write_note
Create and store text notes within the weather-focused MCP server for personal documentation and reference.
Instructions
Write a new note
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| content | Yes | Text content of the note |
Implementation Reference
- src/index.ts:289-305 (handler)The handler in CallToolRequestSchema that executes the write_note logic by calling the FlomoClient.
case "write_note": { const content = String(request.params.arguments?.content); if (!content) { throw new Error("Content is required"); } const apiUrl = "https://flomoapp.com/iwh/MjY4NTU3NQ/b3a150f427dfaa7924b26f68539db56b/"; const flomoClient = new FlomoClient({ apiUrl }); const result = await flomoClient.writeNote({ content }); return { content: [{ type: "text", text: `Write note to flomo success: ${JSON.stringify(result)}` }] }; } - src/clientUtil.ts:15-66 (handler)The actual implementation of writeNote that interacts with the Flomo API via HTTPS.
async writeNote({ content }: { content: string }) { if (!content) { throw new Error('Content is required'); } const body = new URLSearchParams({ content }).toString(); const url = new URL(this.apiUrl); const result = await new Promise<{ statusCode: number; data: string }>((resolve, reject) => { const req = https.request( { hostname: url.hostname, path: url.pathname + url.search, method: 'POST', rejectUnauthorized: false, headers: { 'Content-Type': 'application/x-www-form-urlencoded', 'Content-Length': Buffer.byteLength(body), }, }, (res) => { const chunks: Buffer[] = []; res.on('data', (chunk: Buffer) => chunks.push(chunk)); res.on('end', () => resolve({ statusCode: res.statusCode ?? 0, data: Buffer.concat(chunks).toString('utf8'), }), ); }, ); req.on('error', reject); req.write(body); req.end(); }); if (result.statusCode < 200 || result.statusCode >= 300) { let detail = `HTTP ${result.statusCode}`; try { const json = JSON.parse(result.data); if (json.message) detail += `: ${json.message}`; else if (json.error) detail += `: ${json.error}`; } catch { if (result.data) detail += `: ${result.data.slice(0, 200)}`; } throw new Error(`Failed to write note (${detail})`); } try { return JSON.parse(result.data); } catch { return { ok: true }; } } - src/index.ts:169-182 (registration)The tool registration for write_note in the ListToolsRequestSchema handler.
{ name: "write_note", description: "Write a new note", inputSchema: { type: "object", properties: { content: { type: "string", description: "Text content of the note" } }, required: ["content"] } },