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
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | Search term (case-insensitive) | |
| max_results | No | Max results to return (default 20) |
Implementation Reference
- api/mcp.ts:626-644 (handler)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}"` }] }; }); - api/mcp.ts:626-626 (schema)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 }) => { - api/mcp.ts:188-196 (helper)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", ]; - api/mcp.ts:14-41 (helper)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}]`; } }