wiki_search
Search Wikipedia for specific queries in your preferred language using this tool. Enhance information retrieval with direct access to Wikipedia content, supporting comprehensive research and knowledge discovery.
Instructions
Alias of wiki.search
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| lang | No | ||
| q | Yes |
Implementation Reference
- src/tools/scholar.ts:4-15 (handler)Core implementation of wikiSearch function that queries Wikipedia REST API for title search results.export async function wikiSearch(q: string, lang = 'vi', top = 5) { const url = `https://${lang}.wikipedia.org/w/rest.php/v1/search/title?q=${encodeURIComponent(q)}&limit=${top}`; const res = await fetchWithLimits(url, 8000, 1024*1024); if (!res.body) return []; const data = JSON.parse(res.body.toString('utf-8')); return (data.pages || []).map((p: any) => ({ title: p.title, url: `https://${lang}.wikipedia.org/wiki/${encodeURIComponent(p.key)}`, snippet: p.description || '', source: 'wikipedia' })); }
- src/server.ts:193-193 (schema)Zod schema defining input parameters for wiki_search tool: query string and optional language.const wikiSearchShape = { q: z.string(), lang: z.string().optional() };
- src/server.ts:201-207 (registration)Registers the 'wiki_search' MCP tool, providing schema and thin handler that calls the core wikiSearch function.server.tool('wiki_search', 'Alias of wiki.search', wikiSearchShape, OPEN, async ({ q, lang }) => { const res = await wikiSearch(q, lang || 'vi'); return { content: [{ type: 'text', text: JSON.stringify(res) }] }; } );