Skip to main content
Glama

wiki.search

Search Wikipedia titles to find articles by query and language, enabling quick access to encyclopedia content for research and information retrieval.

Instructions

Wikipedia title search (public API).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
qYes
langNo

Implementation Reference

  • Core implementation of wikiSearch: queries Wikipedia REST API for title search, parses JSON response, and returns formatted results with title, URL, snippet, and source.
    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' })); }
  • Zod schema defining input parameters for wiki.search tool: query string 'q' (required) and optional language 'lang'.
    const wikiSearchShape = { q: z.string(), lang: z.string().optional() };
  • src/server.ts:194-200 (registration)
    Registers the 'wiki.search' tool with server.tool, providing description, schema, and a wrapper handler that calls wikiSearch and formats response as MCP content.
    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) }] }; } );
  • src/server.ts:201-207 (registration)
    Registers the alias 'wiki_search' tool, identical to 'wiki.search'.
    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) }] }; } );

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