Skip to main content
Glama

wiki_search

Search Wikipedia articles to retrieve information on specific topics using a query parameter, supporting multiple languages for comprehensive research.

Instructions

Alias of wiki.search

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
qYes
langNo

Implementation Reference

  • Core implementation of wikiSearch function that queries Wikipedia's 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:201-207 (registration)
    Registration of the 'wiki_search' tool in the MCP server, which wraps the wikiSearch handler.
    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) }] }; } );
  • Zod schema defining input parameters for wiki_search tool (q required, lang optional).
    const wikiSearchShape = { q: z.string(), lang: z.string().optional() };
  • src/server.ts:194-200 (registration)
    Primary registration of 'wiki.search' tool, of which wiki_search is an alias.
    server.tool('wiki.search', 'Wikipedia title search (public API).', wikiSearchShape, OPEN, async ({ q, lang }) => { const res = await wikiSearch(q, lang || 'vi'); return { content: [{ type: 'text', text: JSON.stringify(res) }] }; } );

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/khanhs-234/tool4lm'

If you have feedback or need assistance with the MCP directory API, please join our Discord server