Read a doc
read_docFetch the complete text of a documentation entry, SDK README, or recipe by providing its stable ID returned by search or list tools.
Instructions
Fetch the full content of a doc, SDK README, recipe, or other entry by id (as returned by search_docs or list_docs).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | Stable id returned by search/list, e.g. `docs/STRUCTURE`, `sdks/typescript`, `recipes/livekit-realtime-agent`. |
Implementation Reference
- src/server.ts:132-137 (handler)The handler function for the 'read_doc' tool. It takes an 'id' parameter, looks up the entry via getEntry(), and returns the full document body with a header containing title, section, id, and path.
async ({ id }) => { const entry = await getEntry(id); if (!entry) return textResponse(`No document with id "${id}".`); const header = `# ${entry.title}\n\n_Section: ${entry.section} • id: ${entry.id} • path: ${entry.relPath}_\n\n---\n\n`; return textResponse(header + entry.body); }, - src/server.ts:117-138 (registration)Registration of the 'read_doc' tool using server.registerTool() with its title, description, and inputSchema (requiring the 'id' string).
server.registerTool( "read_doc", { title: "Read a doc", description: "Fetch the full content of a doc, SDK README, recipe, or other entry by `id` (as returned by `search_docs` or `list_docs`).", inputSchema: { id: z .string() .min(1) .describe( "Stable id returned by search/list, e.g. `docs/STRUCTURE`, `sdks/typescript`, `recipes/livekit-realtime-agent`.", ), }, }, async ({ id }) => { const entry = await getEntry(id); if (!entry) return textResponse(`No document with id "${id}".`); const header = `# ${entry.title}\n\n_Section: ${entry.section} • id: ${entry.id} • path: ${entry.relPath}_\n\n---\n\n`; return textResponse(header + entry.body); }, ); - src/server.ts:123-131 (schema)Input schema definition for 'read_doc': a single required string parameter 'id' which is the stable id returned by search/list tools.
inputSchema: { id: z .string() .min(1) .describe( "Stable id returned by search/list, e.g. `docs/STRUCTURE`, `sdks/typescript`, `recipes/livekit-realtime-agent`.", ), }, }, - src/lib/content.ts:139-143 (helper)The getEntry() helper function that is called by the read_doc handler to look up a ContentEntry by its id slug (normalized via makeId).
export async function getEntry(id: string): Promise<ContentEntry | undefined> { const all = await loadContent(); const norm = makeId(id); return all.find((e) => e.id === norm); } - src/lib/content.ts:97-100 (helper)The makeId() helper used within getEntry() to normalize paths by stripping file extensions and normalizing slashes.
function makeId(relPath: string): string { // strip extension; normalise slashes return relPath.replace(/\\/g, "/").replace(/\.(md|mdx|json|yaml|yml)$/i, ""); }