Skip to main content
Glama

create_doc

Create new documents in Yuque knowledge bases with Markdown, HTML, or lake format content, specifying visibility levels and URL slugs.

Instructions

在指定知识库中创建新的语雀文档,支持多种格式内容

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
namespaceYes知识库的命名空间,格式为 user/repo
titleYes文档标题
slugYes文档的短链接名称,用于URL路径
bodyYes文档内容,支持Markdown格式
formatNo内容格式,可选值:markdown、html、lake,默认为 markdown
public_levelNo公开性,可选值:0(私密)、1(公开)、2(企业内公开),默认为 1
accessTokenNo用于认证 API 请求的令牌

Implementation Reference

  • The MCP tool handler function that executes the create_doc tool logic by instantiating YuqueService and calling its createDoc method.
    async ({ namespace, title, slug, body, format = "markdown", public_level = 1, accessToken, }) => { try { Logger.log( `Creating document "${title}" in repository: ${namespace}` ); const yuqueService = this.createYuqueService(accessToken); const doc = await yuqueService.createDoc( namespace, title, slug, body, format, public_level ); Logger.log(`Successfully created document: ${doc.title}`); return { content: [{ type: "text", text: JSON.stringify(doc, null, 2) }], }; } catch (error) { Logger.error(`Error creating doc in repo ${namespace}:`, error); return { content: [{ type: "text", text: `Error creating doc: ${error}` }], }; } }
  • Zod input schema defining parameters for the create_doc tool: namespace, title, slug, body, format, public_level, accessToken.
    { namespace: z.string().describe("知识库的命名空间,格式为 user/repo"), title: z.string().describe("文档标题"), slug: z.string().describe("文档的短链接名称,用于URL路径"), body: z.string().describe("文档内容,支持Markdown格式"), format: z .string() .optional() .describe("内容格式,可选值:markdown、html、lake,默认为 markdown"), public_level: z .number() .optional() .describe( "公开性,可选值:0(私密)、1(公开)、2(企业内公开),默认为 1" ), accessToken: z.string().optional().describe("用于认证 API 请求的令牌"), },
  • src/server.ts:344-344 (registration)
    Registration of the create_doc tool using McpServer.tool method.
    this.server.tool(
  • src/server.ts:345-345 (registration)
    Tool name 'create_doc' specified in registration.
    "create_doc",
  • YuqueService helper method that performs the actual API POST request to create a document in Yuque.
    async createDoc( namespace: string, title: string, slug: string, body: string, format: string = 'markdown', public_level: number = 1 ): Promise<YuqueDoc> { const response = await this.client.post(`/repos/${namespace}/docs`, { title, slug, public: public_level, format, body, }); return response.data.data; }

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/HenryHaoson/Yuque-MCP-Server'

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