get_full_wiki_file
Fetch the full content of a wiki markdown file, useful when partial retrieval tools like get_component are insufficient—for example, to read CSS details for a specific design variant.
Instructions
Returns the COMPLETE content of a wiki .md file. Use only when get_component / get_recipe aren't enough (e.g. reading CSS section for a specific variant). Prefer get_component for HTML snippets.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| filename | Yes | Wiki filename without path (e.g. 'drawer.md', 'form_input.md') |
Implementation Reference
- api/mcp.ts:654-657 (registration)Registration of the 'get_full_wiki_file' tool using server.tool(). Defines a 'filename' string parameter and calls readWikiFile() to fetch the full .md file content.
/* 11. get_full_wiki_file */ server.tool("get_full_wiki_file", "Returns the COMPLETE content of a wiki .md file. Use only when get_component isn't enough (e.g. you need CSS details or variant rules). Do NOT read wiki files from the local filesystem — this tool fetches them from the server.", { filename: z.string().describe("Wiki filename (e.g. 'drawer.md', 'form_input.md', 'header.md')") }, async ({ filename }) => { return { content: [{ type: "text" as const, text: rewriteAssetPaths(await readWikiFile(filename)) }] }; }); - api/mcp.ts:14-41 (helper)The readWikiFile() helper function that 'get_full_wiki_file' delegates to. Fetches wiki .md files from GitHub API with 5-minute TTL caching. Also handles .md extension appending and error responses.
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}]`; } } - api/mcp.ts:44-52 (helper)The rewriteAssetPaths() helper called on the returned wiki content. It rewrites relative asset paths (./assets/, ../assets/, etc.) to full CDN URLs before returning the content to the user.
function rewriteAssetPaths(html: string): string { // Match all relative forms: ./assets/, assets/, ../assets/, ../../assets/ ... // Covers: src="...", href="...", and any data-* attribute pointing at assets/ // (e.g. data-icon, data-src, data-hover-icon — used by JS for dynamic swaps). return html .replace(/src=(["'])(?:\.\/|(?:\.\.\/)+)?assets\//g, (_m, q) => `src=${q}${CDN_BASE}/assets/`) .replace(/href=(["'])(?:\.\/|(?:\.\.\/)+)?assets\//g, (_m, q) => `href=${q}${CDN_BASE}/assets/`) .replace(/(data-[a-z-]+)=(["'])(?:\.\/|(?:\.\.\/)+)?assets\//g, (_m, attr, q) => `${attr}=${q}${CDN_BASE}/assets/`); }