Skip to main content
Glama

yuque_create_doc

Create new documents in Yuque knowledge bases by specifying repository ID, title, content, and format to organize and share knowledge effectively.

Instructions

创建新文档 (Create new document)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
repoIdYes知识库ID (Repository ID)
titleYes文档标题 (Document title)
contentYes文档内容 (Document content)
formatNo文档格式,默认markdown (Document format, default markdown)

Implementation Reference

  • Executes the yuque_create_doc tool by invoking YuqueClient.createDoc with provided arguments and formats the response as MCP content.
    async function handleCreateDoc( client: YuqueClient, args: { repoId: number; title: string; content: string; format?: 'markdown' | 'lake' | 'html'; } ) { const doc = await client.createDoc( args.repoId, args.title, args.content, args.format ); return { content: [ { type: 'text', text: JSON.stringify(doc, null, 2), }, ], };
  • Tool definition including name, description, and input schema validation for yuque_create_doc.
    { 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'], }, },
  • Switch case in the main tool dispatcher (handleTool) that registers and routes yuque_create_doc to its handler function.
    case 'yuque_create_doc': return await handleCreateDoc( client, args as { repoId: number; title: string; content: string; format?: 'markdown' | 'lake' | 'html'; } );
  • Core API implementation in YuqueClient that performs the HTTP POST request to create a document in Yuque.
    async createDoc( repoId: number, title: string, content: string, format: 'markdown' | 'lake' | 'html' = 'markdown' ): Promise<YuqueDoc> { return this.request<YuqueDoc>(`/repos/${repoId}/docs`, { method: 'POST', data: { title, slug: this.generateSlug(title), body: content, format, }, }); }
  • src/server.ts:46-67 (registration)
    MCP server request handlers for listing tools (using definitions) and executing tools (dispatching to handlers.ts). This registers all tools including yuque_create_doc.
    server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools: YUQUE_TOOLS, }; }); // Handle tool execution requests server.setRequestHandler(CallToolRequestSchema, async (request) => { try { return await handleTool(request, { client: yuqueClient }); } catch (error) { if (error instanceof McpError) { throw error; } const errorMessage = error instanceof Error ? error.message : String(error); throw new McpError( ErrorCode.InternalError, `Error executing tool: ${errorMessage}` ); } });

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/tanis2010/yuque-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server