tanstack_search_docs
Search TanStack documentation using a query string. Retrieve matching pages with titles, URLs, and breadcrumbs. Filter results by library or framework.
Instructions
Search across TanStack documentation for a query string. Returns matching pages with titles, URLs, and breadcrumbs.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | Search query (e.g. 'server functions', 'loaders', 'mutations') | |
| library | No | Filter to a specific library (e.g. start, router, query) | |
| framework | No | Filter to a specific framework (e.g. react, vue, solid) | |
| limit | No | Max results to return (default 10, max 50) |
Implementation Reference
- src/index.ts:239-269 (registration)Registration of the tanstack_search_docs tool via server.tool() with name, description, Zod schema, and handler function.
// 6. tanstack_search_docs server.tool( "tanstack_search_docs", "Search across TanStack documentation for a query string. Returns matching pages with titles, URLs, and breadcrumbs.", { query: z.string().describe("Search query (e.g. 'server functions', 'loaders', 'mutations')"), library: z .string() .optional() .describe("Filter to a specific library (e.g. start, router, query)"), framework: z .string() .optional() .describe("Filter to a specific framework (e.g. react, vue, solid)"), limit: z .number() .min(1) .max(50) .optional() .describe("Max results to return (default 10, max 50)"), }, async ({ query, library, framework, limit }) => { const args = ["search-docs", query, "--json"]; if (library) args.push("--library", library); if (framework) args.push("--framework", framework); if (limit) args.push("--limit", String(limit)); const { stdout } = await runCli(args); return jsonResult(parseJsonOutput(stdout)); }, ); - src/index.ts:260-268 (handler)The async handler function for tanstack_search_docs. It builds CLI args (search-docs, query, optional --library, --framework, --limit), runs the CLI via runCli, parses JSON output, and returns it.
async ({ query, library, framework, limit }) => { const args = ["search-docs", query, "--json"]; if (library) args.push("--library", library); if (framework) args.push("--framework", framework); if (limit) args.push("--limit", String(limit)); const { stdout } = await runCli(args); return jsonResult(parseJsonOutput(stdout)); }, - src/index.ts:243-259 (schema)Zod schema for tanstack_search_docs inputs: query (required string), library (optional string), framework (optional string), limit (optional number, min 1, max 50).
{ query: z.string().describe("Search query (e.g. 'server functions', 'loaders', 'mutations')"), library: z .string() .optional() .describe("Filter to a specific library (e.g. start, router, query)"), framework: z .string() .optional() .describe("Filter to a specific framework (e.g. react, vue, solid)"), limit: z .number() .min(1) .max(50) .optional() .describe("Max results to return (default 10, max 50)"), }, - src/index.ts:18-32 (helper)runCli helper function that executes @tanstack/cli via npx with provided args, used by the tool handler to run 'search-docs' commands.
async function runCli( args: string[], timeoutMs = 60_000, ): Promise<{ stdout: string; stderr: string }> { const { stdout, stderr } = await execFileAsync( TANSTACK_CLI, [...TANSTACK_ARGS, ...args], { timeout: timeoutMs, maxBuffer: 10 * 1024 * 1024, // 10 MB env: { ...process.env, NO_COLOR: "1" }, }, ); return { stdout: stdout.trim(), stderr: stderr.trim() }; } - src/index.ts:34-41 (helper)parseJsonOutput helper used by the tool to extract and parse JSON from CLI stdout.
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)); }