VA

vertile-ai/next-mcp-server

部署与 DevOps

本页由 AI 翻译,技术细节请以原文为准。 查看原文

99 stars 12 forks 质量 58 趋势 0MIT

vertile-ai/next-mcp-server 是从 https://github.com/vertile-ai/next-mcp-server. 导入的 MCP 服务器候选

概览

vertile-ai/next-mcp-server 是从 https://github.com/vertile-ai/next-mcp-server. 导入的 MCP 服务器候选

概述(AI 翻译)

演示

特色

  • get-routers-info

路由器分析仪扫描您的Next.js应用目录结构,提取所有API路由的信息,包括:

  • API 路径
  • HTTP 方法(GET、POST、PUT、DELETE 等)
  • 请求参数
  • 状态代码
  • 请求和响应模式

安装

或者如果你用的是pnpm:

用途

命令行

你可以直接运行MCP服务器:

Docker

对于光标的使用,请在 ~/.cursor 或 [projectDir]/.cursor 下定义一个 mcp.json

这里的url可能会根据你在项目中的.env设置而有所不同。

输出

该工具生成每条路线的详细信息:

发展

要进行测试:

要在本地运行MCP服务器:

从npm i之后的node_modules运行:

运营游乐场:

工作原理

工具:

  1. 扫描你的 Next.js 应用目录结构中的路由文件
  2. 分析每个路由文件,提取HTTP方法、路径、参数等。
  3. 从评论中提取文档
  4. 返回所有 API 路由的结构化表示

限制

  1. 由于通过路径访问文件系统目录的特性,如果通过网络托管,则无法使用
  2. 仅支持 Next。

本页由 AI 翻译,技术细节请以原文为准。

README

Next.js MCP Server

Demo

Features

  • get-routers-info

    The Router Analyzer scans your Next.js app directory structure and extracts information about all API routes, including:

    • API paths
    • HTTP methods (GET, POST, PUT, DELETE, etc.)
    • Request parameters
    • Status codes
    • Request and response schemas

Installation

npm install next-mcp-server

Or if you’re using pnpm:

pnpm add next-mcp-server

Usage

Command Line

You can run the mcp server directly:

npm run build
node dist/index.js

Docker

docker build -t mcp/next -f Dockerfile .
docker run mcp/next -d

For cursor usage, define a mcp.json under ~/.cursor or [projectDir]/.cursor

{
  "mcpServers": {
    "next.js": {
      "url": "http://localhost:4857/sse"
    }
  }
}

The url here could vary based on your .env settings within the project.

Output

The tool generates detailed information about each route:

[
  {
    "filePath": "/path/to/your/app/api/test/route.ts",
    "implementationPath": "/path/to/your/app/api/test/route.ts",
    "apiPath": "/api/test",
    "handlers": [
      {
        "method": "GET",
        "path": "/api/test",
        "functionSignature": "export async function GET(request: Request)",
        "description": "Get test data",
        "parameters": [],
        "statusCodes": [200]
      },
      {
        "method": "POST",
        "path": "/api/test",
        "functionSignature": "export async function POST(request: Request)",
        "description": "Create test data",
        "parameters": [],
        "requestBodySchema": "{ name: string }",
        "statusCodes": [201, 400]
      }
    ]
  }
]

Development

To run tests:

npm run test

To run the mcp server locally:

npm run build
node dist/index.js 

To run it from node_modules after npm i:

node node_modules/next-mcp-server/dist/index.js

To run the playground:

pnpm --filter playground dev

How It Works

The tool:

  1. Scans your Next.js app directory structure for route files
  2. Analyzes each route file to extract HTTP methods, paths, parameters, etc.
  3. Extracts documentation from comments
  4. Returns a structured representation of all your API routes

Restrictions

  1. Due to the nature of accessing filesystem directory by path, it will not work if hosted over network
  2. Only supports Next.js App router projects

License

MIT

在 GitHub 查看完整 README

安装

docker run mcp/next -d
新手?先看 mcpskill.org 教程 →