Anthropic Agent SDK
Use STACK with the Anthropic Agent SDK by registering STACK as an MCP server in your agent loop. Anthropic invented MCP; the SDK is built around it. STACK is MCP-native, so the integration is one registration and you get the whole STACK tool surface inside the agent.
For the why-this-matters framing — what STACK adds on top of the Anthropic SDK and why MCP-native end-to-end matters — read /with/anthropic. This page is the technical guide.
1. Prerequisites
- Python 3.10+ and an Anthropic API key (https://console.anthropic.com).
- A STACK operator account. Sign up at https://getstack.run.
- A STACK API key from https://getstack.run/account (or a member key from /team).
- At least one upstream service connected on the STACK side at https://getstack.run/services.
2. Install
pip install anthropic getstack3. Register STACK as an MCP server
The Anthropic Messages API supports MCP servers via the mcp_servers request param (beta header mcp-client-2025-04-04). Pass STACK as one of the servers, with your STACK API key as a Bearer token:
import anthropic
import os
client = anthropic.Anthropic()
response = client.beta.messages.create(
model="claude-sonnet-4-6",
max_tokens=4096,
mcp_servers=[
{
"type": "url",
"url": "https://mcp.getstack.run/mcp",
"name": "stack",
"authorization_token": os.environ["STACK_API_KEY"],
}
],
extra_headers={"anthropic-beta": "mcp-client-2025-04-04"},
messages=[
{
"role": "user",
"content": "Post 'deploy started' to #engineering on Slack via STACK.",
}
],
)
print(response.content)The model sees STACK's tool list at the start of the turn and calls stack_proxy_request (or a more specific tool) when it needs a service. STACK injects the credential at the proxy and lands the call in your audit chain.
4. Mission-context passport pattern
For agents that need a tightly scoped credential for a specific intent, mint a passport up front and register STACK with that passport instead of an admin key. The narrow-only scope rules in the passport apply to every call the agent makes during the run:
from getstack import StackClient
import anthropic
stack = StackClient(api_key=os.environ["STACK_API_KEY"])
passport = stack.passports.issue(
agent_id="agent_deploy_bot",
intent="post_to_slack_engineering",
ttl_seconds=900, # 15 min
)
client = anthropic.Anthropic()
response = client.beta.messages.create(
model="claude-sonnet-4-6",
max_tokens=4096,
mcp_servers=[
{
"type": "url",
"url": "https://mcp.getstack.run/mcp",
"name": "stack",
"authorization_token": passport.token,
}
],
extra_headers={"anthropic-beta": "mcp-client-2025-04-04"},
messages=[{"role": "user", "content": "Post 'deploy started' to #engineering."}],
)
stack.passports.revoke(passport.id)5. Claude API direct (no SDK)
If you're calling the Messages API directly without the Python SDK, the same mcp_servers field works. The full STACK tool surface gets exposed to the model on every turn.
6. Audit and revoke
Every call the agent makes through STACK shows up in the hash-chained audit log with the agent ID, passport, intent, scope, and result. Revoke the passport via stack.passports.revoke() or the dashboard at getstack.run/agents; sub-60-second propagation to every connected service.
Next
- /with/anthropic — the why-this-matters framing.
- Concepts: passports — short-lived, intent-scoped, narrow-only-down-the-chain.
- Python SDK reference — full method list.
- API: audit — exporting the audit chain to your SIEM.