mira-app-server
Version:
Mira Server - standalone server application using mira-app-core
93 lines • 3.68 kB
JavaScript
"use strict";
/**
* tags 模块工具
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.registerTagTools = registerTagTools;
const zod_1 = require("zod");
const helpers_1 = require("../helpers");
function registerTagTools(mcp, ctx) {
mcp.registerTool('tags_list', {
description: '获取素材库的所有标签',
inputSchema: { libraryId: zod_1.z.string() },
}, async (args) => {
return (0, helpers_1.run)(async () => {
const client = ctx.getClient();
return await client.tags().getAll(args.libraryId);
});
});
mcp.registerTool('tags_create', {
description: '创建标签',
inputSchema: {
libraryId: zod_1.z.string(),
title: zod_1.z.string(),
parentId: zod_1.z.number().optional().describe('父标签 ID'),
color: zod_1.z.number().optional().describe('颜色(数字代码)'),
description: zod_1.z.string().optional(),
},
}, async (args) => {
return (0, helpers_1.run)(async () => {
const client = ctx.getClient();
return await client
.tags()
.createTag(args.libraryId, args.title, args.parentId, args.color, args.description);
});
});
mcp.registerTool('tags_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.tags().updateTag(args.libraryId, args.id, updates);
});
});
mcp.registerTool('tags_delete', {
description: '删除标签',
inputSchema: { libraryId: zod_1.z.string(), id: zod_1.z.number() },
}, async (args) => {
return (0, helpers_1.run)(async () => {
const client = ctx.getClient();
return await client.tags().deleteTag(args.libraryId, args.id);
});
});
mcp.registerTool('tags_file_set', {
description: '为文件设置标签(tags 可为名称或 ID,服务端自动解析名称)',
inputSchema: {
libraryId: zod_1.z.string(),
fileId: zod_1.z.number(),
tags: zod_1.z.array(zod_1.z.string()).describe('标签数组(名称或 ID)'),
},
}, async (args) => {
return (0, helpers_1.run)(async () => {
const client = ctx.getClient();
return await client.tags().addTagsToFile(args.libraryId, args.fileId, args.tags);
});
});
mcp.registerTool('tags_file_get', {
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.tags().getFileTagList(args.libraryId, args.fileId);
});
});
}
//# sourceMappingURL=tags.js.map