yuque_search_docs
Search documents in Yuque knowledge bases using keywords to find relevant information across repositories or within specific ones.
Instructions
搜索文档 (Search documents)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | 搜索关键词 (Search keywords) | |
| repoId | No | 知识库ID,可选,不提供则全局搜索 (Repository ID, optional, global search if not provided) |
Implementation Reference
- src/tools/handlers.ts:227-239 (handler)The main handler function for the 'yuque_search_docs' MCP tool. It receives arguments, calls YuqueClient.searchDocs, and returns the results formatted as MCP content (JSON string).async function handleSearchDocs( client: YuqueClient, args: { query: string; repoId?: number } ) { const docs = await client.searchDocs(args.query, args.repoId); return { content: [ { type: 'text', text: JSON.stringify(docs, null, 2), }, ], };
- src/tools/definitions.ts:157-176 (schema)The tool definition including name, description, and input schema validation for 'yuque_search_docs'.{ name: 'yuque_search_docs', description: '搜索文档 (Search documents)', inputSchema: { type: 'object', properties: { query: { type: 'string', description: '搜索关键词 (Search keywords)', minLength: 1, maxLength: 100, }, repoId: { type: 'number', description: '知识库ID,可选,不提供则全局搜索 (Repository ID, optional, global search if not provided)', }, }, required: ['query'], }, },
- src/yuque-client.ts:237-248 (helper)The core helper method in YuqueClient that performs the actual API search request to Yuque's /search endpoint with query parameters./** * Search documents */ async searchDocs(query: string, repoId?: number): Promise<YuqueDoc[]> { const params = new URLSearchParams({ q: query, type: 'doc', // Required parameter }); if (repoId) params.append('repo_id', repoId.toString()); return this.request<YuqueDoc[]>(`/search?${params.toString()}`); }
- src/tools/handlers.ts:71-75 (registration)The dispatch case in the main handleTool switch statement that registers and routes 'yuque_search_docs' calls to the specific handler function.case 'yuque_search_docs': return await handleSearchDocs( client, args as { query: string; repoId?: number } );
- src/server.ts:46-50 (registration)Registration of the tool list handler, which returns YUQUE_TOOLS array including the schema for 'yuque_search_docs'.server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools: YUQUE_TOOLS, }; });