Connect the Claude Messages API to STACK with Anthropic's remote MCP connector. Claude discovers STACK tools and can call them during the request.
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.
pip install anthropicimport 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.
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.
See MCP Setup and STACK Authentication.