codewiki_search_repos
Search repositories indexed by CodeWiki to find open-source projects with AI-powered documentation. Enter a query to discover relevant repositories and access their wiki content.
Instructions
Search repositories indexed by codewiki.google
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | ||
| limit | No |
Implementation Reference
- src/tools/searchRepos.ts:6-40 (handler)Main tool handler that registers 'codewiki_search_repos' tool with MCP server. It validates input using SearchReposInput schema, calls client.searchRepositories with query and limit, and returns formatted JSON results with repository items and metadata.
export function registerSearchReposTool(mcp: McpServer, client: CodeWikiClient): void { mcp.tool( 'codewiki_search_repos', 'Search repositories indexed by codewiki.google', SearchReposInput.shape, async (rawInput) => { const parsed = SearchReposInput.safeParse(rawInput) if (!parsed.success) { return { content: [{ type: 'text', text: `Invalid arguments: ${parsed.error.message}` }], isError: true, } } try { const { query, limit } = parsed.data const { data: items, meta } = await client.searchRepositories(query, limit) return { content: [{ type: 'text', text: JSON.stringify({ query, count: items.length, items, meta, }, null, 2), }], } } catch (err) { return formatMcpError(err) } }, ) } - src/schemas.ts:5-8 (schema)Input validation schema for the search repos tool. Defines query (required string, min 1 char) and limit (optional number, default 10, range 1-50) parameters.
export const SearchReposInput = z.object({ query: z.string().min(1), limit: z.number().int().min(1).max(50).default(10), }) - src/lib/codewikiClient.ts:77-114 (helper)Client implementation that performs the actual repository search. Makes RPC call to codewiki.google, parses the response payload, and returns structured repository data including fullName, url, description, avatarUrl, and extraScore.
async searchRepositories(query: string, limit = 10): Promise<WithMeta<SearchRepoResult[]>> { const start = performance.now() const { payload, bytes } = await this.callRpc('vyWDAf', [query, limit, query, 0], { sourcePath: '/' }) const rows = Array.isArray(payload) && Array.isArray(payload[0]) ? payload[0] : [] const data = rows .filter((item): item is unknown[] => Array.isArray(item)) .map((item) => { const fullName = typeof item[0] === 'string' ? item[0] : 'unknown/unknown' const url = Array.isArray(item[3]) && typeof item[3][1] === 'string' ? item[3][1] : null let description: string | null = null let avatarUrl: string | null = null let extraScore: number | null = null if (Array.isArray(item[5])) { description = typeof item[5][0] === 'string' ? item[5][0] : null avatarUrl = typeof item[5][1] === 'string' ? item[5][1] : null extraScore = typeof item[5][2] === 'number' ? item[5][2] : null } return { fullName, url, description, avatarUrl, extraScore, raw: item, } }) return { data, meta: { totalBytes: bytes, totalElapsedMs: Math.round(performance.now() - start) }, } } - src/server.ts:27-40 (registration)Server setup where the tool is registered. Creates McpServer instance, instantiates CodeWikiClient from config, and calls registerSearchReposTool to add the tool to the MCP server.
export function createMcpServer(config: CodeWikiConfig): McpServer { const mcp = new McpServer({ name: 'codewiki-mcp', version: pkg.version as string, }) const client = CodeWikiClient.fromConfig(config) registerSearchReposTool(mcp, client) registerFetchRepoTool(mcp, client, config) registerAskRepoTool(mcp, client, config) return mcp }