Commit graph

15 commits

Author SHA1 Message Date
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
Drew Davis
085f30743e
feat: Implement alerting for Raw SQL-based dashboard tiles (#2073)
## Summary

This PR implements alerting on Raw SQL-based line/bar charts.

- This is only available for line/bar charts with this change. Number charts will be added in a future PR.
- The threshold is compared to the _last_ numeric column in each result.
- The interval parameter must be used. This is required for line charts to function, and is used for zero-fill and other functionality within the alerts task. This limitation will be removed for Number chart alerts when those are implemented.
- Start and and end date should be used, but are not required because there are some potential use-cases where they may not be desirable.

### Screenshots or video

https://github.com/user-attachments/assets/e2d0cd6c-b040-4490-89af-6a51a7380647

Logs from Check-Alerts evaluating a raw-sql alert

<img width="1241" height="908" alt="Screenshot 2026-04-09 at 3 01 14 PM" src="https://github.com/user-attachments/assets/dbed4e5f-bf27-4179-b8e0-897cc19f3d3a" />

### How to test locally or on Vercel

This must be tested locally, as alerts are not enabled in the preview environment.

<details>
<summary>Query for the "anomaly detection" example</summary>

```sql
WITH buckets AS (
  SELECT
    $__timeInterval(Timestamp) AS ts,
    count() AS bucket_count
  FROM $__sourceTable
  WHERE TimestampTime >= fromUnixTimestamp64Milli({startDateMilliseconds:Int64}) - toIntervalSecond($__interval_s * 30) -- Fetch 30 intervals back
    AND TimestampTime < fromUnixTimestamp64Milli({endDateMilliseconds:Int64})
    AND SeverityText = 'error'
  GROUP BY ts
  ORDER BY ts
  WITH FILL STEP toIntervalSecond($__interval_s)
),

anomaly_detection as (
  SELECT
    ts,
    bucket_count,
    avg(bucket_count) OVER (ORDER BY ts ROWS BETWEEN 30 PRECEDING AND 1 PRECEDING) as previous_30_avg, -- avg of previous 30 intervals
    stddevPop(bucket_count) OVER (ORDER BY ts ROWS BETWEEN 30 PRECEDING AND 1 PRECEDING) as previous_30_stddev, -- standard deviation of previous 30 intervals
    greatest(bucket_count - (previous_30_avg + 2 * previous_30_stddev), 0) as excess_over_2std -- compare bucket to avg + 2 stddev. clamp at 0.
  FROM buckets
)

SELECT ts, excess_over_2std 
FROM anomaly_detection
WHERE ts >= fromUnixTimestamp64Milli({startDateMilliseconds:Int64}) AND ts < fromUnixTimestamp64Milli({endDateMilliseconds:Int64})
```

</details>

### References



- Linear Issue: HDX-1605
- Related PRs:
2026-04-13 17:58:22 +00:00
Brandon Pereira
e767d79e02
Clean Up Integration Test Console Output (#1566)
- Also fix issue where integration tests were making actual network requests
- this also slightly speeds up tests
- Fixes issues where there were JS errors thrown during tests due to incorrect mocks, causing confusion when adding/fixing other tests

Before (note: too much content to even see all tests)

https://github.com/user-attachments/assets/346bb57d-aa64-4a62-b666-3cf47fcc2a6c

After:

https://github.com/user-attachments/assets/f6379a93-2d1d-4f12-a467-02d874f98de6




Fixes HDX-3165
2026-01-07 17:38:01 +00:00
Warren
131a1c1edb
revert: api esbuild (#1280)
This PR reverts https://github.com/hyperdxio/hyperdx/pull/937

Ref: HDX-2620
2025-10-21 09:27:47 +00:00
Elizabet Oliveira
eaff49293c
Add copy-to-clipboard buttons in RawLogTable for log line data and URLs (#1227)
Co-authored-by: Mike Shi <mike@hyperdx.io>
2025-10-10 15:50:34 +01:00
Mike Shi
b8efb4924c
chart ai assistant (#1243) 2025-10-07 14:47:10 -04:00
Drew Davis
45e8e1b62d
fix: Update tsconfigs to resolve IDE type errors (#1150) 2025-09-11 08:55:14 -04:00
Aaron Knudtson
ad6887796f
feat: bundle api for image size reduction (#937)
all-in-one image: 1.51 gb -> 1.21 gb
app image: 573 mb -> 271 mb

Ref HDX-1803
2025-06-24 15:51:34 +00:00
Tom Alexander
293a2affc8
feat: Adds auto openapi doc generation + swagger UI for API (#779)
* Adds support for auto-openapi doc generation
* Adds a swagger route for local development
* Adds a script to manually generate the openapi doc (to be used later if we publish to our site, etc...)

Ref: HDX-1661
2025-04-29 17:54:34 +00:00
github-actions[bot]
184402dccf
chore(release): bump HyperDX app/package versions (beta) (#609)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Warren <warren@Warrens-MacBook-Air.local>
2025-03-13 03:32:40 -07:00
Warren
6ee29abe02
feat: introduce common-utils package (#554)
- copy and paste the utils to a separate dir
- setup building + CD
2025-01-16 18:15:22 +00:00
Shorpo
42969f243e
chore: Add path alias to api package (#107)
small dev ex improvement:

Before: `import { ... } from '../../../fixtures';`
After: `import { ... } from '@/fixtures';`

after checking out, rebuild `api` and `task-check-alerts` containers:
```sh
docker compose -f docker-compose.dev.yml up -d --no-deps --build task-check-alerts api
```
2023-11-17 21:31:24 +00:00
Shorpo
0824ae76d2
Chart alerts: Add support for chart alerts in alerts API (#104)
Add support for chart alerts in alerts API
2023-11-16 03:59:32 +00:00
Warren
836924377e
feat: add docker prod build stages and publish prod builds (#4) 2023-09-15 21:34:14 -07:00
Warren
0826d4dd89 first commit 2023-09-12 20:08:05 -07:00