<!-- MCP server — Heystack docs. Rendered: https://heystack.dev/docs/mcp · Index: https://heystack.dev/llms.txt -->
# MCP server

**Let your coding agent investigate and fix issues for you.** The Heystack MCP server connects ChatGPT, Claude Code, Cursor, VS Code, Codex, Gemini CLI, Claude.ai and any other MCP-capable agent to your Heystack workspace. Once connected, you can say *"users are reporting checkout errors since this morning — find out why"* and the agent will pull the relevant traces, errors, session replays and release history from Heystack, work out what changed, and propose the fix in your code.

The server is hosted and managed by Heystack — there is nothing to run, and nothing to install beyond a one-line connect command.

```
https://mcp.heystack.dev/mcp
```

## What it can do

- **Investigate** — the ranked issue list, an **issue brief** per issue (likely cause with its evidence and what would rule it out, suspect release with commit and compare links, examples, what "fixed" will mean), health overview, slow routes, session stories, crashes, AI/LLM usage and cost, and a one-call app dossier (`heystack_investigate`).
- **Close the loop** — link the commit or PR that fixes an issue (`heystack_link_fix`) and ask, after the deploy, whether it held (`heystack_verify_fix`).
- **Manage** — create apps and ingest keys, tune sampling and replay settings, set up alert rules, resolve issues and bug reports.
- **Onboard** — an agent can create the app, mint the key, wire up the SDK (via the [`heystack-setup` skill](https://heystack.dev/docs/quickstart)), then run `heystack_verify_setup` and wait until data of any kind actually arrives.
- **Team** (admins) — members, invites, roles, personal access tokens and the agent audit log.

Everything an agent does is tenant-scoped to the workspace you signed in with, audited in the console, and read-only unless you grant more.

## Connect your agent

The server speaks **Streamable HTTP** and authenticates with **OAuth 2.1** (sign in with Heystack) or a **personal access token**. Pick your client:

### ChatGPT

In ChatGPT, enable Developer mode if your workspace requires it, then open **Apps → Create** (or **ChatGPT Plugins → +**). Name the app **Heystack**, choose **OAuth**, and paste this exact server URL, including `/mcp`:

```
https://mcp.heystack.dev/mcp
```

Select **Scan Tools**, sign in with the same Heystack account you use for the console, and choose the workspace to connect. If you added Heystack before this authentication update, refresh the app's tool metadata or recreate its draft connection, then scan again. ChatGPT developer mode and custom-app controls depend on your plan and workspace policy.

### Claude Code

```bash
claude mcp add --transport http heystack https://mcp.heystack.dev/mcp
```

Then run `/mcp` inside Claude Code (or `claude mcp login heystack`) to sign in. Prefer the plugin, which bundles the server **and** the `heystack-setup` + `heystack-investigate` skills:

```
/plugin marketplace add heystack-hq/heystack-plugins
/plugin install heystack@heystack
```

The plugin connects with `?toolsets=core,manage` (investigation, apps, keys, config, alerts and app care). Team administration is opt-in: edit the plugin's `.mcp.json` URL to `?toolsets=core,manage,team` if you want an agent to manage members and tokens.

To share the connection with your whole repo, commit a project `.mcp.json`:

```json
{ "mcpServers": { "heystack": { "type": "http", "url": "https://mcp.heystack.dev/mcp" } } }
```

For a headless or CI run, use a [personal access token](#personal-access-tokens) instead of OAuth (the variable name is up to you — `HEYSTACK_TOKEN` is a good choice):

```json
{ "mcpServers": { "heystack": { "type": "http", "url": "https://mcp.heystack.dev/mcp",
    "headers": { "Authorization": "Bearer ${HEYSTACK_TOKEN}" } } } }
```

### Cursor

One click: [Add to Cursor](cursor://anysphere.cursor-deeplink/mcp/install?name=heystack&config=eyJ1cmwiOiJodHRwczovL21jcC5oZXlzdGFjay5kZXYvbWNwIn0=)

Or add to `.cursor/mcp.json` (project) / `~/.cursor/mcp.json` (global):

```json
{ "mcpServers": { "heystack": { "url": "https://mcp.heystack.dev/mcp" } } }
```

Cursor opens the sign-in flow the first time the server is used. For a token instead: `"headers": { "Authorization": "Bearer ${env:HEYSTACK_TOKEN}" }`.

### VS Code / GitHub Copilot

One click: [Add to VS Code](vscode:mcp/install?%7B%22name%22%3A%22heystack%22%2C%22type%22%3A%22http%22%2C%22url%22%3A%22https%3A%2F%2Fmcp.heystack.dev%2Fmcp%22%7D)

Or add `.vscode/mcp.json` to your project:

```json
{
  "servers": {
    "heystack": { "type": "http", "url": "https://mcp.heystack.dev/mcp" }
  }
}
```

With a token, declare a password input so the secret never lands in the file:

```json
{
  "inputs": [ { "type": "promptString", "id": "heystack-token", "description": "Heystack personal access token", "password": true } ],
  "servers": {
    "heystack": { "type": "http", "url": "https://mcp.heystack.dev/mcp",
                  "headers": { "Authorization": "Bearer ${input:heystack-token}" } }
  }
}
```

### Claude.ai and Claude Desktop

**Settings → Connectors → Add custom connector**, name it `Heystack` and paste `https://mcp.heystack.dev/mcp`. Claude detects that the server uses OAuth and asks you to sign in. On Team/Enterprise plans an Owner adds the connector under **Organization settings → Connectors**, then each member connects.

### Codex CLI

```bash
codex mcp add heystack --url https://mcp.heystack.dev/mcp
codex mcp login heystack
```

Or in `~/.codex/config.toml`:

```toml
[mcp_servers.heystack]
url = "https://mcp.heystack.dev/mcp"
# bearer_token_env_var = "HEYSTACK_TOKEN"   # personal access token instead of OAuth
```

### Gemini CLI

```bash
gemini mcp add --transport http heystack https://mcp.heystack.dev/mcp
```

Or in `settings.json`: `"mcpServers": { "heystack": { "httpUrl": "https://mcp.heystack.dev/mcp", "oauth": { "enabled": true } } }`. Add `"headers": { "Authorization": "Bearer …" }` for a token.

### Other clients (Windsurf, Zed, …)

Any client that supports remote MCP over Streamable HTTP works. Point it at `https://mcp.heystack.dev/mcp`; if it doesn't support OAuth, send a personal access token as `Authorization: Bearer hs_pat_…`.

### The OAuth walkthrough

1. Your client discovers that the server is protected and opens **Sign in with Heystack** in your browser.
2. Sign in with the same account you use for the console.
3. **Pick the workspace** the agent should work in. A token is bound to exactly one workspace (organization); to work in another, connect again and pick it.
4. Approve the requested access. You're sent back to your client and the connection is ready — run a first command like *"list my Heystack apps"*.

Compatible clients identify themselves through a client metadata document or register automatically, so there is no client ID to paste. Access tokens are short-lived. Clients that request `offline_access` can renew their connection; otherwise you may be prompted to sign in again.

## Personal access tokens

For clients without OAuth support, for CI, or for a long-running agent, create a **personal access token** in the console under [**Settings › Organisation › Coding agents & API**](https://console.heystack.dev/settings/org/agents):

1. Click **New token**, give it a name, choose its **scopes** and how long it lives (30 / 90 / 180 / 365 days).
2. Copy the token — it is shown once and starts with `hs_pat_`.
3. Send it as `Authorization: Bearer hs_pat_…` (see the per-client snippets above).

Tokens are minted only from a signed-in console session. An agent connected over OAuth or with a token cannot mint another one: `heystack_create_token` answers `session_required` and points you back to **Settings › Organisation › Coding agents & API**.

Tokens act as you in **one organization**, can never grant more than your own role, expire on the date you chose, and can be revoked at any time from the same page (admins can see and revoke every token in the organization). Removing a member from an organization revokes their tokens. A revoked token or read key is refused on its next tool call; the MCP server forgets it at once and re-checks every token and read key at least every 5 seconds. The same tokens also work against the [REST API](https://heystack.dev/docs/api).

For a read-only, unattended agent you can send an `hs_read_` **read key** as the Bearer instead of a PAT: it connects with the core toolset's read tools only (no write/admin tools, no `heystack_explain_trace` or `heystack_query_sql`), is capped at a 7-day window and 120 requests a minute, and an app-scoped key only ever sees its own app — see [REST API → read keys](https://heystack.dev/docs/api#read-keys-hs_read_).

### Scopes

| Scope | Grants | Typical use |
|---|---|---|
| `read` | Every read: apps, telemetry, issues, replays, crashes, alerts, usage | Investigations, reports, CI checks |
| `write` | Triage state, bug status, alert rules | Agents that act on findings |
| `admin` | Apps, ingest keys, sampling/replay settings, workspace, members, invites, audit log | Onboarding automation (requires the **Admin** role) |

Feedback (`heystack_feedback`) and managing your own personal access tokens need no extra scope.

OAuth sign-ins get scopes from your role automatically: admins get `read` + `write` + `admin`, members get `read` + `write`.

## Toolsets: choose how much the agent sees

Agents work best with a focused set of tools, and some clients cap the number they will load. The server exposes **toolsets** selected with a query parameter on the URL:

| URL | What's loaded |
|---|---|
| `…/mcp` (default = `core`) | Discovery + investigation (including `heystack_start_investigation` / `heystack_update_investigation`) + the issue loop (list, brief, status, `heystack_link_fix`, `heystack_verify_fix`) + one person (`heystack_get_user`) + bug status and `verify_setup`; 30 tools |
| `…/mcp?toolsets=core,manage` | + apps, ingest keys, sampling/replay config, alert rules, notification subscriptions, deploy markers, repairs, `heystack_share_investigation`, key events, AI health, AI spend, SDK configuration, erasing a person and filing a GitHub issue (65 tools) |
| `…/mcp?toolsets=core,team` | + workspace, members, invites, personal access tokens, plan usage, audit log |
| `…/mcp?toolsets=core,advanced` | + `heystack_query_sql` (guarded read-only SQL), `heystack_schema`, `heystack_monitor_product`, `heystack_list_replays`, `heystack_feedback` and `heystack_facets` |
| `…/mcp?toolsets=all` | Everything (84 tools) |
| `…/mcp?readonly=true` | Hide every tool that writes (combine with any toolset) |

Recommendations: the **Claude Code plugin** connects with `?toolsets=core,manage`. Member and token administration (`team`) and read-only SQL (`advanced`) stay opt-in: add them to the URL only on a connection where you want an agent to administer the workspace. **Cursor** and **VS Code** work best with the default `core` set, adding `manage` only when you're onboarding. The **Toolsets** selector on the console's **Coding agents & API** page rewrites every connect snippet for you.

Calling a tool that this connection does not include answers with the reason and the exact URL that includes it, for example `https://mcp.heystack.dev/mcp?toolsets=core,manage`; reconnect with that URL (or ask the person to).

**`readonly` is a convenience, not a security boundary.** The client chooses the URL, so anything holding the credential can reconnect without `?readonly=true`. For CI and other unattended agents, make the credential the boundary: use a personal access token with only the `read` scope, or an `hs_read_` read key. Add `?readonly=true` on top to keep write tools out of the tool list.

## The investigation loop

The server ships with instructions that teach agents a repeatable loop; the [`heystack-investigate` skill](https://heystack.dev/heystack-investigate.md) and the [agent playbooks](https://heystack.dev/docs/agent-playbooks) spell it out. In short:

1. `heystack_list_apps` → pick the app (or `heystack_resolve_url` if you pasted a console link). `heystack_investigate` (optional) gives the app's top 3 open issues, each with its brief's summary and likely cause, plus how requests, error rate and p95 changed against the previous window.
2. `heystack_list_issues` → the ranked issue list (the console's Issues inbox) with each issue's `issue_key`, over the last `1h`, `24h` or `7d` (the issue list's only windows). Work one issue at a time.
3. `heystack_get_issue issue_key=… window=…` (the same window you listed it with) → the **issue brief**: the likely cause with its confidence, evidence (each item with a console link) and what would rule it out; causes already ruled out; the suspect release with commit and compare links; when it started relative to that release; the error and a stack excerpt; up to 3 example traces, sessions and replays; linked investigations and fixes; reproduction hints; and what "fixed" will mean. `limited` lists the checks that did not run (analytics paused, too much data, not shown to read keys, no data): their result is unknown, not empty. `summary` is Heystack's rule-based text and is always there; `ai_narrative`, when one was generated in the console, is a separate model-written explanation of the same evidence and is fenced as unverified. An issue that was not seen in the window is an error that says so (retry with `window=7d`), never an empty brief.
4. Try to rule the cause out: compare the onset with the release time, open one example trace (`heystack_get_trace`), and check the stated falsifier. Use `heystack_search`, `heystack_explain_trace` or `heystack_get_session_story` for evidence the brief does not hold.
5. Reproduce (a failing test first), fix, and after the commit or PR call `heystack_link_fix` (`issue_key`, `commit_sha` and/or `pr_url`, `investigation_id`). Heystack finds the release that contains the fix and watches whether the issue stops there. Only errors, failing operations and crashes are measured; a fix for any other issue (a performance issue, for example) is recorded with `outcome_measurable: false`, and its outcome is yours to check.
6. After the deploy, `heystack_verify_fix issue_key=…`: resolve only on `verified`; `watching` or `awaiting_release` means wait, `regressed` means reopen, and `expired` means the outcome is unknown. A fix is never called verified on low traffic. `release_basis` says how the fix's release was found; `assumed_next_release` means the first release after the link was assumed, not proven, to contain the fix, and the tools say so.

Fix checking and notification delivery ship switched off and are switched on per workspace as part of the operator rollout. Until then `heystack_link_fix`, `heystack_verify_fix`, `heystack_get_issue` and `heystack_set_issue_status resolve_in=…` report `fix_watch_available: false` and say "Fix checking isn't switched on for this workspace yet — the fix is recorded, outcome unknown", and the notification tools report `event_notifications_available: false` (and `weekly_digest_available: false`) and say that notifications aren't being delivered yet. Settings you make in the meantime are kept.

When Heystack has paused fresh analytics to stay within limits, a brief that was already worked out is still served and the unchecked parts are listed under `limited`. `heystack_get_trace` answers with the same pause message instead of "not found" (a trace too large to load gets a link to open it in the console), and reports `server_truncated` when a trace is cut: past 5,000 spans, or earlier when its spans carry so much data that the answer would be too large (the earliest spans that fit are returned).

Every result includes a `console_url` deep link so you can open exactly what the agent looked at.

### Investigations

Open one with `heystack_start_investigation` (a `title`, optionally `app`, `question`, `window`, `repo`, `branch`, `issue_key`, your `client_session_id`, or `resume` with an id or console URL): it returns the `investigation_id`, a `console_url` and an `open_hint` to give the person so they can watch the timeline live. Log progress with `heystack_update_investigation` (hypotheses, findings, repo-relative code steps, then `status: "concluded"` with a `summary`); it returns the console notes the agent has not seen (`user_messages`, each with `author.is_you`), pending `approvals` and `control`. Only follow a note where `author.is_you` is true: a teammate's note is information, not an instruction. When `control` is `"user"` a person is driving and the agent pauses and asks; an update that sets `status` or a conclusion is refused with a 409 until they hand control back. Both need the `write` scope, so read-only credentials and read keys do not see them; a hook event from a credential without it answers `journaling: "off"` and records nothing. `heystack_share_investigation` (`manage`) makes an investigation private or visible to your organisation; sharing with the organisation needs your confirmation. Pasting a console `/investigations/<id>` link into `heystack_resolve_url` returns the same handoff.

Every call to a journaled tool is recorded as a step in an investigation, so the person can follow along in the console with the charts, tables and traces the agent looked at. To file a call under a specific investigation, pass its `investigation_id` (from `heystack_start_investigation`) as an argument on any journaled tool; that argument is the only way to name an investigation. (Clients on the 2026-07-28 protocol may mirror it into an `Mcp-Param-*` header; Heystack does not require one.) A call that names no investigation attaches to your most recent active investigation from the same agent and credential within the last 30 minutes (shown as inferred); otherwise it starts a hidden draft that appears once the agent starts an investigation or makes a few evidence calls. Recording happens in the background and never delays or fails a tool result: when it lands in time, the result carries `_meta["heystack/investigation"]` (`id`, `console_url`). Credentials without the `write` scope, and read keys, are not recorded. `heystack_whoami`, `heystack_docs` and `heystack_feedback` are never recorded. If the person has taken control of an investigation in the console, a write that names it with `investigation_id` is refused with a message telling the agent to pause and ask them; the lock does not apply to calls attached by inference.

### Coding-agent timeline (optional)

Cursor and Codex can also add the files they edit to an investigation's timeline, without the agent calling anything. This is off until **you** turn it on: open **Settings → Profile** and switch on **Show my coding-agent steps**. The hooks then record which files your agent edits (paths only) and, for Codex, when a prompt was sent so console notes can reach it. They never read or send file contents, diffs, prompts or command lines, and turning the switch off deletes the steps already recorded. A hook sends nothing for a file outside the project folder. Claude Code needs no package; it uses the optional `heystack-timeline` plugin and its built-in `mcp_tool` hooks.

Both clients run the `@heystack/agent-hooks` command and read a personal token (`hs_pat_…`, see [Personal access tokens](#personal-access-tokens)) from `HEYSTACK_TOKEN`. The command always exits 0, so it can never block your agent, and the whole run gives up after 1.5 seconds. It only talks to `https` addresses (or `http://localhost` for local development). The examples pin version `0.1.0` so a hook never runs code you have not chosen; bump it when you upgrade.

**Join the agent's investigation.** Connect the Heystack MCP server in the same client using the **same** `hs_pat_` token as the hooks (for example `"headers": { "Authorization": "Bearer ${env:HEYSTACK_TOKEN}" }` in Cursor, or `bearer_token_env_var = "HEYSTACK_TOKEN"` in Codex). Hook steps then land in the investigation the agent started, because it is the same person, credential and client within 30 minutes. Heystack folds the names these clients use over MCP (`cursor-vscode`, `codex-mcp-client`) onto the hook names (`cursor`, `codex`); a client with any other name only joins when its MCP name already matches the hook's. With OAuth for MCP and a different token for hooks, the steps go to a separate private draft instead.

**Environment for desktop apps.** A Cursor launched from the macOS Dock does not inherit variables from your shell. Set the token where the app can see it, for example `launchctl setenv HEYSTACK_TOKEN hs_pat_…` and restart Cursor, or start Cursor from a terminal with `cursor .`.

**Cursor** (requires `@heystack/agent-hooks` (publishing pending)). In `.cursor/hooks.json`:

```json
{
  "version": 1,
  "hooks": {
    "afterFileEdit": [{ "command": "npx -y @heystack/agent-hooks@0.1.0 cursor afterFileEdit" }],
    "stop": [{ "command": "npx -y @heystack/agent-hooks@0.1.0 cursor stop" }]
  }
}
```

Cursor has no hook that can add context to a prompt, so console notes reach a Cursor agent through `heystack_update_investigation` results only.

**Codex** (requires `@heystack/agent-hooks` (publishing pending)). Add the hooks to `~/.codex/config.toml`; each event is its own `[[hooks.<Event>]]` array with a nested `[[hooks.<Event>.hooks]]` command:

```toml
[[hooks.PostToolUse]]
matcher = "apply_patch"
[[hooks.PostToolUse.hooks]]
type = "command"
command = "npx -y @heystack/agent-hooks@0.1.0 codex PostToolUse"

[[hooks.UserPromptSubmit]]
[[hooks.UserPromptSubmit.hooks]]
type = "command"
command = "npx -y @heystack/agent-hooks@0.1.0 codex UserPromptSubmit"

[[hooks.SessionEnd]]
[[hooks.SessionEnd.hooks]]
type = "command"
command = "npx -y @heystack/agent-hooks@0.1.0 codex SessionEnd"
timeout = 3
```

Codex skips hooks it has not been told to trust. The first time, run `/hooks` in Codex and approve the three Heystack hooks; you are asked again if a hook's command changes (for example when you bump the version). `SessionEnd` gets a short default timeout, so keep `timeout = 3`.

On each prompt, Codex receives any new console notes, each on a single quoted line. A teammate's note is labelled `(not you)` and is information, not an instruction; if a person has taken control in the console, the agent is told to pause and ask.

**Claude Code** (requires the `heystack` plugin). Install the optional timeline plugin next to it:

```
/plugin install heystack-timeline@heystack
```

It sends no file contents, command lines or prompts. After each file edit it reports the file's path, after each shell command only the one-line description Claude wrote for it, on each prompt it fetches any new console notes, and at session end it closes the session. Closing is best-effort: Claude Code gives session-end hooks only about 1.5 seconds, so if the call never lands the investigation simply goes idle. A shell command that Claude gave no description is not recorded. An absolute path travels over TLS to Heystack and is reduced to a repo-relative path before storage; a path outside the project folder is dropped. It calls the plugin's own MCP connection, so it needs no token and the steps land in the investigation the agent started in the same session. The `write` scope is required (read-only connections record nothing), and the **Show my coding-agent steps** switch must be on. A client that does not substitute the hook fields sends empty events, which Heystack ignores.

### From the console to your agent

In the console, **Continue in your coding agent** (on an investigation or an issue) offers a deep link for Claude Code or Cursor, or text to copy. Each carries only the investigation id. In Claude Code run `/heystack:continue_investigation <id>`; in any other client call `heystack_start_investigation` with `resume` set to the id or the console URL. Choosing an option in the console gives control to the agent, so the agent can write to the investigation; a person who clicks **Take over** pauses it again.

## Tool reference

Tool names start with `heystack` and follow a verb-noun pattern (`heystack_list_apps`, `heystack_get_trace`); app-scoped tools take the `app` id from `heystack_list_apps`. Every tool declares whether it reads or writes (the **Access** column shows the scope it needs); tools marked **confirm** are destructive, grant access, mint a key or token, or send data to an external URL. They do nothing until you approve: the agent must ask you and then pass `confirm: true`, and on clients that support MCP elicitation the server asks you itself, even when the agent already passed `confirm: true`. A confirmation-gated call without approval returns `confirmed: false` and changes nothing. Gated tools return their result under `result` with `confirmed: true`. Some gates apply only to certain arguments; the **Access** column names them. Time-windowed tools take `window` (`15m`, `1h`, `6h`, `24h`, `7d`, `30d`) or an explicit `from`/`to`; row caps are stated in each tool's description and results set `truncated: true` when hit — narrow the window or lower `limit` rather than paging (there is no cursor).

### Discovery (`core`)

| Tool | Access | What it does | Key arguments |
|---|---|---|---|
| `heystack_whoami` | read | The authenticated principal: workspace (organization), user, role, auth kind, scopes and which toolsets are active on this connection | — |
| `heystack_list_apps` | read | Apps in the workspace with framework, 24h span count, last-seen time and console link — call this first. The span count and last-seen time count traces only: an app that sends only logs, session replay or crash reports shows 0, so use `heystack_verify_setup` to see what has arrived | — |
| `heystack_get_app` | read | One app in depth: metadata, live status (15-minute connectivity, services, error rate), which signals are present (24h), replay/sampling config | `app` |

### Investigate (`core`)

| Tool | Access | What it does | Key arguments |
|---|---|---|---|
| `heystack_overview` | read | One-call health dossier: status, RED summary with top routes, anomalies vs the 7-day baseline, top exceptions and error operations, recent releases, LLM usage/cost and which signals exist. Served from a shared snapshot up to 10 minutes old (`computed_at` says when); windows round up to 1h/24h/7d, so use `heystack_metrics red_timeseries=true window=30m` to confirm a fresh deploy | `app`, `window` (default `1h`), `limit` |
| `heystack_search` | read | Search spans (`traces`) or log records (`logs`) with a plain-English `question` **or** structured filters; always echoes `filters_applied` so you can refine | `app`, `source`, `question` or filters (`q`, `service`, `status`, `route`, `severity`, `cf`, `trace`, …), `sort`, `window` (default `24h`), `limit` (max 200) |
| `heystack_aggregate` | read | Group spans or logs by 1–2 dimensions and compute metrics (count, errors, error_rate, p50/p95/p99, users, sessions), optionally bucketed into a timeseries | `app`, `source`, `group_by`, `metrics`, `bucket`, filters, `window`, `limit` |
| `heystack_get_trace` | read | Full trace by id: waterfall-ordered span tree, exceptions/span events, correlated logs, replay session link and console link | `app`, `trace_id`, `detail` (`summary`/`full`) |
| `heystack_explain_trace` | read | Root-cause summary of one trace (spans + correlated logs) from Heystack's built-in analyzer, as prose | `app`, `trace_id` |
| `heystack_list_issues` | read | The ranked issue list (the console's Issues inbox): errors, failing operations, crashes, journeys, alerts, bug reports, security, performance, usage-drop (`usage_drop`: a key event fell below its usual level) and AI-quality (`ai_regression`) issues with rank, severity, trend, impact, `issue_key`, merged members (with fingerprints), suspect release and triage state. One read of the shared snapshot; rows carry no fix state (use `heystack_verify_fix`); read keys may call it (without `assignee`) | `app?`, `status` (`open`/`resolved`/`ignored`/`all`), `source?`, `severity?`, `q?`, `assignee?` (`me`/`none`/user id), `sort?` (`rank`/`last_seen`/`first_seen`/`impact`), `window?` (`1h`/`24h`/`7d`, default `24h`), `limit` |
| `heystack_get_issue` | read | The issue brief: likely cause with confidence, evidence (with console links) and what would rule it out; ruled-out causes; suspect release with commit and compare links; onset vs release; error and stack excerpt; up to 3 example traces, sessions and replays; linked investigations and fixes; reproduction hints; what "fixed" will mean; `limited`; `summary` and `ai_narrative` as separate fields. `fix_watch_available` when fixes are linked. The suspect may carry `author_login` and `pr_url` when a GitHub deploy recorded them. An issue not seen in the window is an error naming the window (retry with `window=7d`). A cached brief costs no analytics read. Read keys get it without logs, sessions, replays or AI text | `issue_key` (or the older `app` + `kind` + `fingerprint`), `depth?` (`core`/`full`), `window?` (`1h`/`24h`/`7d`, default `24h`) |
| `heystack_list_releases` | read | Releases (`service.version`) seen in a window with requests, errors, users affected and latency percentiles, plus each version's deploy marker (`deployed_at`, `source`, `pr_url`, `commit_url`, `compare_url`); versions known only from a deploy marker are listed last with `traffic: false` | `app`, `service`, `window`, `limit` |
| `heystack_service_map` | read | Service-to-service call edges (calls, errors, p95, last seen) derived from parent/child spans — omit `app` for the whole workspace | `app?`, `service`, `window`, `limit` |
| `heystack_metrics` | read | List an app's OTel metrics; with `metric` return its exemplars (value + trace ids); with `red_timeseries` return the request/error/latency timeseries from the RED rollup | `app`, `metric?`, `red_timeseries?`, `route`, `bucket`, `window`, `limit` |
| `heystack_genai_usage` | read | LLM calls per provider/model: call count, input/output tokens, error rate, p50/p95 latency and an estimated USD cost | `app`, `window` (default `24h`), `limit` |
| `heystack_list_crashes` | read | Mobile crash groups (signature, exception type/message, count, devices, sessions, releases, first/last seen) | `app`, `window`, `limit` |
| `heystack_get_crash` | read | One crash group: stats, recent instances (device, OS, release, session/trace ids) and symbolicated stack frames when dSYMs are uploaded | `app`, `signature`, `limit` |
| `heystack_get_session_story` | read | Chronological story of one user session: replay metadata, the session's requests, errors, AI calls, safety decisions and product events, bug reports filed from it and the replay link (the session story page) — from a `session_id` or a `trace_id`. `session` is set only when a replay exists (its click and error totals are the replay's, as in `heystack_list_replays`); the story lists at most 300 moments, oldest first, and `limit` keeps the latest N plus the trace you asked about; the text says when the story is cut. At a critical analytics budget it answers `analytics_paused` | `app`, `session_id` or `trace_id`, `window`, `limit` |
| `heystack_get_user` | read | One person across an app: who they are (when the app shows names; email for organisation admins only; a read key always gets ids only), requests, errors, visits, AI use and safety flags in a window. Up to 10 visits and 10 error titles; an erased person is not found | `user`, `app?`, `window?` (`1h`/`24h`/`7d`, default `24h`) |
| `heystack_list_bug_reports` | read | User-submitted bug reports (message, email, URL, release, linked session/trace, recent errors, status) | `app`, `status` (`new`/`triaged`/`resolved`), `limit` |
| `heystack_resolve_url` | read | Paste a link from your console (a URL on another host is refused without any lookup; app home `/?app=<id>`, settings pages `/settings/app/<id>/…`, the issue and investigation lists, trace, issue `/issues/<key>?app=<id>`, crash, bug report, replay session, explore view, or any older `/apps/<id>?tab=…` link) and get what it points at plus the object's data; `/explore/traces/<id>?app=<app>` links (and the older `?tab=traces&trace=` form) return the trace, and `/explore/<dataset>` pages (traces, logs, metrics, map, workers, sql) resolve as an explore view carrying the dataset and every group-by (an older `/explore?src=logs&g1=…` link resolves to logs); `/sessions/<id>?app=<app>` links (a visit's story page) return the replay session record, and without `?app=` only the kind; `/ai/conversations/<trace id>?app=<app>` links resolve like a trace (conversation text is never returned); `/ai/safety/decisions/<id>` links return that decision's metadata (looked up over 30 days, or 7 for a read key; a failed lookup is reported as its error, never as "not found"); `/users/<id>`, `/ai/models/<model>` and the AI & Safety list pages name the object and return the console link only; `/issues/<key>` links of any kind return the issue story plus the same `brief` and text as `heystack_get_issue` (likely cause with evidence and what would rule it out, linked fixes with their release basis, the confirmation state; a tracked security group instead reports whether a verification was made against the current policy), looked up over the last 24h | `url` |
| `heystack_investigate` | read | The app dossier: the top 3 open issues, each with its brief's summary, likely cause (confidence, what would rule it out) and console link, plus request, error-rate and p95 changes against the previous window. Built from the inbox snapshot and cached briefs; no AI text. A brief whose only candidate is "unknown" counts as cause unknown | `app`, `window?` (`1h`/`24h`/`7d`, default `1h`) |

Every `console_url` the tools return opens the current console: an app is `/?app=<id>`, a trace or log view is `/explore/<dataset>`, an error, crash, bug report or journey incident is `/issues/<key>?app=<id>`, a replay is `/sessions/<id>?app=<id>`, and settings pages are under `/settings/`. Older `/apps/<id>?tab=…` links keep working and `heystack_resolve_url` still reads them.

### Write-back and help (`core`)

| Tool | Access | What it does | Key arguments |
|---|---|---|---|
| `heystack_start_investigation` | write | Start or resume an investigation and get the console link to share (`open_hint`); `resume` returns the handoff | `title`, `app?`, `question?`, `window?`, `resume?`, `client_session_id?`, `repo?`, `branch?`, `issue_key?` |
| `heystack_update_investigation` | write | Record hypotheses, findings and code steps, conclude it, and read console notes, approvals and who has control. When the investigation has an issue and the update carries a PR or commit, `next_actions` says to call `heystack_link_fix`. `reported_by: "hook"` is the Claude Code hook entry point (flat strings only) | `investigation_id` or `client_session_id`, `hypotheses?`, `notes?`, `external_steps?`, `status?`, `summary?`, `repo?`, `branch?`, `pr_url?` |
| `heystack_set_issue_status` | write | Triage an issue: `open`, `resolved` or `ignored`, an assignee, or `resolve_in` (`next_release`, or a release name) which links a release fix that Heystack watches. Only the fields you pass change (status and assignee go through the inbox triage route; a `note`, kept for errors, failing operations and crashes only, keeps the current status and owner). A journey or security issue's status is set by its source | `issue_key` (or `app` + `kind` + `fingerprint`), `status?`, `resolve_in?`, `assignee?`, `note?` |
| `heystack_link_fix` | write | Link a commit or PR (or the next release) to an issue; Heystack finds the release that contains it and watches whether the issue stops. Linking the same fix again is harmless; at most 5 active watches per issue. One analytics read measures the baseline (unknown when paused). Returns `fix_watch_available` and `outcome_measurable` (false for issues other than errors, failing operations and crashes). Not available to read keys | `issue_key`, `commit_sha?` (7–40 hex), `pr_url?` (https on github.com, gitlab.com or bitbucket.org), `investigation_id?`, `mode?` (`commit`/`next_release`/`release`), `release?` |
| `heystack_verify_fix` | read | Whether the leading linked fix held: `state` (`awaiting_release`, `watching`, `verified`, `regressed`, `expired` or `none`), a sentence to show as is, the baseline and after-fix rates, the release that carries it with its `release_basis` (`assumed_next_release` = assumed, not proven), and `fix_watch_available`. No analytics read; read keys may call it, so CI can use it as a gate | `issue_key` |
| `heystack_set_bug_status` | write | Move a user bug report to `new`, `triaged` or `resolved` | `app`, `id`, `status` |
| `heystack_verify_setup` | read | Checks an app is correctly instrumented: data of any kind arriving (requests, logs, browser errors and product events, session replay, crash reports, metrics), service names, runtime entry, error capture, release attribution, gen_ai enrichment, sampling and replay config. With `wait_seconds` it re-checks every 15 seconds until the first data lands. Returns pass/warn/fail checks with concrete fixes from the `heystack-setup` skill. Shares its checklist with Settings › App › Overview (`GET /api/setup-check`); while analytics are paused to stay within limits (or the telemetry read fails) the telemetry checks are replaced by one `telemetry_paused` (or `telemetry_unavailable`) warn check, and any required configuration that is missing (for example an ingest key) is still appended as a failing check. If a re-check during `wait_seconds` fails (rate limited, analytics paused, or an ingest error), it stops waiting and appends a `wait_interrupted` warn check; the other checks are then from the last successful check | `app`, `wait_seconds` (0–120) |
| `heystack_docs` | read | Search or read these docs (SDK entries per runtime, console, API, MCP setup, playbooks, the `heystack-setup` skill) | `query` or `slug` |

### Manage (`manage`)

| Tool | Access | What it does | Key arguments |
|---|---|---|---|
| `heystack_create_app` | admin · **confirm** | Create an app and mint its first server ingest key (`sk_live_…`); the raw key is returned **once** | `name`, `service_name`, `framework?`, `repo_url?`, `confirm` |
| `heystack_update_app` | admin · **confirm** when `repo_url` is set or cleared | Rename an app or set/clear its repository URL (used for suspect-commit links). The app has one repository setting; changing it never retargets an existing recovery connector | `app`, `name?`, `repo_url?`, `confirm?` |
| `heystack_share_investigation` | write · **confirm** when `visibility` is `org` | Make an investigation private or visible to everyone in your organisation, including its charts and notes | `investigation_id`, `visibility` (`org`/`private`), `confirm` |
| `heystack_delete_app` | admin · **confirm** | Permanently delete an app and everything stored for it: keys, alerts, App Care setup and history, GitHub and Cloudflare connections, security settings, issues and triage, investigations, saved views and recordings (refused while a GitHub recovery run is live; the GitHub token itself must be revoked on GitHub). Telemetry already received is not deleted: it stays visible in organisation-wide views and SQL until it expires (within 30 days) | `app`, `confirm` |
| `heystack_list_keys` | read | Ingest keys for an app (prefix, class `live`/`web`/`ios`/`android`, created, revoked) — never the full key | `app` |
| `heystack_create_key` | admin · **confirm** | Mint a new ingest key: `live` = server (`sk_live_…`, server-side only), `web` = public write-only Browser key (`hs_web_…`) for `@heystack/otel/web`, `ios`/`android` = mobile public keys; the raw key is returned **once** | `app`, `class` (default `live`), `confirm` |
| `heystack_revoke_key` | admin · **confirm** | Revoke an ingest key — anything still using it stops being able to send telemetry immediately | `app`, `key_id`, `confirm` |
| `heystack_get_config` | read | Per-app configuration: session replay (enabled, sample rate, masking, browser kill-switches), head sampling (rate, keep errors, keep slow) and whether a Cloudflare Analytics connector is configured | `app` |
| `heystack_set_replay_config` | admin | Update session replay for a browser app: enable/disable, sample rate (0–1), masking mode (`strict`/`relaxed`) and the remote kill-switches for browser tracing / error capture | `app`, `enabled`, `sample_rate`, `masking_mode`, `tracing_enabled`, `errors_enabled` |
| `heystack_set_sampling_config` | admin | Update head-sampling: `trace_sample_rate` (0–1), `keep_errors` (always keep error traces) and `keep_slow_ms` (always keep traces slower than this) | `app`, `trace_sample_rate`, `keep_errors`, `keep_slow_ms` |
| `heystack_list_alerts` | read | Alert rules for an app (type, threshold, window, notification channel, enabled, last fired) plus recent alert events; the delivery URL is never returned | `app`, `events_limit` (default 20) |
| `heystack_create_alert` | write · **confirm** with `webhook_url` | Create an alert rule: `error_rate` (threshold in %), `latency_p95` (ms), `crash_rate` (crashes per hour) or `no_data` (fires when the app sends nothing for the whole window) over a window (`5m`/`15m`/`1h`/`6h`/`24h`; `crash_rate` and `no_data` take `1h`/`6h`/`24h` only), optionally delivering to a notification channel (`channel_id`) or a webhook URL. Rules come back with a plain `window_label` | `app`, `name`, `type`, `threshold`, `window`, `channel_id?`, `webhook_url?`, `confirm?` |
| `heystack_update_alert` | write · **confirm** when setting `webhook_url` | Change an alert rule's name, threshold, window, notification channel (`channel_id`; `null` clears, no confirmation), webhook (`null` clears, no confirmation) or enabled flag | `app`, `id`, fields, `confirm?` |
| `heystack_delete_alert` | write · **confirm** | Delete an alert rule (its past events are kept) | `app`, `id`, `confirm` |
| `heystack_list_notifications` | read (people only) | Which events (new issue, issue back, fix verified or regressed, journey down, approval waiting, safety spike, quota reached, …) go to which notification channel, for an app or organisation-wide, plus the event kinds and whether delivery is switched on (`event_notifications_available`, `weekly_digest_available`). Read keys get `read_key_not_allowed` | `app?` |
| `heystack_set_notifications` | admin | Turn one event kind on or off for an existing channel, for an app or every app; omitting `threshold_per_hour` keeps the stored threshold | `app?`, `event_kind`, `channel_id`, `enabled`, `threshold_per_hour?` |
| `heystack_record_deploy` | write | Record a deploy marker (version, build commit, time, PR, commits) so briefs link the suspect release to its commit and compare view and a linked fix finds its release. CI can send the same with the app's server key ([REST API](https://heystack.dev/docs/api#deploy-markers)) | `app`, `version`, `build?`, `previous_build?`, `environment?`, `deployed_at?` (at most 5 minutes ahead, 30 days back), `pr_url?`, `commits?` (SHAs, 7–40 hex) |
| `heystack_create_github_issue` | write | File a GitHub issue for a Heystack issue in the app's repository through the Heystack GitHub App, written from its brief (no end-user names or emails); the GitHub URL is kept as the issue's link. Idempotent (`created: false` when already filed); refuses plainly when the App isn't installed or configured. Put `Fixes HS-<issue key>` in the pull request to link the fix automatically | `issue_key` |
| `heystack_erase_user` | admin · **confirm** | Erase one person from an app: their profile and links are hidden at once, new data naming them is dropped as it arrives, and stored activity ages out with retention. Irreversible; Heystack keeps only a one-way fingerprint of the id. Repeating it is harmless | `app`, `user`, `confirm` |
| `heystack_list_key_events` | read | An app's key events (sign-ups, checkouts, …): matcher, today / 7-day / 30-day counts, evidence (`observed` never means the action worked; only `verified` may be called confirmed) and where history counting stands. Stored daily counts, no analytics read | `app`, `include_all?` |
| `heystack_define_key_event` | admin | Define a key event from a matcher (a request route, a product event or a captured page click) so Heystack counts it every day and opens a usage-drop issue when it drops. At most 50 turned on per app (`409 limit`), unique names (`409 name_taken`); request and click matchers count the last 30 days once in the background (at most 20,000 matches, 5 per organisation per day) | `app`, `label`, `name?`, `matcher`, `backfill?` |
| `heystack_get_ai_health` | read | How an app's AI answers are doing: status word, failure and flagged rates against the previous period, spend, what changed (new models, prompt versions, releases) and tool-call errors. Without `by` it reads stored counters only; `by` (a breakdown) is one on-demand read | `app?`, `window` (`1h`/`6h`/`24h`/`7d`/`30d`), `by?`, `model?`, `feature?`, `release?` |
| `heystack_get_ai_spend` | read | AI spend across every provider, gateway and SDK: totals (reported, estimated, unpriced calls), a breakdown by provider, model, gateway, consumer label or app (≤ 200 rows), every day in the range, month to date with a straight-line forecast, and the budgets that apply with their state. Reads daily counters only (no analytics cost) | `app?`, `from?`, `to?` (UTC `YYYY-MM-DD`; default month to date), `group?` (`provider`/`model`/`gateway`/`consumer`/`app`) |
| `heystack_get_sdk_config` | read | The SDK configuration document Heystack serves to the app's SDKs (`/v1/config`), the admin overrides it is built from (with their `revision`), and the SDK clients seen for the app (name, entry, version, last seen) | `app` |
| `heystack_set_sdk_config` | admin · **confirm** | Replace the app's SDK config overrides: kill switches (`kill.all`/`traces`/`errors`/`replay`/`events`/`autocapture`/`identify`/`heartbeat`/`ai_content`/`carry`), autocapture, consent, event property lists, identity and the refresh interval. Send back the **whole** overrides object from `heystack_get_sdk_config` (anything left out is removed) with its `revision`, so a concurrent edit is refused | `app`, `overrides`, `revision`, `confirm` |

### Team (`team`)

| Tool | Access | What it does | Key arguments |
|---|---|---|---|
| `heystack_get_org` | read | The active workspace (organization): id, name, slug, member count | — |
| `heystack_rename_org` | admin | Rename the active workspace | `name` |
| `heystack_list_members` | read | Members with email, name and role (`org:admin` / `org:member`) | — |
| `heystack_invite_member` | admin · **confirm** | Email an invitation to join the workspace as member or admin | `email`, `role?`, `confirm` |
| `heystack_set_member_role` | admin · **confirm** | Change a member's role to `org:admin` or `org:member` | `user_id`, `role`, `confirm` |
| `heystack_remove_member` | admin · **confirm** | Remove a member from the workspace (their personal access tokens are revoked) | `user_id`, `confirm` |
| `heystack_list_invites` | read | Pending invitations | — |
| `heystack_revoke_invite` | admin | Revoke a pending invitation | `id` |
| `heystack_list_tokens` | read | Personal access tokens (`hs_pat_…`) in the workspace: name, prefix, scopes, creator, expiry, last used, revoked — never the secret | — |
| `heystack_create_token` | any scope · **confirm** | Create a personal access token for headless agents / CI; scopes are a subset of `read`, `write`, `admin` and can never exceed your role. The secret is returned **once**. Minting needs a signed-in console session: OAuth and token connections get `session_required` and should use console → Settings › Organisation › Coding agents & API instead | `name`, `scopes`, `expires_in_days` (default 90, max 365), `confirm` |
| `heystack_revoke_token` | write (any scope) · **confirm** | Revoke a personal access token immediately | `id`, `confirm` |
| `heystack_get_usage` | read (people only) | This month's events, session replays and AI credits against the plan's limits, quota state (`ok`/`warn`/`over`), per-app events, today's analytics lookups and whether limits are enforced. No analytics read | — |
| `heystack_audit_log` | admin | Recent agent/API activity in the workspace: who (user/token), which tool, method + path, status, duration, when | `limit`, `before` |

### Advanced (`advanced`)

| Tool | Access | What it does | Key arguments |
|---|---|---|---|
| `heystack_query_sql` | read | Guarded, read-only SQL `SELECT` over your telemetry tables for aggregate/correlation questions the structured tools can't express (see [REST API → SQL](https://heystack.dev/docs/api#sql-queries) for the table list and caps). Your workspace filter is injected automatically and the executed SQL is returned | `sql`, `limit?` (max 200) |
| `heystack_schema` | read | Column names and types for a telemetry table (from the live DDL), or the list of queryable tables when `table` is omitted (same content as the `heystack://schema/{table}` resource) | `table?` |
| `heystack_monitor_product` | read | Whole-product activity, failing operations, observed usage maps, feature outcomes, users and sessions, with exact user/session pivots (a bounded snapshot; raw attributes are left out) | `section` (`experience`/`events`/`usage`/`features`/`users`/`sessions`/`problems`), `app?`, `window` (`1h`/`24h`/`7d`), filters |
| `heystack_list_replays` | read | Recent session-replay sessions: user, start/duration, entry URL, browser/device, clicks, errors and linked trace ids (the core tools reach replays through `heystack_get_session_story` and the brief's replay samples) | `app`, `window`, `errors_only`, `limit` |
| `heystack_facets` | read | Top 20 values (with counts) of one filterable field over spans or logs — which services, status codes, releases, devices or Cloudflare outcomes exist. Moved out of `core`: there, `heystack_aggregate` with one `group_by` and the `count` metric answers the same question for every field except `enduser_id` and `account_id` (not group-by dimensions; filter on them instead) | `app`, `source`, `field`, filters, `window` |
| `heystack_feedback` | write (any scope) | Report a missing capability, a wrong/unhelpful result, or other feedback about these tools to the Heystack team | `kind` (`missing_capability`/`wrong_result`/`other`), `message`, `tool?`, `context?` |

### Inline visuals (MCP Apps)

Seven tools have an inline view (any tool with a snapshot renderer, tables included; `heystack_overview` and `heystack_genai_usage` are tables): `heystack_overview`, `heystack_aggregate`, `heystack_metrics`, `heystack_get_trace`, `heystack_service_map`, `heystack_genai_usage` and `heystack_investigate`. In clients that support [MCP Apps](https://modelcontextprotocol.io/extensions/apps/overview) (Claude on the web and in Claude Desktop, VS Code GitHub Copilot, Microsoft 365 Copilot, Goose, Postman, MCPJam, Archestra and other MCP Apps clients) the result renders inline as a chart, map, request timeline, dossier or table, with an **Open in Heystack** button that opens the same `console_url`. If your client does not allow the button, the link is shown as plain text to copy.

Nothing changes for other clients: you still get the same text and the same `console_url`, so in a terminal open the link to see the picture. We don't promise inline rendering in ChatGPT, Claude Code or Cursor.

The view is one self-contained page served as `ui://heystack/viewer`. It makes no network requests and loads nothing from outside, and it shows telemetry text as plain text, never as markup. The picture data travels in the result's `_meta`, which MCP Apps clients keep out of the model's context.

### Resources

Resources are read-only documents the agent can pull into context:

| URI | Contents |
|---|---|
| `heystack://apps` | Live list of apps in the workspace |
| `heystack://fields` | Filterable fields, facets, group-by dimensions and metrics for `heystack_search` / `heystack_facets` / `heystack_aggregate` |
| `heystack://investigations` | The 20 newest investigations you can see (id, title, status, origin, console link) |
| `heystack://investigations/{id}` | An investigation's handoff: hypotheses, console notes the agent has not seen, pending approvals and code touched |
| `heystack://schema/{table}` | Column reference for `heystack_query_sql` — `otel_traces`, `otel_logs`, `otel_metrics`, `otel_span_events`, `otel_span_links`, `crashes`, `otel_traces_red_rollup`, `otel_traces_genai_rollup`, `otel_traces_genai_rollup_v2` |
| `ui://heystack/viewer` | The inline view for MCP Apps clients (one self-contained HTML page). For people's clients to render, not for agents to read |
| `heystack://docs/{slug}` | Any page of these docs as markdown (same content as `https://heystack.dev/docs/{slug}.md`), plus `heystack-setup` for the skill |

### Prompts

Eleven reusable prompts appear in your client's prompt/command picker. Each takes the `app` id (from `heystack_list_apps`) unless noted:

| Prompt | Arguments | What it does |
|---|---|---|
| `investigate_incident` | `app`, `window?` (default `1h`) | The incident loop: dossier → the top issue's brief → try to rule the cause out → report with evidence |
| `fix_issue` | `issue_key` | One issue end to end: brief → reproduce → patch → `heystack_link_fix` → `heystack_verify_fix` after the deploy |
| `verify_release` | `app`, `release?` | After a deploy: issues that are new or came back in the release, and whether the watched fixes held |
| `triage_new_errors` | `app`, `since_release?` | Triage recent issues (optionally since a release) from their briefs: ignore noise, link fixes, note regressions |
| `why_is_latency_up` | `app`, `route?` | Find where latency regressed (route, service, dependency, LLM) and show a slow example trace |
| `onboard_app` | `framework` (`nextjs`/`workers`/`node`/`web`/`android`/`other`), `app?` | Create an app (or use an existing one), install the SDK via the `heystack-setup` skill, then verify telemetry arrives |
| `weekly_health_report` | `app` | A concise 7-day report: traffic, errors, latency, top issues, releases, LLM cost, crashes, with links |
| `reduce_llm_cost` | `app` | Analyze LLM usage by model/route, find expensive or failing calls, and propose concrete savings |
| `verify_my_setup` | `app` | Check that an app is instrumented correctly and fix anything missing |
| `start_investigation` | `app?`, `question?` | Open a recorded investigation, share its live link, then work the problem logging hypotheses and findings |
| `continue_investigation` | `investigation_id` | Resume an investigation from its handoff (also the `/heystack:continue_investigation` command in the Claude Code plugin) |

The [agent playbooks](https://heystack.dev/docs/agent-playbooks) page has the same prompts in copy-pasteable form for clients that don't surface MCP prompts.

## Safety and limits

- **Tenant-scoped.** A connection sees exactly one workspace — the one chosen at sign-in or the one a token belongs to. There is no cross-workspace access, and the workspace filter is applied by the server on every query, including SQL.
- **Least privilege.** Reads need `read`; anything that changes state needs `write` or `admin`. Members can't perform admin actions no matter what an agent asks for.
- **Destructive and privileged tools require your confirmation.** Deleting apps, revoking keys or tokens, removing members and deleting alerts need it. So do inviting members, changing roles, minting ingest keys or access tokens, creating an app, changing an app's repository, pointing an alert at a webhook, setting up an outcome check against a URL and preparing a repair. Without approval the call returns `confirmed: false` and changes nothing. On clients that support MCP elicitation the server asks you directly, even if the agent passed `confirm: true`. Otherwise the agent must ask you before it passes `confirm: true`.
- **The credential is the boundary.** `?readonly=true` and `?toolsets=` are chosen by the client and only shape the tool list. For CI or a shared connection, use a `read`-scoped personal access token or an `hs_read_` read key, so write tools are refused whatever URL is used.
- **Audited.** Every agent call (client, who, tool, request, status, duration) appears in the console under **Settings › Organisation › Audit log** (visible to organization admins), via `heystack_audit_log` (`team` toolset) and `GET /api/audit`.
- **Telemetry is treated as data, not instructions.** Anyone with your public browser key can send spans, logs, crashes and bug reports, so tool results treat that text as untrusted. Values quoted in headings, bullets, tables or lines are flattened to one line with backticks neutralised. Longer bodies sit in fenced blocks that the content cannot close. Everything is length-capped, including telemetry in `structuredContent`. Model-generated text (trace explanations, AI next actions) is fenced and labelled unverified.
- **Bounded by design.** Each read has a default time window (never unbounded), row and byte caps and a query timeout; results are truncated (`truncated: true`) rather than failing. AI-backed tools (`explain_trace`, natural-language search) are rate-limited per workspace; `heystack_investigate` and `heystack_get_issue` make no model call.
- **Managed only.** There is no self-hosted MCP server — the hosted endpoint is the only one, and it is updated automatically.

## Troubleshooting

| Symptom | Likely cause | Fix |
|---|---|---|
| `401 unauthorized` | Not signed in, or the client dropped its session | Re-run the sign-in (`/mcp` in Claude Code, `codex mcp login heystack`, reconnect in Cursor/VS Code) |
| `401 no_organization` | You signed in but didn't pick a workspace | Sign in again and choose a workspace on the consent screen |
| `401 token_expired` / `token_revoked` | Personal access token expired or was revoked | Create a new token under **Settings › Organisation › Coding agents & API** and update the header |
| `403 scope_required` / `admin_required` | Token lacks `write`/`admin`, or you're a Member trying an admin action | Create a token with the needed scope, or ask a workspace admin |
| `session_required` from `heystack_create_token` | Access tokens can only be minted from a signed-in console session | Create the token in the console under **Settings › Organisation › Coding agents & API** |
| `confirmed: false` | The tool needs your approval and none was given | Approve the action when the agent asks, or say so explicitly; the agent then retries with `confirm: true` |
| Tool not found | It's in a toolset you didn't enable | Add `?toolsets=…` to the URL (see above) |
| Empty results | Wrong `app` or the default 1h/24h window | Run `heystack_list_apps`, widen `window` (e.g. `7d`) |
| `truncated: true` | Result hit its cap | Narrow the window or filters, or lower `limit` (there is no paging cursor) |
| Client caps tool count | Too many tools loaded | Use the default `core` toolset |

For the equivalent HTTP surface, see the [REST API](https://heystack.dev/docs/api). To read these docs from an agent, fetch `https://heystack.dev/llms.txt`.

### Reading investigation evidence

The issue brief and the app dossier include `measurement_notes`. A suggested release cause is an association to check in code (its falsifier says what would rule it out), not proof that the release caused the issue. Anything under `limited` was not checked and remains unknown. Affected-people counts are observed lower bounds.

## App care and recovery

App-care tools operate on the same persistent checks, incidents and repairs as the console. They never turn a successful deployment response into a recovery claim: the care service verifies the configured checks independently.

| Tool | Toolset | Access | Purpose |
| --- | --- | --- | --- |
| `heystack_get_care` | core | read | App condition, coverage and open incidents; pass `incident` for that incident's evidence, plans, actions and receipts |
| `heystack_get_care_incident` | manage | read | Deprecated alias of `heystack_get_care` with `incident` |
| `heystack_run_checkup` | manage | write | Run a checkup, or one configured journey using optional `journey_id` |
| `heystack_configure_journey` | manage | admin, confirm | Create or update HTTP assertions, browser steps, allowed origins, and schedule; omitted update fields are preserved. Sends recurring requests to the URL, so it needs your approval |
| `heystack_get_journey_evidence` | manage | read | Read the latest 20 runs and assertion evidence for a journey |
| `heystack_investigate_care` | manage | write | Persist an evidence-based incident explanation |
| `heystack_prepare_repair` | manage | write, confirm | Prepare a permitted repair with explicit verification targets. Dispatches the repository workflow (tests, pull request), so it needs your approval |
| `heystack_refresh_repair` | manage | write | Collect preparation artifacts and test results |
| `heystack_refresh_recovery` | manage | write | Refresh execution and independent verification |
| `heystack_execute_repair` | manage | admin, confirm | Start an already-approved repair through the configured connector. If the plan is not approved yet it does not execute: it returns `approval_required` with an `approval_url` (clients that support URL elicitation are sent to it) |

**Approving a repair.** `heystack_execute_repair` on a plan that is not approved returns `{approval_required: true, approval_url, approval_id}` (not an error) and never retries execution. Only a signed-in organization admin can approve at that link, in the console; the approval is bound to the plan as it was requested, so a change to the plan makes it stale. After the admin approves, call the tool again. Clients that support URL elicitation are sent to the link once (also after a form confirmation); the follow-up call re-attempts execution, which succeeds only if an admin has approved by then.

Enable `?toolsets=core,manage` for care mutations. The server validates ownership, scope, policy, source/release freshness and required checks. A coding agent cannot grant itself permission through a tool call. Public HTTP checks do not establish that an authenticated signup or payment completed; read each check's actual coverage.

### Uncertain repair dispatch

`heystack_reconcile_dispatch` is an admin-only, confirmed operation for attaching the original GitHub run after a lost response or explicitly confirming that no workflow started. It never dispatches a replacement. Check GitHub before authorizing it; a failed poll alone is not evidence that a deployment did not start. Use a plan ID for preparation and an action-run ID for execution.
