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 索引 | 没有匹配 |
异步模式 | 循环中的 |
连接池 | 在处理器或循环中创建客户端/池 |
依赖 | 未使用的依赖、开发/生产错误分类、锁文件统计 |
MCP 工具
工具 | 描述 |
| 全量扫描,带分组发现和摘要 |
| MongoDB/PostgreSQL 查询模式 |
| MongoDB 索引覆盖启发式规则 |
| 异步/等待性能模式 |
| 连接生命周期反模式 |
|
|
工具参考:docs/tools.md
安装
npm install ai-backend-performance-mcp或直接运行:
npx ai-backend-performance-mcpMCP 配置
添加到你的 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测试
npm testtests/fixtures/ 下的夹具项目将有问题的和有效的代码配对,覆盖 N+1 查询、索引、异步、连接池和依赖,以便分析器不会对每个 await、查询、循环或连接都触发。
路线图
Redis/缓存分析器
Prisma/TypeORM 特定查询规则
ProjectContext 缓存
SARIF/JSON 报告导出
可配置的严重程度阈值
贡献
欢迎贡献!参见 CONTRIBUTING.md 和 CODE_OF_CONDUCT.md。
许可证
MIT — 参见 LICENSE。
Maintenance
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
- AlicenseNot gradedqualityAmaintenanceEnables 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.151GPL 3.0
- AlicenseAqualityDmaintenanceDependency security & health auditing for AI agents with no account or API key required.22MIT
- AlicenseNot gradedqualityBmaintenanceEnables 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.8MIT
- AlicenseNot gradedqualityAmaintenanceEnables AI agents to scan code for security and quality issues and receive machine-readable reports with suggested fixes and verification criteria.892MIT
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.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
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