yuque_create_repo
Create a knowledge repository on Yuque platform to organize and manage documents. Specify repository name, optional description, and visibility settings to establish structured documentation space.
Instructions
创建知识库 (Create knowledge repository)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | 知识库名称 (Repository name) | |
| description | No | 知识库描述,可选 (Repository description, optional) | |
| isPublic | No | 是否公开,默认false (Whether public, default false) |
Implementation Reference
- src/tools/handlers.ts:242-263 (handler)The handler function that processes the yuque_create_repo tool call, extracts arguments, invokes YuqueClient.createRepo, and returns the formatted response.async function handleCreateRepo( client: YuqueClient, args: { name: string; description?: string; isPublic?: boolean; } ) { const repo = await client.createRepo( args.name, args.description, args.isPublic || false ); return { content: [ { type: 'text', text: JSON.stringify(repo, null, 2), }, ], }; }
- src/tools/definitions.ts:177-202 (schema)Tool schema defining the name, description, and input validation schema for yuque_create_repo.{ name: 'yuque_create_repo', description: '创建知识库 (Create knowledge repository)', inputSchema: { type: 'object', properties: { name: { type: 'string', description: '知识库名称 (Repository name)', minLength: 1, maxLength: 100, }, description: { type: 'string', description: '知识库描述,可选 (Repository description, optional)', maxLength: 500, }, isPublic: { type: 'boolean', description: '是否公开,默认false (Whether public, default false)', }, }, required: ['name'], }, }, ];
- src/server.ts:45-67 (registration)MCP server registration of tool list handler (returns YUQUE_TOOLS including yuque_create_repo) and tool call handler (dispatches to handleTool).// Handle tool listing requests server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools: YUQUE_TOOLS, }; }); // Handle tool execution requests 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}` ); } });
- src/yuque-client.ts:253-274 (helper)YuqueClient method that performs the actual API call to create a repository, called by the tool handler.async createRepo( name: string, description?: string, isPublic: boolean = false ): Promise<YuqueRepo> { const slug = this.generateSlug(name); // Get current user ID for repository creation const user = await this.getUser(); const userId = user.id; return this.request<YuqueRepo>(`/users/${userId}/repos`, { method: 'POST', data: { name, slug, description: description || '', public: isPublic ? 1 : 0, type: 'Book', }, }); }