STACK
MENU
DOCS / INTEGRATIONS / ANTHROPIC AGENT SDK

Anthropic

Connect the Claude Messages API to STACK with Anthropic's remote MCP connector. Claude discovers STACK tools and can call them during the request.

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

  • Python 3.9 or later and an Anthropic API key.
  • A STACK account and a Bearer token accepted by the STACK MCP server.
  • At least one service connected at https://getstack.run/app/connect.
bash
pip install anthropic

2. Add STACK to the request

python
import os
import anthropic

client = anthropic.Anthropic()

response = client.beta.messages.create(
    model="claude-opus-4-8",
    max_tokens=1200,
    messages=[{
        "role": "user",
        "content": "Post 'deploy started' to the approved Slack channel.",
    }],
    mcp_servers=[{
        "type": "url",
        "url": "https://mcp.getstack.run/mcp",
        "name": "stack",
        "authorization_token": os.environ["STACK_MCP_TOKEN"],
    }],
    tools=[{
        "type": "mcp_toolset",
        "mcp_server_name": "stack",
    }],
    betas=["mcp-client-2025-11-20"],
)

print(response.content)

Set STACK_MCP_TOKEN to an OAuth access token issued for https://mcp.getstack.run/mcp, or to the operator API key when this runs as a headless service that cannot complete OAuth. Anthropic sends that token to STACK when it connects. Your application must obtain and refresh an OAuth token before making the Messages request; the connector does not run that flow for you. Store the token in your service secret store, not in the prompt or source code.

3. Limit authority

The Bearer token establishes the caller. An owner OAuth token and an operator API key both give the session operator-level access, while a member OAuth token applies that member's role and service-connection restrictions. A task Passport can be used as the bearer when the session must authenticate as that agent; each tool route still decides whether it accepts agent context and how it applies the Passport.

4. Verify and revoke

  • Run one read-only STACK tool before you allow write actions.
  • Confirm the action appears in the STACK audit log.
  • Revoke the MCP OAuth session in STACK Settings when the integration is no longer needed.
  • Revoke a task Passport when you need to stop its next STACK-verified call.

See MCP Setup and STACK Authentication.

stack | Docs