Skip to main content
Glama
nanameru

Next.js Docs MCP

by nanameru

get_all_docs

Retrieve Next.js documentation URLs to help AI agents fetch relevant content for answering questions about Next.js features, errors, and development topics.

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

TableJSON Schema
NameRequiredDescriptionDefault
contextNoOptional user query, error message, or code snippet used by the client to decide invocation
filePathNoOptional current file path used by the client to decide invocation
statusYesCosmetic flag to ensure clients log arguments/header (e.g., 'executing')executing

Implementation Reference

  • The primary handler function for the 'get_all_docs' tool. It processes input arguments, constructs a header with context/file/status info, aggregates all documentation entries from NEXTJS_DOCS_DATABASE, formats them into a numbered list with categories, and returns a structured text response optimized for Claude AI consumption.
    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-250 (registration)
    Tool registration in the ListToolsRequestSchema handler, defining the name, description, and input schema for 'get_all_docs'.
      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"],
          },
        },
      ],
    };
  • Input schema definition for the 'get_all_docs' tool, specifying optional context, filePath, and required status parameters.
    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-260 (registration)
    Dispatch case in the CallToolRequestSchema handler that routes calls to 'get_all_docs' to the getAllDocsForClaude method.
    switch (name) {
      case "get_all_docs":
        return await this.getAllDocsForClaude(args as { context?: string; filePath?: string });
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden. It discloses behavioral traits such as returning a list of URLs, requiring agents to fetch content post-call with specific constraints (10s timeout, concurrency limit of 3, follow redirects), and handling failures by trying next URLs. However, it doesn't mention rate limits, authentication needs, or potential errors from the tool itself, leaving some gaps.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is well-structured with clear sections for auto-trigger guidance, post-call instructions, and tool purpose. It's appropriately sized for its complexity, but some sentences could be more concise (e.g., the post-call instructions are detailed but slightly verbose). Overall, it's front-loaded with purpose and efficient in conveying necessary information.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (no annotations, no output schema, but rich behavioral guidance), the description is complete. It covers purpose, usage guidelines, behavioral traits, and post-processing steps thoroughly. The absence of an output schema is compensated by explaining the return type (list of URLs) and how to handle it, making it sufficient for an AI agent to use effectively.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents all three parameters. The description adds context by explaining how 'context' and 'filePath' are used by clients for invocation decisions, but it doesn't provide additional syntax or format details beyond what the schema states. With high schema coverage, a baseline score of 3 is appropriate as the description adds minimal extra value.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: 'Provide all Next.js documentation URLs for AI agents.' It specifies the exact resource (Next.js documentation URLs) and the action (provide all of them). The description distinguishes this tool by emphasizing it returns a 'comprehensive list' for agents to fetch from, which is specific and actionable.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides explicit guidance on when to use this tool, including auto-trigger conditions based on user queries, error keywords, and file paths. It also includes post-call instructions for how agents should handle the output, specifying actions like fetching top URLs and fallback strategies. This covers both invocation timing and post-processing steps comprehensively.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/nanameru/Next.js-Docs-MCP'

If you have feedback or need assistance with the MCP directory API, please join our Discord server