ai-backend-performance-mcp
Enables AI agents to perform read-only static analysis of Node.js backend projects, detecting database query anti-patterns, async bottlenecks, connection pooling mistakes, and dependency hygiene issues while returning structured evidence-backed findings.
README
ai-backend-performance-mcp
Static analysis MCP server for Node.js backend performance issues. AI agents can inspect a project for database query anti-patterns, async bottlenecks, connection pooling mistakes, and dependency hygiene problems — without modifying your code.
Why this project?
Backend performance issues often hide in plain sight: N+1 queries in loops, clients created per request, sequential awaits that could run in parallel, or dependencies misclassified in package.json. This MCP server exposes those patterns as structured, evidence-backed findings that AI coding assistants can reason about.
What it does
- Read-only static analysis of JavaScript/TypeScript source files
- Six focused MCP tools for common backend performance categories
- Structured findings with severity, confidence, code snippets, and recommendations
- Distinguishes confirmed evidence from potential issues
What it does not do
- Execute your application or repository code
- Modify files, install packages, or change indexes
- Replace profiling, load testing, or database
EXPLAINanalysis
Architecture
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
See docs/architecture.md for layer details.
Analyzers
| Analyzer | Detects |
|---|---|
| Database queries | N+1 patterns, unbounded finds/queries |
| MongoDB indexes | Filter/sort fields without matching createIndex |
| Async patterns | await in loops, sequential awaits, blocking sync ops |
| Connection pooling | Client/pool creation in handlers or loops |
| Dependencies | Unused deps, dev/prod misclassification, lockfile stats |
MCP Tools
| Tool | Description |
|---|---|
analyze_project |
Full scan with grouped findings and summary |
analyze_database_queries |
MongoDB/PostgreSQL query patterns |
analyze_indexes |
MongoDB index coverage heuristics |
analyze_async_patterns |
Async/await performance patterns |
analyze_connection_pooling |
Connection lifecycle anti-patterns |
analyze_dependencies |
package.json / lockfile hygiene |
Tool reference: docs/tools.md
Installation
npm install ai-backend-performance-mcp
Or run directly:
npx ai-backend-performance-mcp
MCP configuration
Add to your MCP client config (example for Cursor / Claude Desktop):
{
"mcpServers": {
"backend-performance": {
"command": "npx",
"args": ["-y", "ai-backend-performance-mcp"],
"env": {}
}
}
}
For local development:
{
"mcpServers": {
"backend-performance": {
"command": "node",
"args": ["/absolute/path/to/ai-backend-performance-mcp/dist/index.js"]
}
}
}
Usage
Invoke any tool with a projectPath pointing to a Node.js backend repository:
{
"projectPath": "/path/to/your/api"
}
Example output (truncated)
{
"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
}
}
Try the included demo project at examples/sample-node-api.
Safety
- Read-only: never writes to analyzed projects
- Path validation: prevents traversal outside
projectPath - No code execution: parses source text only; does not run repository code
- Untrusted input: treat analyzed repos as untrusted
Limitations
- Static analysis only; findings that depend on cluster state stay
potential - Dynamic
require()/ runtime-generated queries are not fully tracked - Index analysis compares in-repo
createIndexcalls only (not Atlas/ops-managed indexes) and stays silent when the repo defines none Array.find, batched$in/ANY(),_idlookups, and module-scope DB clients are not treated as issues- Sequential awaits are flagged only when they do not consume prior bindings;
Promise.allis never reported as a finding - Dependency unused detection is import-scan based
- Redis-specific rules are planned but not implemented in v0.1.0
Development
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
See docs/development.md.
Testing
npm test
Fixture projects under tests/fixtures/ pair problematic and valid code for N+1 queries, indexes, async, pooling, and dependencies so analyzers do not fire on every await, query, loop, or connection.
Roadmap
- [ ] Redis/cache analyzer
- [ ] Prisma/TypeORM-specific query rules
- [ ] ProjectContext caching
- [ ] SARIF/JSON report export
- [ ] Configurable severity thresholds
Contributing
Contributions are welcome! See CONTRIBUTING.md and CODE_OF_CONDUCT.md.
License
MIT — see LICENSE.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。