Skip to main content
Glama
get-note.ts1.17 kB
import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; import { z } from "zod"; import { ContentConverter } from "../converter"; import { XiaomiNoteClient } from "../client"; import { deriveNoteTitle } from "../note"; import { NotesCache } from "../cache"; export function registerGetNoteTool( server: McpServer, client: XiaomiNoteClient, converter: ContentConverter, cache: NotesCache, ): void { server.registerTool( "get_note", { description: "根据笔记 ID 获取 Markdown 内容", inputSchema: { id: z.string().min(1, "笔记 ID 不能为空").describe("笔记 ID"), }, }, async ({ id }: { id: string }) => { const response = await client.getNote(id); const note = response.data.entry; cache.upsertNote(note); const title = deriveNoteTitle(note, converter); const markdown = converter.xmlToMarkdown(note.content ?? note.snippet ?? ""); const header = title ? `# ${title}\n\n` : ""; return { content: [ { type: "text" as const, text: `${header}${markdown}`.trim(), }, ], }; } ); }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/LaelLuo/mi_note_mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server