UNPKG

mira-app-server

Version:

Mira Server - standalone server application using mira-app-core

103 lines 4.07 kB
"use strict"; /** * folders 模块工具 */ Object.defineProperty(exports, "__esModule", { value: true }); exports.registerFolderTools = registerFolderTools; const zod_1 = require("zod"); const helpers_1 = require("../helpers"); function registerFolderTools(mcp, ctx) { mcp.registerTool('folders_list', { description: '获取素材库的所有文件夹(可按父文件夹筛选)', inputSchema: { libraryId: zod_1.z.string(), parentId: zod_1.z.number().optional().describe('只列出某父文件夹的子项'), }, }, async (args) => { return (0, helpers_1.run)(async () => { const client = ctx.getClient(); if (args.parentId !== undefined) { return await client.folders().getSubFolders(args.libraryId, args.parentId); } return await client.folders().getAll(args.libraryId); }); }); mcp.registerTool('folders_create', { description: '创建文件夹', inputSchema: { libraryId: zod_1.z.string(), title: zod_1.z.string(), parentId: zod_1.z.number().optional(), color: zod_1.z.number().optional(), description: zod_1.z.string().optional(), }, }, async (args) => { return (0, helpers_1.run)(async () => { const client = ctx.getClient(); return await client .folders() .createFolder(args.libraryId, args.title, args.parentId, args.color, args.description); }); }); mcp.registerTool('folders_update', { description: '更新文件夹', inputSchema: { libraryId: zod_1.z.string(), id: zod_1.z.number(), title: zod_1.z.string().optional(), parentId: zod_1.z.number().optional(), color: zod_1.z.number().optional(), description: zod_1.z.string().optional(), }, }, async (args) => { return (0, helpers_1.run)(async () => { const client = ctx.getClient(); const updates = {}; if (args.title !== undefined) updates.title = args.title; if (args.parentId !== undefined) updates.parent_id = args.parentId; if (args.color !== undefined) updates.color = args.color; if (args.description !== undefined) updates.description = args.description; return await client.folders().updateFolder(args.libraryId, args.id, updates); }); }); mcp.registerTool('folders_delete', { description: '删除文件夹', inputSchema: { libraryId: zod_1.z.string(), id: zod_1.z.number(), deleteFiles: zod_1.z.boolean().optional().describe('同时删除文件夹内的文件'), }, }, async (args) => { return (0, helpers_1.run)(async () => { const client = ctx.getClient(); return await client.folders().deleteFolder(args.libraryId, args.id, args.deleteFiles); }); }); mcp.registerTool('folders_move', { description: '将文件移动到指定文件夹', inputSchema: { libraryId: zod_1.z.string(), fileId: zod_1.z.number(), folderId: zod_1.z.number(), }, }, async (args) => { return (0, helpers_1.run)(async () => { const client = ctx.getClient(); return await client.folders().moveFileToFolder(args.libraryId, args.fileId, args.folderId); }); }); mcp.registerTool('folders_remove', { description: '将文件移出文件夹(移到根目录)', inputSchema: { libraryId: zod_1.z.string(), fileId: zod_1.z.number() }, }, async (args) => { return (0, helpers_1.run)(async () => { const client = ctx.getClient(); return await client.folders().removeFileFromFolder(args.libraryId, args.fileId); }); }); } //# sourceMappingURL=folders.js.map