Skip to main content
Glama

wiki_search

Search Wikipedia for articles matching a query. Retrieve summaries and links. Optionally specify language for localized results.

Instructions

Alias of wiki.search

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
qYes
langNo

Implementation Reference

  • The core handler function for wiki_search. Fetches Wikipedia title suggestions via the REST API and returns 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'
      }));
    }
  • src/server.ts:201-207 (registration)
    Registration of the 'wiki_search' tool as an alias for 'wiki.search'. Defines the shape with 'q' (required string) and 'lang' (optional string), and invokes wikiSearch().
    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) }] };
      }
    );
  • Input schema for wiki_search: 'q' (required string) and 'lang' (optional string). Shared by both 'wiki.search' and its alias 'wiki_search'.
    const wikiSearchShape = { q: z.string(), lang: z.string().optional() };
  • The fetchWithLimits utility used by wikiSearch to make HTTP requests with timeout, size limits, and SSRF protection.
    export async function fetchWithLimits(urlStr: string, timeoutMs = CONFIG.fetchTimeoutMs, maxBytes = CONFIG.maxFetchBytes) {
      const u = new URL(urlStr);
      await assertNotPrivate(u);
    
      const controller = new AbortController();
      const timer = setTimeout(() => controller.abort(), timeoutMs);
      try {
        const res = await request(urlStr, {
          method: 'GET',
          headers: { 'user-agent': 'mcp-multitool/0.2', 'accept': '*/*' },
          signal: controller.signal,
          maxRedirections: 3
        });
    
        const status = res.statusCode;
        const headersRec: Record<string, string> = {};
        for (const [k, v] of Object.entries(res.headers)) {
          headersRec[k] = Array.isArray(v) ? v.join(', ') : String(v ?? '');
        }
    
        if (status >= 400) {
          return { status, headers: headersRec, body: null as any };
        }
    
        const chunks: Buffer[] = [];
        let total = 0;
        for await (const chunk of res.body) {
          const b: Buffer = Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk as any);
          total += b.length;
          if (total > maxBytes) break;
          chunks.push(b);
        }
        const buf = Buffer.concat(chunks);
        const contentType = headersRec['content-type'] || 'application/octet-stream';
        const finalUrl = headersRec['content-location'] || urlStr;
        return { status, headers: headersRec, body: buf, finalUrl, contentType };
      } finally {
        clearTimeout(timer);
      }
    }
  • src/server.ts:194-200 (registration)
    Primary registration of 'wiki.search' tool (the canonical name). wiki_search is an alias that delegates to the same handler.
    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) }] };
      }
    );
Behavior1/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No behavioral information provided beyond annotations. openWorldHint indicates schema flexibility but description says nothing about effects, side effects, or constraints.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness2/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Extremely brief but under-specified. A single phrase that lacks substance; not concise in a helpful way.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness1/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the minimal schema and lack of output schema, the description should compensate but fails entirely. No context about search functionality, results, or usage.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters1/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0% and description adds no meaning to parameters 'q' or 'lang'. No explanation of what they represent or their format.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose2/5

Does the description clearly state what the tool does and how it differs from similar tools?

Description says 'Alias of wiki.search', which is a tautology and provides no specific verb or resource. It doesn't clarify what the tool does beyond being an alias.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance on when to use this tool versus the sibling wiki.search. The description does not mention any context or alternatives.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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