import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
import { NotesCache } from "../cache";
export function registerFoldersListResource(server: McpServer, cache: NotesCache): void {
server.registerResource(
"folders",
"minote://folders",
{
title: "文件夹列表",
description: "返回所有文件夹的基本信息",
mimeType: "text/plain",
},
async () => {
const folders = cache
.getFolders()
.sort((a, b) => b.modifyDate - a.modifyDate);
const lines = folders.map((folder, index) => {
const modified = new Date(folder.modifyDate).toISOString();
const subject = folder.subject || "(未命名)";
return `${index + 1}. [${folder.id}] ${subject} (${modified})`;
});
return {
contents: [
{
uri: "minote://folders",
text: lines.length > 0 ? lines.join("\n") : "暂无文件夹",
},
],
};
},
);
}