Skip to main content
Glama
robinafaruqia

ai-backend-performance-mcp

ai-backend-performance-mcp

用于 Node.js 后端性能问题的静态分析 MCP 服务器。AI 代理可以检查项目中的数据库查询反模式、异步瓶颈、连接池错误和依赖卫生问题——而无需修改你的代码。

为什么有这个项目?

后端性能问题往往隐藏在日常代码中:循环中的 N+1 查询、每次请求都创建客户端、本可并行却串行的 await,或 package.json 中错误分类的依赖。这个 MCP 服务器将这些模式以结构化、有证据支撑的发现暴露出来,供 AI 编码助手推理。

它能做什么

  • 对 JavaScript/TypeScript 源文件进行只读静态分析

  • 六个聚焦的 MCP 工具,覆盖常见后端性能类别

  • 结构化发现,包含严重程度、置信度、代码片段和建议

  • 区分已确认的证据与潜在问题

它不能做什么

  • 不执行你的应用或仓库代码

  • 不修改文件、安装包或更改索引

  • 不替代性能剖析、负载测试或数据库 EXPLAIN 分析

Related MCP server: DepHealth MCP

架构

flowchart TD
  Client[MCP Client / AI Agent]
  Server[MCP Server]
  Tools[MCP Tools]
  Engine[Analysis Engine]
  Analyzers[Individual Analyzers]
  Findings[Structured Findings]

  Client --> Server
  Server --> Tools
  Tools --> Engine
  Engine --> Analyzers
  Analyzers --> Findings
  Findings --> Tools
  Tools --> Server
  Server --> Client

参见 docs/architecture.md 了解各层详情。

分析器

分析器

检测内容

数据库查询

N+1 模式、无界 find/query

MongoDB 索引

没有匹配 createIndex 的过滤/排序字段

异步模式

循环中的 await、串行 await、阻塞性同步操作

连接池

在处理器或循环中创建客户端/池

依赖

未使用的依赖、开发/生产错误分类、锁文件统计

MCP 工具

工具

描述

analyze_project

全量扫描,带分组发现和摘要

analyze_database_queries

MongoDB/PostgreSQL 查询模式

analyze_indexes

MongoDB 索引覆盖启发式规则

analyze_async_patterns

异步/等待性能模式

analyze_connection_pooling

连接生命周期反模式

analyze_dependencies

package.json / 锁文件卫生

工具参考:docs/tools.md

安装

npm install ai-backend-performance-mcp

或直接运行:

npx ai-backend-performance-mcp

MCP 配置

添加到你的 MCP 客户端配置(以 Cursor / Claude Desktop 为例):

{
  "mcpServers": {
    "backend-performance": {
      "command": "npx",
      "args": ["-y", "ai-backend-performance-mcp"],
      "env": {}
    }
  }
}

用于本地开发:

{
  "mcpServers": {
    "backend-performance": {
      "command": "node",
      "args": ["/absolute/path/to/ai-backend-performance-mcp/dist/index.js"]
    }
  }
}

用法

使用指向 Node.js 后端仓库的 projectPath 调用任意工具:

{
  "projectPath": "/path/to/your/api"
}

示例输出(截断)

{
  "projectPath": "/app/examples/sample-node-api",
  "technologies": ["express", "mongodb"],
  "metadata": {
    "packageName": "sample-node-api",
    "packageVersion": "1.0.0",
    "sourceFileCount": 4
  },
  "findings": [
    {
      "category": "pooling",
      "severity": "critical",
      "title": "Connection or client created in request handler",
      "evidence": {
        "kind": "confirmed",
        "snippet": "const client = await MongoClient.connect(...)"
      },
      "confidence": 0.9,
      "recommendation": "Create a shared client/pool at module scope and reuse it."
    }
  ],
  "summary": {
    "totalFindings": 6,
    "confirmedCount": 3,
    "potentialCount": 3
  }
}

试试随附的演示项目 examples/sample-node-api

安全性

  • 只读:从不写入被分析的项目

  • 路径验证:防止越出 projectPath 的遍历

  • 不执行代码:仅解析源代码文本;不运行仓库代码

  • 不可信输入:将被分析仓库视为不可信

限制

  • 仅静态分析;依赖集群状态的发现保持为 potential

  • 动态 require() / 运行时生成的查询不会被完全跟踪

  • 索引分析仅比较仓库内的 createIndex 调用(不比较 Atlas/运维管理的索引),当仓库未定义任何索引时保持沉默

  • Array.find、批量 $in/ANY()_id 查找以及模块作用域的数据库客户端不被视为问题

  • 仅当串行 await 不消费先前绑定时才标记;Promise.all 永远不会被报告为发现

  • 依赖未使用检测基于导入扫描

  • Redis 特定规则已计划但未在 v0.1.0 中实现

开发

git clone https://github.com/robinafaruqia/ai-backend-performance-mcp.git
cd ai-backend-performance-mcp
npm install
npm run typecheck
npm run lint
npm test
npm run build

参见 docs/development.md

测试

npm test

tests/fixtures/ 下的夹具项目将有问题的有效的代码配对,覆盖 N+1 查询、索引、异步、连接池和依赖,以便分析器不会对每个 await、查询、循环或连接都触发。

路线图

  • Redis/缓存分析器

  • Prisma/TypeORM 特定查询规则

  • ProjectContext 缓存

  • SARIF/JSON 报告导出

  • 可配置的严重程度阈值

贡献

欢迎贡献!参见 CONTRIBUTING.mdCODE_OF_CONDUCT.md

许可证

MIT — 参见 LICENSE

Install Server
A
license - permissive license
A
quality
B
maintenance

Maintenance

Maintainers
Response time
Release cycle
Releases (12mo)
Commit activity

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Servers

  • A
    license
    Not graded
    quality
    A
    maintenance
    Enables AI assistants to perform sophisticated static code analysis using Joern's Code Property Graph technology. Supports multi-language analysis, security vulnerability detection, and code quality assessment through isolated Docker environments.
    151
    GPL 3.0
  • A
    license
    Not graded
    quality
    B
    maintenance
    Enables MCP-compatible clients to inspect Next.js codebases, analyze App Router and Pages Router structure, discover API routes, and audit build performance through controlled tools.
    8
    MIT

View all related MCP servers

Related MCP Connectors

  • Provide AI-powered real-time analysis and intelligence on NPM packages, including security, depend…

  • Package intelligence for AI agents across npm, PyPI, crates.io and deps.dev. No API keys.

  • Lints + auto-fixes how AI coding agents discover any new product. 24 rules, 6 tools, score 0-100.

View all MCP Connectors

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/robinafaruqia/ai-backend-performance-mcp'

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