Skip to main content
Glama

search_wiki

Search component documentation to find where a specific class, rule, or pattern is documented. Returns file name, matching line, and context lines.

Instructions

Full-text search across all Components-Wiki .md files. Returns file name + matching line + 2 lines of context. Use this to find where a specific class, rule, or pattern is documented.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesSearch term (case-insensitive)
max_resultsNoMax results to return (default 20)

Implementation Reference

  • The handler function for the 'search_wiki' tool. It performs full-text search across all wiki files by iterating through WIKI_FILES, reading each one via readWikiFile(), and matching lines against the query (case-insensitive). Results include surrounding context lines (before/after the match). Max results default to 20.
    server.tool("search_wiki", "Full-text search across all component wiki documentation. Use this to find where a CSS class, rule, or pattern is documented. Do NOT search local files — this tool searches the complete wiki.", { query: z.string(), max_results: z.number().optional() }, async ({ query, max_results }) => {
      const q = query.toLowerCase();
      const max = max_results || 20;
      const results: string[] = [];
      for (const file of WIKI_FILES) {
        const content = await readWikiFile(file);
        if (content.startsWith("[")) continue;
        const lines = content.split("\n");
        for (let i = 0; i < lines.length; i++) {
          if (lines[i].toLowerCase().includes(q)) {
            const ctx = [lines[i-1]?.trim(), `→ ${lines[i].trim()}`, lines[i+1]?.trim()].filter(Boolean).join("\n");
            results.push(`**${file}** line ${i+1}:\n${ctx}`);
            if (results.length >= max) break;
          }
        }
        if (results.length >= max) break;
      }
      return { content: [{ type: "text" as const, text: results.length ? `Found ${results.length} result(s):\n\n${results.join("\n\n---\n\n")}` : `No results for "${query}"` }] };
    });
  • Input schema for search_wiki: 'query' (required string) and optional 'max_results' (number).
    server.tool("search_wiki", "Full-text search across all component wiki documentation. Use this to find where a CSS class, rule, or pattern is documented. Do NOT search local files — this tool searches the complete wiki.", { query: z.string(), max_results: z.number().optional() }, async ({ query, max_results }) => {
  • api/mcp.ts:626-626 (registration)
    Tool registration via server.tool() with name 'search_wiki' and description 'Full-text search across all component wiki documentation.'
    server.tool("search_wiki", "Full-text search across all component wiki documentation. Use this to find where a CSS class, rule, or pattern is documented. Do NOT search local files — this tool searches the complete wiki.", { query: z.string(), max_results: z.number().optional() }, async ({ query, max_results }) => {
  • WIKI_FILES array - the list of wiki files that search_wiki iterates over for full-text search.
    const WIKI_FILES = [
      "INDEX.md","actionbar.md","app_shells.md","button-row.md","classic_tab.md",
      "data_table_type1.md","data_table_type2.md","design_tokens.md","drawer.md",
      "echarts-elegant-theme.md","echarts-widget.md","form_dropdown.md","form_input.md",
      "header.md","icon-engine.md","icons.md","layout_shell.md","line_tab.md",
      "note-container.md","predefined_charts.md","rpt-chart-floater.md",
      "sidemenu_variant1_settings.md","sidemenu_variant2_reports.md","stat_card.md",
      "tile_widgets.md","topnavbar.md","widget.md",
    ];
  • readWikiFile() helper function used by search_wiki to fetch wiki file content from GitHub API with caching.
    async function readWikiFile(filename: string): Promise<string> {
      const name = filename.endsWith(".md") ? filename : `${filename}.md`;
      const cached = wikiCache.get(name);
      if (cached && Date.now() - cached.fetchedAt < WIKI_CACHE_TTL_MS) {
        return cached.text;
      }
      if (!GH_TOKEN)
        return `[ERROR: ELEGANT_GH_TOKEN env var not set]`;
      try {
        // Cache-bust GitHub API with a timestamp parameter on cold miss
        const url = `https://api.github.com/repos/${PRIVATE_REPO}/contents/${WIKI_PATH}/${name}`;
        const res = await fetch(url, {
          headers: {
            Authorization: `Bearer ${GH_TOKEN}`,
            Accept: "application/vnd.github.raw+json",
            "X-GitHub-Api-Version": "2022-11-28",
            "Cache-Control": "no-cache",
          },
          cache: "no-store" as RequestCache,
        });
        if (!res.ok) return `[Wiki file not found: ${name} (${res.status})]`;
        const text = await res.text();
        wikiCache.set(name, { text, fetchedAt: Date.now() });
        return text;
      } catch (err: any) {
        return `[GitHub fetch error: ${err.message}]`;
      }
    }
Behavior4/5

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

With no annotations provided, the description explains the non-destructive search behavior and return format. It does not contradict any annotations (none given) and adds useful behavioral detail beyond the schema.

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

Conciseness5/5

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

Two concise sentences provide the essential information: what the tool does and what it returns. No unnecessary words, and the key details are front-loaded.

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

Completeness5/5

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

For a search tool with simple parameters and no output schema, the description sufficiently covers the return format and usage context. It addresses the agent's need to understand the tool's role among siblings.

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

Parameters4/5

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

Schema coverage is 100%, so the baseline is 3. The description adds value by noting the case-insensitive search and the default max_results (implied), and mentions the context lines included in results, which enriches understanding of the query parameter.

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

Purpose5/5

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

The description clearly states it performs full-text search across wiki .md files and specifies the return format (file name, matching line, 2 lines of context). This distinguishes it from sibling tools like get_component (returns a specific component) or get_full_wiki_file (returns entire file).

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

Usage Guidelines4/5

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

The description advises using this tool to find documentation for specific classes, rules, or patterns. It does not explicitly state when not to use it or mention alternatives, but the context is clear enough for an agent to decide.

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/Anguraj-zoho/elegant-mcp'

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