hyperdx/packages/api
Brandon Pereira 9781ae6387
feat: integrate Model Context Protocol (MCP) server for dashboards & investigations (#2030)
## 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
2026-04-14 14:39:07 +00:00
..
bin [HDX-2712] Unified hyperdx entrypoint script for API and tasks (#1951) 2026-03-20 18:27:40 +00:00
docs/auto_provision feat: Set up default sources/connections with env var in server mode (#817) 2025-05-16 23:17:37 +00:00
migrations feat: support sample-weighted aggregations for sampled trace data (#1963) 2026-03-30 19:52:18 +00:00
scripts chore: Add automatic api doc generation (#1397) 2025-11-21 21:14:02 +00:00
src feat: integrate Model Context Protocol (MCP) server for dashboards & investigations (#2030) 2026-04-14 14:39:07 +00:00
.Dockerignore first commit 2023-09-12 20:08:05 -07:00
.env.development Fix dev env port resolution and improve multi-worktree support (#2025) 2026-04-01 20:53:09 +00:00
.env.e2e feat: isolate dev environment for multi-agent worktree support (#1994) 2026-03-31 18:24:24 +00:00
.env.test Enable parallel integration testing across multiple worktrees (#1917) 2026-03-16 19:42:08 +00:00
.spectral.yaml ci: Add linting for openapi specs (#1945) 2026-03-20 15:13:19 +00:00
CHANGELOG.md Release HyperDX (#2094) 2026-04-10 11:08:49 -07:00
Dockerfile ci: Replace QEMU with native ARM64 runners for release builds (#1952) 2026-03-20 23:04:49 +00:00
eslint.config.mjs chore(eslint): add @typescript-eslint/no-unsafe-type-assertion rule (#1534) 2025-12-30 16:01:11 +00:00
jest.config.js Enable parallel integration testing across multiple worktrees (#1917) 2026-03-16 19:42:08 +00:00
jest.setup.ts fix: Adjust CI logs verbosity (#1888) 2026-03-11 20:32:02 +00:00
migrate-mongo-config.ts feat: setup clickhouse migration tool + update metrics schema (add is_delta + is_monotonic fields) (#138) 2023-12-03 14:06:50 -08:00
nodemon.json Improve common-utils build performance and add support for .env.local (#1466) 2025-12-11 23:07:16 +00:00
openapi.json feat: Implement alerting for Raw SQL-based dashboard tiles (#2073) 2026-04-13 17:58:22 +00:00
package.json feat: integrate Model Context Protocol (MCP) server for dashboards & investigations (#2030) 2026-04-14 14:39:07 +00:00
tsconfig.build.json fix: Update tsconfigs to resolve IDE type errors (#1150) 2025-09-11 08:55:14 -04:00
tsconfig.json feat: integrate Model Context Protocol (MCP) server for dashboards & investigations (#2030) 2026-04-14 14:39:07 +00:00