wiki_get
Retrieve Wikipedia articles by specifying a title and optional language. Access structured encyclopedia content for research or information needs.
Instructions
Alias of wiki.get
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| title | Yes | ||
| lang | No |
Implementation Reference
- src/tools/scholar.ts:17-29 (handler)The core handler function `wikiGet` that fetches a Wikipedia page summary via the REST API and returns title, url, abstract, source, and updatedAt.
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:210-210 (schema)Input schema definition `wikiGetShape` with `title` (required string) and `lang` (optional string).
const wikiGetShape = { title: z.string(), lang: z.string().optional() }; - src/server.ts:211-224 (registration)Registration of the 'wiki.get' tool and its alias 'wiki_get' via server.tool(). Both call the same `wikiGet` handler.
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) }] }; } ); 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/utils/http.ts:1-1 (helper)The `fetchWithLimits` utility function used by `wikiGet` to make HTTP requests with size/timeout limits and DNS rebinding protection.
import { request } from 'undici';