# Claude Code

Add STACK to Claude Code as an MCP server. STACK speaks OAuth 2.1 with PKCE and Dynamic Client Registration (RFC 7591), which is what Claude Code's MCP add command requires. No API-key copy-paste; you approve scopes in your browser the first time the CLI connects.

For authentication, client compatibility, and shared service setup, see [MCP setup](/docs/security/mcp-setup).

## Run fleet Missions

Connect the service and approve the fleet policy before starting automated work. The approved provisioner enrolls workers with their own keys. A worker uses its key to obtain a short-lived MCP session, then calls stack_start_mission with the job’s exact access and limits.

Use the returned Passport for calls through STACK. Routine allowed calls require no additional approval. Call stack_renew_mission to continue the same job without resetting its allowance. The client can obtain another session and reconnect with the worker’s key when its MCP session expires.

Interactive OAuth signs the client in as a member. Fleet execution uses the enrolled worker’s identity. Use a client or application runtime that can present the worker’s session token for this flow.

## 1. Prerequisites

- Claude Code installed (https://docs.claude.com/en/docs/claude-code).
- A STACK account. Start at https://getstack.run/get-started (the first 14 days are free; a card is required).
- At least one upstream service connected in the STACK Console at https://getstack.run/app/connections. Claude Code will reach it through STACK.

## 2. Add STACK as an MCP server

From your terminal, run:

```bash
claude mcp add --transport http --scope user stack https://mcp.getstack.run/mcp
```

On first connection, Claude Code discovers STACK's OAuth metadata at `/.well-known/oauth-authorization-server`, registers itself as an OAuth client via `/oauth/register`, and opens your browser to `getstack.run` to approve the scopes.

If you want STACK available across all your Claude Code projects, add `--scope user`. To scope to one project only, use `--scope project` (the default in current versions; check `claude mcp add --help`).

## 3. Verify the connection

```bash
claude mcp list
```

You should see `stack` with status connected. Inside a Claude Code session, the model can now call STACK tools just like any other MCP-registered tool.

## 4. Usage from Claude Code

Once connected, Claude can invoke the STACK tools allowed by the OAuth Bearer token. A team member's token retains that member's role and connection restrictions. The most useful tools in a coding session:

- stack_list_services — see which services are connected and what scopes you have.
- stack_proxy_request — make an authenticated call through the credential-injecting proxy, limited by the supplied Passport grants and current member connection restrictions.
- stack_get_proxy_operation — recover delivery state or an authorised stored response after a non-GET call loses its response.
- stack_issue_passport — mint a short-lived passport for an open Mission (mission_ids holds exactly one ms_* ID).
- stack_invoke_skill — invoke a published skill. For sealed skills, STACK runs the published LLM and script steps in STACK.
- stack_audit_list — read the hash-chained audit log available to your authenticated role. Needs controls.
- stack_create_dropoff / stack_collect — schema-validated agent-to-agent hand-off across runtimes.
- stack_revoke_passport / stack_revoke_all_passports — the next STACK-verified call rejects revoked authority.

Non-GET proxy calls require an `authority_request_id` created and persisted before the call. Reuse it only for the unchanged request. See [Proxy operation recovery](/docs/api/proxy#operation-recovery).

Full tool reference at [/docs/mcp-tools](/docs/mcp-tools).

## 5. Team sharing

Invite team members at `getstack.run/team`. Each person signs in to STACK and authorizes Claude Code with their own login. STACK retains that member identity on the OAuth session, so requests remain attributable to the member and are limited by the member's current role and allowed connections.

## 6. Revocation

Disconnect or revoke from the STACK dashboard at `getstack.run/team` or programmatically via [POST /v1/passports/revoke](/docs/api/passports). The next STACK-verified request from Claude Code fails. A call already forwarded to an upstream service is not rolled back.

## Next

- [MCP setup](/docs/security/mcp-setup) — authentication and client setup.
- [Concepts: passports](/docs/concepts/passports) — what passports are and how scope narrows down a delegation chain.
- [Concepts: audit](/docs/concepts/audit) — the hash-chained audit log that records every tool call.
- [Concepts: team](/docs/concepts/team) — multi-member operators, roles, and per-member audit.
