Skip to main content
Glama

search

Search documents or knowledge bases in Yuque platform using keywords, with filters for content type, scope, and author.

Instructions

在语雀平台中搜索文档或知识库内容,支持范围和作者筛选

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYes搜索关键词
typeYes要搜索的内容类型:doc(文档) 或 repo(知识库)
scopeNo搜索范围,不填默认搜索当前用户/团队
pageNo页码,默认为1
creatorNo仅搜索指定作者的内容
accessTokenNo用于认证 API 请求的令牌

Implementation Reference

  • The main handler function for the 'search' MCP tool. It logs the search parameters, creates a YuqueService instance, calls the search method, formats the results as JSON text content, or returns an error message.
    async ({ query, type, scope, page, creator, accessToken }) => { try { Logger.log(`Searching for: ${query} with type: ${type}`); const yuqueService = this.createYuqueService(accessToken); const results = await yuqueService.search( query, type, scope, page, creator ); Logger.log(`Successfully found ${results.length} results`); return { content: [{ type: "text", text: JSON.stringify(results, null, 2) }], }; } catch (error) { Logger.error(`Error searching for ${query}:`, error); return { content: [{ type: "text", text: `Error searching: ${error}` }], }; } }
  • Zod input schema defining parameters for the 'search' tool: query (required string), type (enum doc/repo), optional scope, page, creator, accessToken.
    { query: z.string().describe("搜索关键词"), type: z .enum(["doc", "repo"]) .describe("要搜索的内容类型:doc(文档) 或 repo(知识库)"), scope: z .string() .optional() .describe("搜索范围,不填默认搜索当前用户/团队"), page: z.number().optional().describe("页码,默认为1"), creator: z.string().optional().describe("仅搜索指定作者的内容"), accessToken: z.string().optional().describe("用于认证 API 请求的令牌"), },
  • src/server.ts:492-531 (registration)
    Registration of the 'search' tool on the MCP server using server.tool(), including name, description, input schema, and handler function.
    this.server.tool( "search", "在语雀平台中搜索文档或知识库内容,支持范围和作者筛选", { query: z.string().describe("搜索关键词"), type: z .enum(["doc", "repo"]) .describe("要搜索的内容类型:doc(文档) 或 repo(知识库)"), scope: z .string() .optional() .describe("搜索范围,不填默认搜索当前用户/团队"), page: z.number().optional().describe("页码,默认为1"), creator: z.string().optional().describe("仅搜索指定作者的内容"), accessToken: z.string().optional().describe("用于认证 API 请求的令牌"), }, async ({ query, type, scope, page, creator, accessToken }) => { try { Logger.log(`Searching for: ${query} with type: ${type}`); const yuqueService = this.createYuqueService(accessToken); const results = await yuqueService.search( query, type, scope, page, creator ); Logger.log(`Successfully found ${results.length} results`); return { content: [{ type: "text", text: JSON.stringify(results, null, 2) }], }; } catch (error) { Logger.error(`Error searching for ${query}:`, error); return { content: [{ type: "text", text: `Error searching: ${error}` }], }; } } );
  • YuqueService helper method that performs the actual HTTP GET request to Yuque API /search endpoint with query parameters.
    async search(q: string, type: 'doc' | 'repo', scope?: string, page?: number, creator?: string): Promise<YuqueSearchResult[]> { const params: any = { q, type }; if (scope) params.scope = scope; if (page) params.page = page; if (creator) params.creator = creator; const response = await this.client.get('/search', { params }); return response.data.data; }
  • TypeScript interface defining the structure of search results returned by Yuque API.
    export interface YuqueSearchResult { id: number; type: 'doc' | 'repo'; title: string; summary: string; url: string; info: string; target: YuqueDoc | YuqueRepo; }

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