npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

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.

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

  1. Clone or download this repository

  2. Install dependencies

npm install
  1. Configure environment variables
cp .env.example .env

Edit .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
  1. Build the project
npm run build

Configuration

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 start

Or for development with auto-reload:

npm run dev

MCP Tools

The server provides the following tools:

1. analyze_performance_impact

Analyzes code changes for performance impact.

Parameters:

  • code (required): Code snippet to analyze
  • filePath (optional): File path for context
  • functionName (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 name
  • serviceName (optional): Service/application name

3. get_all_functions_performance

Get performance metrics for all functions in a service.

Parameters:

  • serviceName (required): Service/application name
  • limit (optional): Maximum results (default: 100)

4. annotate_code_with_performance

Annotate code with performance metrics from production.

Parameters:

  • code (required): Code to annotate
  • filePath (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

  1. Language Detection: Automatically detects programming language from file extension or code content
  2. Code Analysis: Uses language-specific parsers to extract function definitions and calls
  3. Performance Data Fetching: Queries observability platforms for real-time metrics
  4. Impact Detection: Compares function call patterns against performance thresholds
  5. 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

  1. Get your API key and Application key from Datadog API Settings
  2. Set DATADOG_API_KEY and DATADOG_APP_KEY in .env
  3. Optionally set DATADOG_SITE (default: datadoghq.com)

New Relic

  1. Get your API key from New Relic API Keys
  2. Get your Account ID from the URL or account settings
  3. Set NEW_RELIC_API_KEY, NEW_RELIC_ACCOUNT_ID, and NEW_RELIC_REGION in .env

Honeycomb

  1. Get your API key from Honeycomb Team Settings
  2. Set your dataset name
  3. Set HONEYCOMB_API_KEY and HONEYCOMB_DATASET in .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.ts

Running Tests

npm test

Linting

npm run lint

Formatting

npm run format

Troubleshooting

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_SECONDS to 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