Skip to content

Commit ba2cb67

Browse files
authored
better description for nextjs_runtime (#21)
1 parent c60d998 commit ba2cb67

File tree

1 file changed

+31
-23
lines changed

1 file changed

+31
-23
lines changed

src/mcp-tools/nextjs-runtime.ts

Lines changed: 31 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -47,23 +47,31 @@ const nextjsRuntimeInputSchema = z.object({
4747
})
4848

4949
export const nextjsRuntimeTool = tool({
50-
description: `Discover, inspect, and interact with running Next.js development servers and their MCP endpoints.
51-
52-
USE THIS TOOL WHEN:
53-
- User asks about running Next.js servers (e.g., "how many Next.js apps are running?", "show me running servers", "list Next.js apps")
54-
- User wants to see what servers/apps are active
55-
- User wants to interact with Next.js runtime capabilities
56-
- User needs to call Next.js internal tools or APIs
57-
- User asks about server ports, PIDs, or processes
58-
59-
COMMON QUERY EXAMPLES:
60-
✓ "How many Next.js apps with MCP are running?"
61-
✓ "Show me all running Next.js servers"
62-
✓ "List running Next.js development servers"
63-
✓ "What Next.js apps are currently active?"
64-
✓ "Are there any Next.js servers running?"
65-
✓ "What tools are available in the Next.js runtime?"
66-
✓ "Clear the Next.js cache"
50+
description: `Interact with a running Next.js development server's MCP endpoint to query runtime information, diagnostics, and internals.
51+
52+
WHEN TO USE THIS TOOL - Use proactively in these scenarios:
53+
54+
1. **Before implementing ANY changes to the app**: When asked to add, modify, or fix anything in the application:
55+
- "Add a loading state" → Check current component structure and routes first
56+
- "Fix the navigation" → Inspect existing routes and components
57+
- "Update the API endpoint" → Query current routes and data flows
58+
- "Add error handling" → Check runtime errors and component hierarchy
59+
- "Refactor the auth logic" → Inspect current auth implementation and routes
60+
- "Optimize performance" → Check runtime diagnostics and component tree
61+
Use this to understand where changes should be made and what currently exists.
62+
63+
2. **For diagnostic and investigation questions**:
64+
- "What's happening?" / "What's going on?" / "Why isn't this working?"
65+
- "Check the errors" / "See what's wrong"
66+
- "What routes are available?" / "Show me the routes"
67+
- "Clear the cache" / "Reset everything"
68+
- Questions about build status, compilation errors, or runtime diagnostics
69+
70+
3. **For agentic codebase search**: Use this as FIRST CHOICE for searching the currently running app. If not found, fallback to static codebase search tools.
71+
72+
KEY PRINCIPLE: If the request involves the running Next.js application (whether to investigate OR modify it), query the runtime FIRST to understand current state before proceeding.
73+
74+
Start by calling action='list_tools' to discover what runtime information is available, then use those tools to gather context.
6775
6876
REQUIREMENTS:
6977
- Next.js 16 or later (MCP support was added in v16)
@@ -73,13 +81,13 @@ Next.js exposes an MCP (Model Context Protocol) endpoint at /_next/mcp when star
7381
- experimental.mcpServer: true in next.config.js, OR
7482
- __NEXT_EXPERIMENTAL_MCP_SERVER=true environment variable
7583
76-
CAPABILITIES:
77-
1. Discover running Next.js dev servers and their ports (action='discover_servers')
78-
2. List available MCP tools/functions exposed by the Next.js runtime (action='list_tools')
79-
3. Call those tools to interact with Next.js internals (action='call_tool')
84+
This tool allows you to:
85+
1. Discover running Next.js dev servers and their ports
86+
2. List available MCP tools/functions exposed by the Next.js runtime
87+
3. Call those tools to interact with Next.js internals (e.g., get route info, clear cache, runtime diagnostics, etc.)
8088
81-
TYPICAL WORKFLOW:
82-
1. Use action='discover_servers' to find running Next.js servers
89+
Typical workflow:
90+
1. Use action='discover_servers' to find running Next.js servers (optional - auto-discovery will be attempted)
8391
2. Use action='list_tools' with the discovered port to see available tools and their input schemas
8492
3. Use action='call_tool' with port, toolName, and args (as an object, only if required) to invoke a specific tool
8593

0 commit comments

Comments
 (0)