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;
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions support for multiple formats but doesn't cover critical aspects like required permissions, rate limits, error handling, or what happens on success (e.g., returns a document ID). For a creation tool with zero annotation coverage, this leaves significant gaps in understanding its behavior.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that front-loads the core purpose ('创建新的语雀文档') and adds useful context about format support. Every word earns its place with no redundancy or wasted text.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (7 parameters, creation operation) and lack of both annotations and output schema, the description is insufficient. It doesn't explain return values, error conditions, or behavioral nuances, leaving the agent under-informed for a mutation tool with multiple inputs.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents all 7 parameters thoroughly. The description adds minimal value beyond the schema, only implying that 'format' supports multiple types without specifying details. Baseline 3 is appropriate when the schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('创建新的语雀文档' - create new Yuque document) and resource ('在指定知识库中' - in specified knowledge base), specifying it supports multiple content formats. It distinguishes from siblings like 'update_doc' or 'delete_doc' by focusing on creation, though it doesn't explicitly contrast with 'get_doc' operations.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is provided on when to use this tool versus alternatives. The description doesn't mention prerequisites (e.g., needing a valid namespace or authentication), nor does it contrast with sibling tools like 'update_doc' for modifications or 'get_repo_docs' for listing documents.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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