performance-impact-mcp
v1.0.0
Published
Enterprise MCP server for analyzing code performance impact using production telemetry data from Datadog, New Relic, and Honeycomb. Supports 13+ programming languages.
Maintainers
Readme
Performance Impact MCP
Enterprise-grade Model Context Protocol (MCP) server that analyzes code performance impact using real production telemetry data from observability platforms.
Overview
This MCP server solves the "I didn't know this was slow" problem by connecting your editor to production observability data (Datadog, New Relic, Honeycomb). It analyzes your code changes in real-time and warns you when you're introducing performance issues.
Key Features
- Real-time Performance Analysis: Uses live production telemetry data, not local benchmarks
- Multi-Platform Support: Integrates with Datadog, New Relic, and Honeycomb
- Intelligent Warnings: Detects when high-latency functions are called from high-traffic endpoints
- Code Annotations: Automatically annotates functions with performance metrics
- Caching: Efficient caching to minimize API calls
- Multi-Language Support: Supports 13+ programming languages including TypeScript, JavaScript, Python, Java, Go, C#, Ruby, PHP, Rust, Swift, Kotlin, C/C++, and more
- AST-Based Analysis: Deep code analysis using language-specific parsers
Architecture
┌─────────────────┐
│ MCP Server │
└────────┬────────┘
│
┌────┴────┐
│ │
┌───▼───┐ ┌───▼────────┐
│ AST │ │Performance│
│Parser │ │ Analyzer │
└───┬───┘ └───┬───────┘
│ │
┌───▼─────────▼───┐
│ Observability │
│ Adapters │
├─────────────────┤
│ • Datadog │
│ • New Relic │
│ • Honeycomb │
└─────────────────┘Installation
Clone or download this repository
Install dependencies
npm install- Configure environment variables
cp .env.example .envEdit .env and add your observability platform credentials (at least one required):
# Datadog
DATADOG_API_KEY=your_api_key
DATADOG_APP_KEY=your_app_key
DATADOG_SITE=datadoghq.com
# New Relic
NEW_RELIC_API_KEY=your_api_key
NEW_RELIC_ACCOUNT_ID=your_account_id
NEW_RELIC_REGION=us
# Honeycomb
HONEYCOMB_API_KEY=your_api_key
HONEYCOMB_DATASET=your_dataset- Build the project
npm run buildConfiguration
Environment Variables
| Variable | Description | Default |
|----------|-------------|---------|
| DATADOG_API_KEY | Datadog API key | - |
| DATADOG_APP_KEY | Datadog Application key | - |
| DATADOG_SITE | Datadog site (e.g., datadoghq.com) | datadoghq.com |
| NEW_RELIC_API_KEY | New Relic API key | - |
| NEW_RELIC_ACCOUNT_ID | New Relic Account ID | - |
| NEW_RELIC_REGION | New Relic region (us/eu) | us |
| HONEYCOMB_API_KEY | Honeycomb API key | - |
| HONEYCOMB_DATASET | Honeycomb dataset name | - |
| CACHE_TTL_SECONDS | Cache TTL in seconds | 300 |
| PERFORMANCE_THRESHOLD_P95_MS | P95 latency threshold (ms) | 1000 |
| HIGH_TRAFFIC_THRESHOLD_PER_MIN | High traffic threshold | 1000 |
| ENABLE_WARNINGS | Enable performance warnings | true |
| LOG_LEVEL | Logging level | info |
Usage
Running the MCP Server
npm startOr for development with auto-reload:
npm run devMCP Tools
The server provides the following tools:
1. analyze_performance_impact
Analyzes code changes for performance impact.
Parameters:
code(required): Code snippet to analyzefilePath(optional): File path for contextfunctionName(optional): Name of the function being edited
Example:
{
"code": "async function handleUserSignup(details) {\n const user = await db.users.create(details);\n await sendWelcomeEmail(user.email);\n return user;\n}",
"functionName": "handleUserSignup"
}Response:
{
"warnings": [
{
"severity": "error",
"message": "High-traffic function 'handleUserSignup' (5000 calls/min) is calling high-latency function 'sendWelcomeEmail' (P95: 1800ms)",
"line": 3,
"column": 2,
"functionName": "sendWelcomeEmail",
"context": "handleUserSignup",
"recommendation": "Consider moving 'sendWelcomeEmail' to a background job/queue to avoid blocking the high-traffic endpoint."
}
],
"summary": {
"totalWarnings": 1,
"highSeverityWarnings": 1,
"potentialPerformanceImpact": "High impact: 1 critical performance issue(s) detected."
}
}2. get_function_performance
Get performance metrics for a specific function.
Parameters:
functionName(required): Function nameserviceName(optional): Service/application name
3. get_all_functions_performance
Get performance metrics for all functions in a service.
Parameters:
serviceName(required): Service/application namelimit(optional): Maximum results (default: 100)
4. annotate_code_with_performance
Annotate code with performance metrics from production.
Parameters:
code(required): Code to annotatefilePath(optional): File path for context
Example Output:
// AI Perf: P95: 45ms | Calls: 5000/min
async function handleUserSignup(details: UserDetails) {
const user = await db.users.create(details);
// AI Perf: P95: 1800ms | Calls: 200/min
await sendWelcomeEmail(user.email);
return user;
}Integration with Cursor/Claude Desktop
Add this to your Cursor MCP settings (~/.cursor/mcp.json or similar):
{
"mcpServers": {
"performance-impact": {
"command": "node",
"args": ["/path/to/performance-impact-mcp/dist/index.js"],
"env": {
"DATADOG_API_KEY": "your_key",
"DATADOG_APP_KEY": "your_key"
}
}
}
}How It Works
- Language Detection: Automatically detects programming language from file extension or code content
- Code Analysis: Uses language-specific parsers to extract function definitions and calls
- Performance Data Fetching: Queries observability platforms for real-time metrics
- Impact Detection: Compares function call patterns against performance thresholds
- Warning Generation: Creates actionable warnings when performance issues are detected
Supported Programming Languages
The MCP server supports the following programming languages:
- TypeScript (.ts, .tsx) - Full AST parsing with TypeScript-specific features
- Angular - Fully supported (.component.ts, .service.ts, .module.ts, etc.)
- React - Fully supported (.tsx, .jsx)
- Vue - Fully supported (.ts)
- JavaScript (.js, .jsx, .mjs, .cjs) - Full AST parsing with JSX support
- Python (.py, .pyi, .pyw) - Function and method extraction
- Java (.java) - Method definition and call analysis
- Go (.go) - Function parsing with Go-specific syntax
- C# (.cs, .csx) - Method and call analysis
- Ruby (.rb, .rake, .gemspec, .ru) - Method and call extraction
- PHP (.php, .phtml) - Function and method analysis
- Rust (.rs) - Function parsing with Rust-specific features
- Swift (.swift) - Method and function analysis
- Kotlin (.kt, .kts) - Function and method extraction
- C/C++ (.c, .cpp, .h, .hpp) - Function and method parsing
Language detection works automatically based on file extensions. Angular files (.component.ts, .service.ts, etc.) are automatically recognized as TypeScript. If detection fails, the parser falls back to TypeScript/JavaScript parsing.
Example Scenario
You're editing a high-traffic endpoint that processes user signups:
// AI Perf: P95: 45ms | Calls: 5k/min
async function handleUserSignup(details: UserDetails) {
const user = await db.users.create(details);
// You add this line:
await sendWelcomeEmail(user.email);
// ✨ MCP instantly warns:
// "Performance Warning: 'handleUserSignup' (P95: 45ms) is a high-traffic
// endpoint. You are adding a call to 'sendWelcomeEmail', which has a
// P95 latency of 1800ms in production. Consider moving this to a
// background job/queue."
return user;
}Platform-Specific Setup
Datadog
- Get your API key and Application key from Datadog API Settings
- Set
DATADOG_API_KEYandDATADOG_APP_KEYin.env - Optionally set
DATADOG_SITE(default:datadoghq.com)
New Relic
- Get your API key from New Relic API Keys
- Get your Account ID from the URL or account settings
- Set
NEW_RELIC_API_KEY,NEW_RELIC_ACCOUNT_ID, andNEW_RELIC_REGIONin.env
Honeycomb
- Get your API key from Honeycomb Team Settings
- Set your dataset name
- Set
HONEYCOMB_API_KEYandHONEYCOMB_DATASETin.env
Development
Project Structure
src/
├── index.ts # MCP server entry point
├── adapters/ # Observability platform adapters
│ ├── ObservabilityAdapter.ts
│ ├── DatadogAdapter.ts
│ ├── NewRelicAdapter.ts
│ └── HoneycombAdapter.ts
├── analyzer/ # Performance analysis logic
│ └── PerformanceAnalyzer.ts
├── cache/ # Caching system
│ └── PerformanceCache.ts
├── config/ # Configuration management
│ └── ConfigManager.ts
├── parser/ # AST parsing
│ └── ASTParser.ts
└── utils/ # Utilities
└── Logger.tsRunning Tests
npm testLinting
npm run lintFormatting
npm run formatTroubleshooting
No data found for functions
- Ensure your observability platform is properly configured
- Check that functions are instrumented in production
- Verify API keys have correct permissions
- Check logs for API errors
High API rate limits
- Increase
CACHE_TTL_SECONDSto cache longer - Use a single observability platform if possible
- Check your platform's rate limits
Parse errors
- Ensure code is valid for the detected language
- Check that the file extension matches the programming language
- Supported languages: TypeScript, JavaScript, Python, Java, Go, C#, Ruby, PHP, Rust, Swift, Kotlin, C/C++
- If language detection fails, the parser will attempt TypeScript/JavaScript as fallback
Contributing
Contributions welcome! Please ensure:
- Code follows TypeScript best practices
- Tests are added for new features
- Documentation is updated
License
MIT
Enterprise Features
This MCP server is designed for enterprise use with:
- Robust error handling
- Comprehensive logging
- Efficient caching
- Support for multiple observability platforms
- Production-ready code quality
