mirror of
https://github.com/hyperdxio/hyperdx
synced 2026-04-21 13:37:15 +00:00
## Summary Adds an MCP (Model Context Protocol) server to the HyperDX API, enabling AI assistants (Claude, Cursor, OpenCode, etc.) to query observability data, manage dashboards, and explore data sources directly via standardized tool calls. Key changes: - **MCP server** (`packages/api/src/mcp/`) — Streamable HTTP transport at `/api/mcp`, authenticated via Personal API Access Key - **Tools** — `hyperdx_list_sources`, `hyperdx_query`, `hyperdx_get_dashboard`, `hyperdx_save_dashboard`, `hyperdx_delete_dashboard`, `hyperdx_query_tile` - **Dashboard prompts** — Detailed prompt templates that guide LLMs in generating valid, high-quality dashboards - **Shared logic** — Refactored dashboard validation/transformation out of the external API router into reusable utils (`packages/api/src/routers/external-api/v2/utils/dashboards.ts`) - **Documentation** — `MCP.md` with setup instructions for Claude Code, OpenCode, Cursor, MCP Inspector, and other clients - **Tests** — Unit tests for dashboard tools, query tools, tracing, and response trimming ### Screenshots https://github.com/user-attachments/assets/8c5aa582-c79e-47e0-8f75-e03feabdf8a6 ### How to test locally 1. Start the dev stack: `yarn dev` 2. Connect an MCP client (e.g. MCP Inspector): ```bash cd packages/api && yarn dev:mcp ``` Then configure the inspector: - **Transport Type:** Streamable HTTP - **URL:** `http://localhost:8080/api/mcp` - **Header:** `Authorization: Bearer <your-personal-access-key>` - Click **Connect** 3. Alternatively, connect via Claude Code or OpenCode: ```bash claude mcp add --transport http hyperdx http://localhost:8080/api/mcp \ --header "Authorization: Bearer <your-personal-access-key>" ``` 4. Try listing sources, querying data, or creating/updating a dashboard through the connected AI assistant. 5. Run unit tests: ```bash cd packages/api && yarn ci:unit ``` ### References - Linear Issue: HDX-3710
355 lines
8.4 KiB
JSON
355 lines
8.4 KiB
JSON
{
|
|
"version": "0.1.0",
|
|
"name": ".NET Runtime Metrics",
|
|
"description": "Garbage collection, heap fragmentation, exception, thread pool, and CPU metrics for .NET v9+ applications with the OpenTelemetry.Instrumentation.Runtime package",
|
|
"tags": ["OTel Runtime Metrics"],
|
|
"tiles": [
|
|
{
|
|
"id": "6d4b7e",
|
|
"x": 0,
|
|
"y": 0,
|
|
"w": 6,
|
|
"h": 3,
|
|
"config": {
|
|
"name": "GC Heap Size",
|
|
"source": "Metrics",
|
|
"displayType": "number",
|
|
"granularity": "auto",
|
|
"alignDateRangeToGranularity": true,
|
|
"select": [
|
|
{
|
|
"aggFn": "sum",
|
|
"valueExpression": "",
|
|
"metricName": "dotnet.gc.last_collection.heap.size",
|
|
"metricType": "sum"
|
|
}
|
|
],
|
|
"where": "",
|
|
"whereLanguage": "sql",
|
|
"numberFormat": {
|
|
"output": "byte",
|
|
"mantissa": 1
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"id": "07f54d",
|
|
"x": 6,
|
|
"y": 0,
|
|
"w": 6,
|
|
"h": 3,
|
|
"config": {
|
|
"name": "Exceptions",
|
|
"source": "Metrics",
|
|
"displayType": "number",
|
|
"granularity": "auto",
|
|
"alignDateRangeToGranularity": true,
|
|
"select": [
|
|
{
|
|
"aggFn": "sum",
|
|
"valueExpression": "",
|
|
"metricName": "dotnet.exceptions",
|
|
"metricType": "sum"
|
|
}
|
|
],
|
|
"where": "",
|
|
"whereLanguage": "sql",
|
|
"numberFormat": {
|
|
"output": "number",
|
|
"mantissa": 0,
|
|
"thousandSeparated": true
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"id": "c9bc67",
|
|
"x": 12,
|
|
"y": 0,
|
|
"w": 6,
|
|
"h": 3,
|
|
"config": {
|
|
"name": "GC Pause (s)",
|
|
"source": "Metrics",
|
|
"displayType": "number",
|
|
"granularity": "auto",
|
|
"alignDateRangeToGranularity": true,
|
|
"select": [
|
|
{
|
|
"aggFn": "sum",
|
|
"valueExpression": "",
|
|
"metricName": "dotnet.gc.pause.time",
|
|
"metricType": "sum"
|
|
}
|
|
],
|
|
"where": "",
|
|
"whereLanguage": "sql",
|
|
"numberFormat": {
|
|
"output": "number",
|
|
"mantissa": 3,
|
|
"thousandSeparated": true
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"id": "334016",
|
|
"x": 18,
|
|
"y": 0,
|
|
"w": 6,
|
|
"h": 3,
|
|
"config": {
|
|
"name": "ThreadPool Items",
|
|
"source": "Metrics",
|
|
"displayType": "number",
|
|
"granularity": "auto",
|
|
"alignDateRangeToGranularity": true,
|
|
"select": [
|
|
{
|
|
"aggFn": "sum",
|
|
"valueExpression": "",
|
|
"metricName": "dotnet.thread_pool.work_item.count",
|
|
"metricType": "sum"
|
|
}
|
|
],
|
|
"where": "",
|
|
"whereLanguage": "sql",
|
|
"numberFormat": {
|
|
"output": "number",
|
|
"mantissa": 0,
|
|
"thousandSeparated": true
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"id": "98e92c",
|
|
"x": 0,
|
|
"y": 3,
|
|
"w": 12,
|
|
"h": 7,
|
|
"config": {
|
|
"name": "GC Collections by Generation",
|
|
"source": "Metrics",
|
|
"displayType": "stacked_bar",
|
|
"granularity": "auto",
|
|
"alignDateRangeToGranularity": true,
|
|
"select": [
|
|
{
|
|
"aggFn": "sum",
|
|
"valueExpression": "",
|
|
"metricName": "dotnet.gc.collections",
|
|
"metricType": "sum"
|
|
}
|
|
],
|
|
"where": "",
|
|
"whereLanguage": "sql",
|
|
"groupBy": "Attributes['gc.heap.generation']"
|
|
}
|
|
},
|
|
{
|
|
"id": "f6c44a",
|
|
"x": 12,
|
|
"y": 3,
|
|
"w": 12,
|
|
"h": 7,
|
|
"config": {
|
|
"name": "GC Pause Time (s)",
|
|
"source": "Metrics",
|
|
"displayType": "line",
|
|
"granularity": "auto",
|
|
"alignDateRangeToGranularity": true,
|
|
"select": [
|
|
{
|
|
"aggFn": "sum",
|
|
"valueExpression": "",
|
|
"metricName": "dotnet.gc.pause.time",
|
|
"metricType": "sum"
|
|
}
|
|
],
|
|
"where": "",
|
|
"whereLanguage": "sql",
|
|
"numberFormat": {
|
|
"output": "number",
|
|
"mantissa": 3,
|
|
"thousandSeparated": true
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"id": "e54085",
|
|
"x": 0,
|
|
"y": 10,
|
|
"w": 12,
|
|
"h": 7,
|
|
"config": {
|
|
"name": "Last Collection Heap Size (by gen)",
|
|
"source": "Metrics",
|
|
"displayType": "line",
|
|
"granularity": "auto",
|
|
"alignDateRangeToGranularity": true,
|
|
"select": [
|
|
{
|
|
"aggFn": "avg",
|
|
"valueExpression": "",
|
|
"metricName": "dotnet.gc.last_collection.heap.size",
|
|
"metricType": "sum"
|
|
}
|
|
],
|
|
"where": "",
|
|
"whereLanguage": "sql",
|
|
"groupBy": "Attributes['gc.heap.generation']",
|
|
"numberFormat": {
|
|
"output": "byte",
|
|
"mantissa": 1
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"id": "34979f",
|
|
"x": 12,
|
|
"y": 10,
|
|
"w": 12,
|
|
"h": 7,
|
|
"config": {
|
|
"name": "Heap Fragmentation (by gen)",
|
|
"source": "Metrics",
|
|
"displayType": "line",
|
|
"granularity": "auto",
|
|
"alignDateRangeToGranularity": true,
|
|
"select": [
|
|
{
|
|
"aggFn": "avg",
|
|
"valueExpression": "",
|
|
"metricName": "dotnet.gc.last_collection.heap.fragmentation.size",
|
|
"metricType": "sum"
|
|
}
|
|
],
|
|
"where": "",
|
|
"whereLanguage": "sql",
|
|
"groupBy": "Attributes['gc.heap.generation']",
|
|
"numberFormat": {
|
|
"output": "byte",
|
|
"mantissa": 1
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"id": "6649b7",
|
|
"x": 0,
|
|
"y": 17,
|
|
"w": 12,
|
|
"h": 7,
|
|
"config": {
|
|
"name": "Exception Rate",
|
|
"source": "Metrics",
|
|
"displayType": "line",
|
|
"granularity": "auto",
|
|
"alignDateRangeToGranularity": true,
|
|
"select": [
|
|
{
|
|
"aggFn": "sum",
|
|
"valueExpression": "",
|
|
"metricName": "dotnet.exceptions",
|
|
"metricType": "sum"
|
|
}
|
|
],
|
|
"where": "",
|
|
"whereLanguage": "sql"
|
|
}
|
|
},
|
|
{
|
|
"id": "3a8add",
|
|
"x": 12,
|
|
"y": 17,
|
|
"w": 12,
|
|
"h": 7,
|
|
"config": {
|
|
"name": "Allocation Rate",
|
|
"source": "Metrics",
|
|
"displayType": "line",
|
|
"granularity": "auto",
|
|
"alignDateRangeToGranularity": true,
|
|
"select": [
|
|
{
|
|
"aggFn": "sum",
|
|
"valueExpression": "",
|
|
"metricName": "dotnet.gc.heap.total_allocated",
|
|
"metricType": "sum"
|
|
}
|
|
],
|
|
"where": "",
|
|
"whereLanguage": "sql",
|
|
"numberFormat": {
|
|
"output": "byte",
|
|
"mantissa": 1
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"id": "fdfdc8",
|
|
"x": 0,
|
|
"y": 24,
|
|
"w": 12,
|
|
"h": 7,
|
|
"config": {
|
|
"name": "CPU Cores Used",
|
|
"source": "Metrics",
|
|
"displayType": "line",
|
|
"granularity": "auto",
|
|
"alignDateRangeToGranularity": true,
|
|
"select": [
|
|
{
|
|
"aggFn": "sum",
|
|
"valueExpression": "",
|
|
"metricName": "dotnet.process.cpu.time",
|
|
"metricType": "sum"
|
|
}
|
|
],
|
|
"where": "",
|
|
"whereLanguage": "sql"
|
|
}
|
|
},
|
|
{
|
|
"id": "ebe6dc",
|
|
"x": 12,
|
|
"y": 24,
|
|
"w": 12,
|
|
"h": 7,
|
|
"config": {
|
|
"name": "ThreadPool Throughput & Lock Contention",
|
|
"source": "Metrics",
|
|
"displayType": "line",
|
|
"granularity": "auto",
|
|
"alignDateRangeToGranularity": true,
|
|
"select": [
|
|
{
|
|
"aggFn": "sum",
|
|
"valueExpression": "",
|
|
"metricName": "dotnet.thread_pool.work_item.count",
|
|
"metricType": "sum",
|
|
"alias": "work items"
|
|
},
|
|
{
|
|
"aggFn": "sum",
|
|
"valueExpression": "",
|
|
"metricName": "dotnet.monitor.lock_contentions",
|
|
"metricType": "sum",
|
|
"alias": "contentions"
|
|
}
|
|
],
|
|
"where": "",
|
|
"whereLanguage": "sql"
|
|
}
|
|
}
|
|
],
|
|
"filters": [
|
|
{
|
|
"id": "svc-filter-001",
|
|
"type": "QUERY_EXPRESSION",
|
|
"name": "ServiceName",
|
|
"expression": "ServiceName",
|
|
"source": "Metrics",
|
|
"sourceMetricType": "sum",
|
|
"where": "ResourceAttributes['telemetry.sdk.language'] = 'dotnet'",
|
|
"whereLanguage": "sql"
|
|
}
|
|
]
|
|
}
|