docs_read
Read the full markdown content of any doc file from installed @particle-academy packages using the package name and doc path. This provides version-matched documentation without network calls.
Instructions
Read the full markdown content of one doc file. Pass the package name and the path from docs_list.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| package | Yes | Package name, e.g. '@particle-academy/react-fancy'. | |
| path | Yes | Doc path, e.g. 'README.md' or 'docs/guides/sheets.md'. |
Implementation Reference
- src/tools.ts:102-116 (handler)The handler function for the docs_read tool. It extracts package name and path from args, calls readDoc() from scanner.ts, and returns the file content or an error if not found.
(args) => { const pkg = typeof args.package === "string" ? args.package : ""; const path = typeof args.path === "string" ? args.path : ""; if (!pkg || !path) { return errorResult("Both `package` and `path` are required."); } const content = readDoc(cache, pkg, path); if (content === null) { return errorResult( `Not found: ${pkg} :: ${path}. Call docs_list to see available paths.`, ); } return textResult(content, { package: pkg, path, bytes: content.length }); }, ); - src/tools.ts:93-100 (schema)Input schema for docs_read tool: requires 'package' (string) and 'path' (string) parameters.
inputSchema: { type: "object", properties: { package: { type: "string", description: "Package name, e.g. '@particle-academy/react-fancy'." }, path: { type: "string", description: "Doc path, e.g. 'README.md' or 'docs/guides/sheets.md'." }, }, required: ["package", "path"], }, - src/tools.ts:88-116 (registration)Tool registration for docs_read using server.registerTool() with name 'docs_read', description, input schema, and handler.
server.registerTool( { name: "docs_read", description: "Read the full markdown content of one doc file. Pass the package name and the path from docs_list.", inputSchema: { type: "object", properties: { package: { type: "string", description: "Package name, e.g. '@particle-academy/react-fancy'." }, path: { type: "string", description: "Doc path, e.g. 'README.md' or 'docs/guides/sheets.md'." }, }, required: ["package", "path"], }, }, (args) => { const pkg = typeof args.package === "string" ? args.package : ""; const path = typeof args.path === "string" ? args.path : ""; if (!pkg || !path) { return errorResult("Both `package` and `path` are required."); } const content = readDoc(cache, pkg, path); if (content === null) { return errorResult( `Not found: ${pkg} :: ${path}. Call docs_list to see available paths.`, ); } return textResult(content, { package: pkg, path, bytes: content.length }); }, ); - src/scanner.ts:215-225 (helper)The readDoc() helper function that looks up a package by name in the scan results, finds the file by path, and reads its markdown content from disk using readFileSync.
export function readDoc(scan: PackageDocs[], packageName: string, path: string): string | null { const pkg = scan.find((p) => p.name === packageName); if (!pkg) return null; const file = pkg.files.find((f) => f.path === path); if (!file) return null; try { return readFileSync(file.absolutePath, "utf8"); } catch { return null; } }