Skip to main content
Glama

update_doc

Modify existing documents in Yuque knowledge bases by updating titles, content, or access permissions using document IDs and namespaces.

Instructions

更新语雀中已存在的文档,可以修改标题、内容或权限设置

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
namespaceYes知识库的命名空间,格式为 user/repo
idYes要更新的文档ID
titleNo文档的新标题
slugNo文档的新短链接名称
bodyNo文档的新内容,支持Markdown格式
publicNo文档的公开状态,0(私密)、1(公开)、2(企业内公开)
formatNo内容格式,可选值:markdown、html、lake
accessTokenNo用于认证 API 请求的令牌

Implementation Reference

  • MCP tool handler for 'update_doc' that prepares update data and delegates to YuqueService.updateDoc, handles errors and formats response.
      namespace,
      id,
      title,
      slug,
      body,
      public: publicLevel,
      format,
      accessToken,
    }) => {
      try {
        Logger.log(`Updating document ${id} in repository: ${namespace}`);
        const yuqueService = this.createYuqueService(accessToken);
        const updateData: any = {};
        if (title !== undefined) updateData.title = title;
        if (slug !== undefined) updateData.slug = slug;
        if (body !== undefined) updateData.body = body;
        if (publicLevel !== undefined) updateData.public = publicLevel;
        if (format !== undefined) updateData.format = format;
    
        const doc = await yuqueService.updateDoc(namespace, id, updateData);
    
        Logger.log(`Successfully updated document: ${doc.title}`);
        return {
          content: [{ type: "text", text: JSON.stringify(doc, null, 2) }],
        };
      } catch (error) {
        Logger.error(`Error updating doc ${id} in repo ${namespace}:`, error);
        return {
          content: [{ type: "text", text: `Error updating doc: ${error}` }],
        };
      }
    }
  • Zod input schema defining parameters for the update_doc tool.
      namespace: z.string().describe("知识库的命名空间,格式为 user/repo"),
      id: z.number().describe("要更新的文档ID"),
      title: z.string().optional().describe("文档的新标题"),
      slug: z.string().optional().describe("文档的新短链接名称"),
      body: z.string().optional().describe("文档的新内容,支持Markdown格式"),
      public: z
        .number()
        .optional()
        .describe("文档的公开状态,0(私密)、1(公开)、2(企业内公开)"),
      format: z
        .string()
        .optional()
        .describe("内容格式,可选值:markdown、html、lake"),
      accessToken: z.string().optional().describe("用于认证 API 请求的令牌"),
    },
  • src/server.ts:402-453 (registration)
    Registration of the 'update_doc' tool using McpServer.tool() method, including name, description, schema, and handler.
      "update_doc",
      "更新语雀中已存在的文档,可以修改标题、内容或权限设置",
      {
        namespace: z.string().describe("知识库的命名空间,格式为 user/repo"),
        id: z.number().describe("要更新的文档ID"),
        title: z.string().optional().describe("文档的新标题"),
        slug: z.string().optional().describe("文档的新短链接名称"),
        body: z.string().optional().describe("文档的新内容,支持Markdown格式"),
        public: z
          .number()
          .optional()
          .describe("文档的公开状态,0(私密)、1(公开)、2(企业内公开)"),
        format: z
          .string()
          .optional()
          .describe("内容格式,可选值:markdown、html、lake"),
        accessToken: z.string().optional().describe("用于认证 API 请求的令牌"),
      },
      async ({
        namespace,
        id,
        title,
        slug,
        body,
        public: publicLevel,
        format,
        accessToken,
      }) => {
        try {
          Logger.log(`Updating document ${id} in repository: ${namespace}`);
          const yuqueService = this.createYuqueService(accessToken);
          const updateData: any = {};
          if (title !== undefined) updateData.title = title;
          if (slug !== undefined) updateData.slug = slug;
          if (body !== undefined) updateData.body = body;
          if (publicLevel !== undefined) updateData.public = publicLevel;
          if (format !== undefined) updateData.format = format;
    
          const doc = await yuqueService.updateDoc(namespace, id, updateData);
    
          Logger.log(`Successfully updated document: ${doc.title}`);
          return {
            content: [{ type: "text", text: JSON.stringify(doc, null, 2) }],
          };
        } catch (error) {
          Logger.error(`Error updating doc ${id} in repo ${namespace}:`, error);
          return {
            content: [{ type: "text", text: `Error updating doc: ${error}` }],
          };
        }
      }
    );
  • YuqueService helper method that makes the actual PUT API request to update the document in Yuque.
    async updateDoc(
      namespace: string,
      id: number,
      data: {
        title?: string;
        slug?: string;
        body?: string;
        public?: number;
        format?: string;
      }
    ): Promise<YuqueDoc> {
      const response = await this.client.put(`/repos/${namespace}/docs/${id}`, data);
      return response.data.data;
    }
Behavior2/5

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

No annotations are provided, so the description carries full burden. It states this is an update operation ('更新'), implying mutation, but doesn't disclose behavioral traits like authentication requirements (though accessToken parameter hints at this), rate limits, whether changes are reversible, what happens to unspecified fields, or error conditions. For a mutation tool with zero annotation coverage, this is a significant gap.

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

Conciseness4/5

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

The description is a single, efficient sentence in Chinese that front-loads the core purpose. It wastes no words but could be slightly more structured (e.g., separating scope from modifiable fields). Every part earns its place, making it appropriately concise.

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 this is a mutation tool with 8 parameters, no annotations, and no output schema, the description is incomplete. It doesn't cover authentication needs (implied by accessToken but not stated), response format, error handling, or behavioral constraints. For a tool of this complexity with no structured safety hints, the description should provide more contextual guidance.

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 8 parameters thoroughly. The description mentions '标题、内容或权限设置' (title, content, or permission settings), which maps to title, body, and public parameters, but adds no additional semantic context beyond what the schema provides. With high schema coverage, baseline 3 is appropriate.

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 verb ('更新' meaning 'update') and resource ('语雀中已存在的文档' meaning 'existing documents in Yuque'), and specifies what can be modified ('标题、内容或权限设置' meaning 'title, content, or permission settings'). It distinguishes from create_doc by specifying '已存在的' (existing), but doesn't explicitly differentiate from other update operations if they exist.

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?

The description provides no guidance on when to use this tool versus alternatives like create_doc or delete_doc. It doesn't mention prerequisites (e.g., needing an existing document ID) or contextual constraints (e.g., user permissions). The only implied usage is for updating existing documents, but no explicit alternatives or exclusions are stated.

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