tanstack_doc
Fetch the full content of a TanStack documentation page for any library and specific path.
Instructions
Fetch the full content of a specific TanStack documentation page
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| library | Yes | Library ID (e.g. query, router, table, start, form, virtual) | |
| path | Yes | Documentation path (e.g. framework/react/overview, guide/server-functions) | |
| docsVersion | No | Docs version (default: latest) |
Implementation Reference
- src/index.ts:230-237 (handler)Tool handler for 'tanstack_doc'. Builds CLI args from library, path, and optional docsVersion, then runs the CLI and returns JSON-parsed result.
async ({ library, path, docsVersion }) => { const args = ["doc", library, path, "--json"]; if (docsVersion) args.push("--docs-version", docsVersion); const { stdout } = await runCli(args); return jsonResult(parseJsonOutput(stdout)); }, ); - src/index.ts:214-229 (schema)Schema definition for 'tanstack_doc'. Defines description and input parameters: library (string), path (string), docsVersion (optional string).
"tanstack_doc", "Fetch the full content of a specific TanStack documentation page", { library: z .string() .describe("Library ID (e.g. query, router, table, start, form, virtual)"), path: z .string() .describe( "Documentation path (e.g. framework/react/overview, guide/server-functions)", ), docsVersion: z .string() .optional() .describe("Docs version (default: latest)"), }, - src/index.ts:213-237 (registration)Registration of the 'tanstack_doc' tool on the MCP server via server.tool() with name, description, schema, and handler.
server.tool( "tanstack_doc", "Fetch the full content of a specific TanStack documentation page", { library: z .string() .describe("Library ID (e.g. query, router, table, start, form, virtual)"), path: z .string() .describe( "Documentation path (e.g. framework/react/overview, guide/server-functions)", ), docsVersion: z .string() .optional() .describe("Docs version (default: latest)"), }, async ({ library, path, docsVersion }) => { const args = ["doc", library, path, "--json"]; if (docsVersion) args.push("--docs-version", docsVersion); const { stdout } = await runCli(args); return jsonResult(parseJsonOutput(stdout)); }, ); - src/index.ts:34-41 (helper)Helper function parseJsonOutput - parses CLI stdout by finding first JSON object/array start and parsing it.
function parseJsonOutput(stdout: string): unknown { // The CLI may print warnings before the JSON blob – find the first { or [ const jsonStart = stdout.search(/[\[{]/); if (jsonStart === -1) { throw new Error(`CLI returned non-JSON output:\n${stdout}`); } return JSON.parse(stdout.slice(jsonStart)); } - src/index.ts:47-49 (helper)Helper function jsonResult - wraps data as a text content result with JSON stringification.
function jsonResult(data: unknown) { return textResult(JSON.stringify(data, null, 2)); }