AgentSkillsCN

nextjs-devtools

通过 MCP 实现 Next.js 开发工具链。适用于检查路由、组件、构建信息,以及调试 Next.js 应用时使用。但不适用于通用 React 项目,或非 Next.js 项目的开发。

SKILL.md
--- frontmatter
name: nextjs-devtools
description: |
  Next.js development tooling via MCP. Inspect routes, components, build info, and debug Next.js apps.
  Use when working on Next.js applications, debugging routing, or inspecting app structure.
  NOT for general React or non-Next.js projects.

Next.js DevTools

Inspect and debug Next.js applications via MCP server.

Quick Start

bash
# Start server (spawns on-demand)
bash scripts/start-server.sh

# Or use directly via mcp-client
python3 scripts/mcp-client.py call \
  -s "npx next-devtools-mcp@latest" \
  -t list-routes

Available Tools

ToolDescription
list-routesGet all app routes
get-route-infoDetails for specific route
list-componentsReact components in app
get-build-infoBuild configuration
get-confignext.config.js settings

Workflow Patterns

Pattern 1: Route Inspection

bash
# List all routes
python3 scripts/mcp-client.py call \
  -s "npx next-devtools-mcp@latest" \
  -t list-routes

# Get specific route details
python3 scripts/mcp-client.py call \
  -s "npx next-devtools-mcp@latest" \
  -t get-route-info \
  -p '{"route": "/api/auth"}'

Pattern 2: Debug Build Issues

bash
# Check build config
python3 scripts/mcp-client.py call \
  -s "npx next-devtools-mcp@latest" \
  -t get-build-info

# Check next.config.js
python3 scripts/mcp-client.py call \
  -s "npx next-devtools-mcp@latest" \
  -t get-config

Pattern 3: Component Discovery

bash
python3 scripts/mcp-client.py call \
  -s "npx next-devtools-mcp@latest" \
  -t list-components

Scripts

start-server.sh

For persistent server (multiple calls):

bash
bash scripts/start-server.sh
# Server runs on default port
# Use mcp-client.py with -u flag instead of -s

On-Demand (Recommended)

For single calls, use -s flag which spawns server per-call:

bash
python3 scripts/mcp-client.py call \
  -s "npx next-devtools-mcp@latest" \
  -t <tool-name>

Troubleshooting

IssueSolution
Server not startingCheck npx next-devtools-mcp@latest works manually
No routes foundEnsure running from Next.js project root
Build info emptyRun next build first