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}`
        );
      }
    });
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 states this is a creation operation but doesn't mention any behavioral traits: it doesn't specify required permissions, whether the operation is idempotent, what happens on conflicts, or what the response looks like (since there's no output schema). This leaves significant gaps for a mutation tool.

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 extremely concise—a single bilingual phrase that directly states the purpose. There's no wasted verbiage, and it's front-loaded with the essential information. Every word earns its place.

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 that this is a mutation tool (creates new documents) with no annotations and no output schema, the description is incomplete. It doesn't address behavioral aspects like permissions, side effects, or response format, leaving the agent with insufficient context to use the tool effectively beyond basic parameter passing.

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?

The schema description coverage is 100%, so all parameters are documented in the schema itself. The description adds no additional parameter semantics beyond what's already in the schema (e.g., it doesn't explain relationships between parameters or provide usage examples). This meets the baseline for high schema coverage.

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 document') and the resource ('document'), making the purpose immediately understandable. However, it doesn't differentiate this tool from its sibling 'yuque_update_doc' (which also modifies documents) or specify what distinguishes creation from updating in this context.

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. It doesn't mention prerequisites (like needing an existing repository), when not to use it (e.g., for updating existing documents), or direct alternatives among the sibling tools (such as yuque_update_doc for modifications).

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/tanis2010/yuque-mcp-server'

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