import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
import { NotesCache } from "../cache";
export function registerListNotesTool(server: McpServer, cache: NotesCache): void {
server.tool("list_notes", "列出所有笔记", async () => {
const items = cache.getNotesListItems();
if (items.length === 0) {
return {
content: [
{
type: "text" as const,
text: "暂无笔记。",
},
],
};
}
const lines = items
.map((item, index) => {
const modifyDate = new Date(item.modifyDate).toISOString();
return `${index + 1}. [${item.id}] ${item.title} (${modifyDate})`;
})
.join("\n");
return {
content: [
{
type: "text" as const,
text: lines,
},
],
};
});
}