get_all_docs
Retrieve all relevant Next.js documentation URLs to assist with queries or error resolution. Use the tool when users mention Next.js-related topics or errors, or when app file paths suggest Next.js usage. Fetch and analyze top URLs to provide accurate, context-specific answers.
Instructions
Provide all Next.js documentation URLs for AI agents.
Auto-trigger guidance (for clients):
Run when the user asks about 'Next.js', 'Nextjs', 'Next', or mentions topics like 'App Router', 'Pages Router', 'Route Handlers', 'data fetching', 'deployment', 'turbopack', 'Vercel'.
Run when the user reports errors containing keywords like 'Next.js error', 'build error', 'routing error', 'hydration error', 'module not found', 'next.config.js', 'middleware', 'Image', 'Link', 'Route Handler'.
Run when an active file path suggests a Next.js app, e.g. 'next.config.js', 'app/', 'pages/', 'middleware.ts/js', or imports starting with 'next/'.
Post-call agent instructions (MUST DO):
After receiving the list, FETCH the content of the top relevant URLs (at least the first 3–5) to ground answers in the actual docs.
Use standard HTTP GET with a 10s timeout, follow redirects, and limit concurrency to 3 to be polite.
Prefer pages whose title/URL matches the user's query or error message; summarize only after fetching.
If fetching fails, try the next candidate URL and report which ones were fetched. This tool returns a comprehensive list so the agent can pick and fetch the most relevant docs.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| context | No | Optional user query, error message, or code snippet used by the client to decide invocation | |
| filePath | No | Optional current file path used by the client to decide invocation | |
| status | Yes | Cosmetic flag to ensure clients log arguments/header (e.g., 'executing') | executing |
Input Schema (JSON Schema)
Implementation Reference
- src/index.ts:277-323 (handler)The core handler function that executes the tool logic: constructs a header from args, collects all docs from NEXTJS_DOCS_DATABASE, formats them numbered with category/url/desc, and returns as text content.private async getAllDocsForClaude(args?: { context?: string; filePath?: string; status?: string }) { const header: string[] = []; header.push("✅ Next.js Docs MCP executed successfully."); if (args?.context) { header.push(`Context: ${args.context}`); } if (args?.filePath) { header.push(`Active file: ${args.filePath}`); } if (args?.status) { header.push(`Status: ${args.status}`); } const allDocs: Array<{title: string, url: string, description: string, category: string}> = []; // データベースから全ドキュメントを取得 Object.entries(NEXTJS_DOCS_DATABASE).forEach(([category, docs]) => { docs.forEach((doc: any) => { allDocs.push({ title: doc.title, url: doc.url, description: doc.description, category: category }); }); }); // Claudeが理解しやすい形式で出力 const formattedDocs = allDocs.map((doc, index) => `${index + 1}. **${doc.title}**\n 📁 Category: ${doc.category}\n 🔗 ${doc.url}\n 📝 ${doc.description}\n` ).join('\n'); return { content: [ { type: "text", text: header.join("\n") + `\n\n📚 **Next.js Documentation - All Available Documents**\n\n` + `Total documents: ${allDocs.length}\n\n` + `以下は全てのNext.jsドキュメントURLです。あなたのクエリに関連するドキュメントをこれらの中から選んでください:\n\n` + `${formattedDocs}\n\n` + `---\n` + `**使い方:**\n` + `これらのドキュメントの中から、あなたの質問や問題に関連するものを選んで、該当するURLを参照してください。`, }, ], }; }
- src/index.ts:225-251 (registration)Registration of the 'get_all_docs' tool in the ListToolsRequestSchema handler, including name, detailed description with usage guidance, and input schema.tools: [ { name: "get_all_docs", description: "Provide all Next.js documentation URLs for AI agents.\n\nAuto-trigger guidance (for clients):\n- Run when the user asks about 'Next.js', 'Nextjs', 'Next', or mentions topics like 'App Router', 'Pages Router', 'Route Handlers', 'data fetching', 'deployment', 'turbopack', 'Vercel'.\n- Run when the user reports errors containing keywords like 'Next.js error', 'build error', 'routing error', 'hydration error', 'module not found', 'next.config.js', 'middleware', 'Image', 'Link', 'Route Handler'.\n- Run when an active file path suggests a Next.js app, e.g. 'next.config.js', 'app/**', 'pages/**', 'middleware.ts/js', or imports starting with 'next/'.\n\nPost-call agent instructions (MUST DO):\n- After receiving the list, FETCH the content of the top relevant URLs (at least the first 3–5) to ground answers in the actual docs.\n- Use standard HTTP GET with a 10s timeout, follow redirects, and limit concurrency to 3 to be polite.\n- Prefer pages whose title/URL matches the user's query or error message; summarize only after fetching.\n- If fetching fails, try the next candidate URL and report which ones were fetched.\nThis tool returns a comprehensive list so the agent can pick and fetch the most relevant docs.", inputSchema: { type: "object", properties: { context: { type: "string", description: "Optional user query, error message, or code snippet used by the client to decide invocation", }, filePath: { type: "string", description: "Optional current file path used by the client to decide invocation", }, status: { type: "string", description: "Cosmetic flag to ensure clients log arguments/header (e.g., 'executing')", default: "executing", }, }, required: ["status"], }, }, ], }; });
- src/index.ts:229-247 (schema)Input schema defining optional 'context' and 'filePath' strings, and required 'status' string for the tool.inputSchema: { type: "object", properties: { context: { type: "string", description: "Optional user query, error message, or code snippet used by the client to decide invocation", }, filePath: { type: "string", description: "Optional current file path used by the client to decide invocation", }, status: { type: "string", description: "Cosmetic flag to ensure clients log arguments/header (e.g., 'executing')", default: "executing", }, }, required: ["status"], },
- src/index.ts:258-267 (helper)Dispatcher in the CallToolRequestSchema handler that routes 'get_all_docs' calls to the getAllDocsForClaude method.switch (name) { case "get_all_docs": return await this.getAllDocsForClaude(args as { context?: string; filePath?: string }); default: throw new McpError( ErrorCode.MethodNotFound, `Unknown tool: ${name}` ); }