Skip to main content
Glama

yuque_create_doc

Create new documents in Yuque knowledge bases using markdown, lake, or HTML formats to organize and share information.

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

  • The specific handler function for yuque_create_doc that calls YuqueClient.createDoc and returns the created document as JSON text 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'], }, },
  • Registration of the tool name in the main switch dispatcher within handleTool function.
    case 'yuque_create_doc': return await handleCreateDoc( client, args as { repoId: number; title: string; content: string; format?: 'markdown' | 'lake' | 'html'; } );
  • Core utility function in YuqueClient that performs the actual HTTP POST request to create a document in Yuque, including slug generation.
    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:53-67 (registration)
    Registers the handleTool function as the MCP CallToolRequest handler in the server.
    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