/**
* MCP Tool Definitions for Yuque operations
* 语雀操作MCP工具定义
*/
import { Tool } from '@modelcontextprotocol/sdk/types.js';
/**
* All available Yuque MCP tools
*/
export const YUQUE_TOOLS: Tool[] = [
{
name: 'yuque_get_user',
description: '获取当前用户信息 (Get current user information)',
inputSchema: {
type: 'object',
properties: {},
},
},
{
name: 'yuque_get_repos',
description: '获取知识库列表 (List knowledge repositories)',
inputSchema: {
type: 'object',
properties: {
userId: {
type: 'string',
description: '用户ID,不提供则获取当前用户的知识库 (User ID, defaults to current user)',
},
},
},
},
{
name: 'yuque_get_docs',
description: '获取文档列表 (List documents in a repository)',
inputSchema: {
type: 'object',
properties: {
repoId: {
type: 'number',
description: '知识库ID (Repository ID)',
},
limit: {
type: 'number',
description: '返回数量限制,默认20 (Result limit, default 20)',
minimum: 1,
maximum: 100,
},
offset: {
type: 'number',
description: '偏移量,默认0 (Offset for pagination, default 0)',
minimum: 0,
},
},
required: ['repoId'],
},
},
{
name: 'yuque_get_doc',
description: '获取文档详情 (Get document details)',
inputSchema: {
type: 'object',
properties: {
docId: {
type: 'number',
description: '文档ID (Document ID)',
},
repoId: {
type: 'number',
description: '知识库ID (Repository ID)',
},
},
required: ['docId', 'repoId'],
},
},
{
name: 'yuque_create_doc',
description: '创建新文档 (Create new document)',
inputSchema: {
type: 'object',
properties: {
repoId: {
type: 'number',
description: '知识库ID (Repository ID)',
},
title: {
type: 'string',
description: '文档标题 (Document title)',
minLength: 1,
maxLength: 200,
},
content: {
type: 'string',
description: '文档内容 (Document content)',
minLength: 1,
},
format: {
type: 'string',
enum: ['markdown', 'lake', 'html'],
description: '文档格式,默认markdown (Document format, default markdown)',
},
},
required: ['repoId', 'title', 'content'],
},
},
{
name: 'yuque_update_doc',
description: '更新文档 (Update existing document)',
inputSchema: {
type: 'object',
properties: {
docId: {
type: 'number',
description: '文档ID (Document ID)',
},
repoId: {
type: 'number',
description: '知识库ID (Repository ID)',
},
title: {
type: 'string',
description: '文档标题 (Document title)',
minLength: 1,
maxLength: 200,
},
content: {
type: 'string',
description: '文档内容 (Document content)',
},
format: {
type: 'string',
enum: ['markdown', 'lake', 'html'],
description: '文档格式 (Document format)',
},
},
required: ['docId', 'repoId'],
},
},
{
name: 'yuque_delete_doc',
description: '删除文档 (Delete document)',
inputSchema: {
type: 'object',
properties: {
docId: {
type: 'number',
description: '文档ID (Document ID)',
},
repoId: {
type: 'number',
description: '知识库ID (Repository ID)',
},
},
required: ['docId', 'repoId'],
},
},
{
name: 'yuque_search_docs',
description: '搜索文档 (Search documents)',
inputSchema: {
type: 'object',
properties: {
query: {
type: 'string',
description: '搜索关键词 (Search keywords)',
minLength: 1,
maxLength: 100,
},
repoId: {
type: 'number',
description: '知识库ID,可选,不提供则全局搜索 (Repository ID, optional, global search if not provided)',
},
},
required: ['query'],
},
},
{
name: 'yuque_create_repo',
description: '创建知识库 (Create knowledge repository)',
inputSchema: {
type: 'object',
properties: {
name: {
type: 'string',
description: '知识库名称 (Repository name)',
minLength: 1,
maxLength: 100,
},
description: {
type: 'string',
description: '知识库描述,可选 (Repository description, optional)',
maxLength: 500,
},
isPublic: {
type: 'boolean',
description: '是否公开,默认false (Whether public, default false)',
},
},
required: ['name'],
},
},
];
/**
* Get tool definition by name
*/
export function getToolDefinition(name: string): Tool | undefined {
return YUQUE_TOOLS.find(tool => tool.name === name);
}
/**
* Get all tool names
*/
export function getToolNames(): string[] {
return YUQUE_TOOLS.map(tool => tool.name);
}