search_pages
Find wiki pages by entering keywords to locate relevant information quickly.
Instructions
Search for pages in the wiki using keywords
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | Search query string | |
| limit | No | Maximum number of results to return (default: 10, max: 50) |
Implementation Reference
- index.ts:628-659 (handler)MCP tool call handler for 'search_pages': extracts parameters, calls wikiClient.searchPages, formats results into JSON response with total hits and page details.case "search_pages": { const { query, limit = 10 } = request.params.arguments as { query: string; limit?: number; }; const result = await wikiClient.searchPages(query, Math.min(limit, 50)); // Format search results in a readable way const pages = result.query.search.map((page: any) => ({ title: page.title, snippet: page.snippet, size: page.size, wordCount: page.wordcount, timestamp: page.timestamp })); return { content: [ { type: "text", text: JSON.stringify( { totalHits: result.query.searchinfo.totalhits, pages }, null, 2 ) } ] }; }
- index.ts:379-388 (helper)MediaWikiClient.searchPages method: performs the actual MediaWiki API search query using makeApiCall.async searchPages(query: string, limit: number = 10): Promise<any> { return this.makeApiCall({ action: "query", list: "search", srsearch: query, srlimit: limit, srinfo: "totalhits", srprop: "size|wordcount|timestamp|snippet" }); }
- index.ts:465-484 (schema)Tool object definition with name 'search_pages', description, and inputSchema specifying query (required) and optional limit.const SEARCH_PAGES_TOOL: Tool = { name: "search_pages", description: "Search for pages in the wiki using keywords", inputSchema: { type: "object", properties: { query: { type: "string", description: "Search query string" }, limit: { type: "number", description: "Maximum number of results to return (default: 10, max: 50)", default: 10 } }, required: ["query"] } };
- index.ts:597-607 (registration)Registers SEARCH_PAGES_TOOL in the MCP server's listTools response, making it discoverable.// Register the tools server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: [ SEARCH_PAGES_TOOL, READ_PAGE_TOOL, CREATE_PAGE_TOOL, UPDATE_PAGE_TOOL, GET_PAGE_HISTORY_TOOL, GET_CATEGORIES_TOOL ] }));