wiki_get
Retrieve structured Wikipedia entries by specifying the article title and language. Enhances local LLMs with accurate, accessible information directly from Wikipedia.
Instructions
Alias of wiki.get
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| lang | No | ||
| title | Yes |
Implementation Reference
- src/tools/scholar.ts:17-29 (handler)Core handler function that fetches and parses Wikipedia page summary by title using the REST API.export async function wikiGet(title: string, lang = 'vi') { const url = `https://${lang}.wikipedia.org/api/rest_v1/page/summary/${encodeURIComponent(title)}`; const res = await fetchWithLimits(url, 8000, 1024*1024); if (!res.body) return null; const data = JSON.parse(res.body.toString('utf-8')); return { title: data.title, url: data.content_urls?.desktop?.page || data.canonical || '', abstract: data.extract || '', source: 'wikipedia', updatedAt: data.timestamp || new Date().toISOString() }; }
- src/server.ts:218-224 (registration)Registration of the 'wiki_get' tool, which calls the wikiGet handler function.server.tool('wiki_get', 'Alias of wiki.get', wikiGetShape, OPEN, async ({ title, lang }) => { const res = await wikiGet(title, lang || 'vi'); return { content: [{ type: 'text', text: JSON.stringify(res) }] }; } );
- src/server.ts:210-210 (schema)Input schema definition for wiki_get tool using Zod (title required, lang optional).const wikiGetShape = { title: z.string(), lang: z.string().optional() };
- src/server.ts:211-217 (registration)Related primary registration of 'wiki.get' tool, of which wiki_get is an alias.server.tool('wiki.get', 'Wikipedia summary by title.', wikiGetShape, OPEN, async ({ title, lang }) => { const res = await wikiGet(title, lang || 'vi'); return { content: [{ type: 'text', text: JSON.stringify(res) }] }; } );