← Discover MCPs and Agents
M
MCPAPIs & IntegrationsGitHub

MCP-Server-in-.NET-for-API-Performance-Analysis

Links

README

From the repo.

Performance Lab — ASP.NET Core Performance MCP Server

An educational demo project showing how to build an MCP (Model Context Protocol) server that uses AI to diagnose .NET API performance problems in real time.

What it does

You connect GitHub Copilot (or Claude, or any MCP-compatible client) to this project, and then ask it in natural language to:

  • Run load tests against any HTTP endpoint
  • Compare two endpoints side by side
  • Detect ThreadPool starvation, GC pressure, or high error rates
  • Suggest concrete .NET fixes based on the data
  • Generate markdown performance reports

The project includes a sample API with intentionally broken endpoints so you can see all the problems in action.

Projects

ProjectPortDescription
PerformanceLab.Api5100Sample ASP.NET Core API with educational (intentionally flawed) endpoints
PerformanceLab.McpServer5200MCP server + REST API — the brain
PerformanceLab.Dashboard5300Blazor Server dashboard for visualising results
PerformanceLab.SharedShared models (no external dependencies)
PerformanceLab.TestsxUnit tests for core logic

Quick start

Prerequisites

  • .NET 10 SDK
  • GitHub Copilot with MCP support, or Claude Desktop

1. Clone and build

git clone <repo-url>
cd PerformanceLab
dotnet build

2. Start all three services

Open three terminals:

# Terminal 1 — Sample API
dotnet run --project src/PerformanceLab.Api

# Terminal 2 — MCP Server
dotnet run --project src/PerformanceLab.McpServer

# Terminal 3 — Dashboard
dotnet run --project src/PerformanceLab.Dashboard

3. Connect your AI client

GitHub Copilot (VS Code)

Add this to your workspace .vscode/mcp.json (or user-level settings):

{
  "servers": {
    "performance-lab": {
      "type": "http",
      "url": "http://localhost:5200/mcp"
    }
  }
}

Reload the window. You should see "performance-lab" in the Copilot MCP server list.

Claude Desktop

Add to claude_desktop_config.json:

{
  "mcpServers": {
    "performance-lab": {
      "url": "http://localhost:5200/mcp"
    }
  }
}

4. Run your first test

In GitHub Copilot chat (Agent mode):

Run a load test against http://localhost:5100/fast for 10 seconds with 20 users

Then compare the slow endpoint with the fast one:

Compare http://localhost:5100/slow-thread-sleep with http://localhost:5100/slow-task-delay

Get a diagnosis:

Analyze the results for run <ID from the output above>

Sample API Endpoints

EndpointWhat it demonstrates
GET /fastBaseline — returns immediately
GET /slow-thread-sleep?ms=500❌ Blocks a ThreadPool thread with Thread.Sleep
GET /slow-task-delay?ms=500✅ Correct async pattern with await Task.Delay
GET /memory-heavyAllocates ~1MB per request — GC pressure
GET /cpu-heavy?iterations=50000CPU-bound work (SHA256 hash loop)
GET /database-simulationN+1 anti-pattern — 5 sequential awaits (~250ms)
GET /optimized-versionFixed with Task.WhenAll (~50ms)

MCP Tools Available

ToolDescription
run_load_testRun a load test, get result ID
compare_endpointsTest two URLs and compare side by side
analyze_resultsFull diagnosis for a result ID
compare_before_afterCompare two stored result IDs
detect_slow_responsesCheck for slow latency patterns
detect_threadpool_starvationp99/p50 ratio analysis
detect_memory_pressureGC pause spike detection
generate_reportFull markdown report for one or more IDs
suggest_optimizationsPattern-based .NET fix suggestions
list_resultsList all stored test run IDs

Running Tests

dotnet test

Expected: 15 tests, all passing.

Dashboard

Open http://localhost:5300 after starting the dashboard.

The dashboard calls the McpServer REST API (/api/results) to display stored results and allows side-by-side comparison of any two test runs.

Architecture

AI Client (Copilot / Claude)
        │ MCP Protocol (HTTP SSE)
        ▼
PerformanceLab.McpServer (:5200)
  ├─ /mcp          ← MCP tools for AI clients
  ├─ /api/results  ← REST API for dashboard
  │
  ├─ LoadTestRunner    — fires concurrent HTTP requests
  ├─ ResultAnalyzer    — rule-based diagnosis
  └─ InMemoryResultStore — holds results in memory
        │ HTTP
        ▼
PerformanceLab.Api (:5100)
  └─ Sample endpoints (fast, slow, memory-heavy, etc.)

PerformanceLab.Dashboard (:5300)
  └─ Blazor Server — reads /api/results from McpServer

Example AI Prompts

Run a load test against http://localhost:5100/slow-thread-sleep for 15 seconds with 20 users

Compare http://localhost:5100/database-simulation with http://localhost:5100/optimized-version

Detect threadpool starvation for result <ID>

Do you see any GC pressure symptoms in result <ID>?

Generate a full performance report for <ID1>,<ID2>

What .NET optimizations would you suggest for threadpool issues?

Collected info

  • 12 stars
  • 6 forks
  • Language: C#
  • Source updated: 9/12/2026

Config for your environment

Replace {MCP_ENDPOINT_URL} with this MCP’s endpoint URL (from its repo or docs above). No API key — you connect directly.

Tool

OS

Config file: ~/.cursor/mcp.json

{
  "mcpServers": {
    "mcp-server": {
      "url": "{MCP_ENDPOINT_URL}"
    }
  }
}

Paste into mcpServers in the config file. Restart Cursor after saving.

If this MCP is also published on mcpchannel.ai, you can subscribe from Browse and use the gateway config there instead.