UNPKG

mcp-server-flomo

Version:
57 lines 1.68 kB
#!/usr/bin/env node import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js"; import { z } from "zod"; if (!process.env.FLOMO_API_URL) { throw new Error("FLOMO_API_URL is not set, apply a personal access token to the environment variable from https://v.flomoapp.com/mine"); } const flomoApiUrl = process.env.FLOMO_API_URL; const server = new McpServer({ name: "mcp-server-flomo", version: "0.0.1", }, { capabilities: { logging: {}, }, }); // declare tool capabilities server.tool("newNote", "Create a new note in Flomo", { input: z.string() }, async (input) => { try { const response = await createFlomoNote(input.input); return { content: [ { type: "text", text: `${JSON.stringify(response)}`, }, ], }; } catch (error) { return { content: [ { type: "text", text: `${JSON.stringify(error)}`, }, ], }; } }); async function createFlomoNote(content) { const body = { content: content, }; return await fetch(flomoApiUrl, { method: "POST", headers: { "Content-Type": "application/json", }, body: JSON.stringify(body), }).then((res) => res.json()); } // declare resource capabilities // Flomo api does not support resource capabilities const transport = new StdioServerTransport(); await server.connect(transport); //# sourceMappingURL=index.js.map