How to connect an MCP server to Claude Managed Agents
Updated
Declare the server's address in the agent's mcp_servers with an mcp_toolset that names it, store a key for the server in a vault as a static_bearer credential, allow api.kaiv.ai in the environment's networking, and pass the vault's ID when you create the session. The agent then calls the server's tools from its sandbox.
Step by step
- Create a keyOn the server's Connect tab, create a key for this one server. It is shown once.
- Declare the server on the agentAdd the server's address to mcp_servers and an mcp_toolset that names it, as below.
- Store the key in a vaultCreate a vault and add a static_bearer credential whose mcp_server_url is the server's address and whose token is the key.
- Allow api.kaiv.aiWith limited networking, add api.kaiv.ai to the environment's allowed_hosts, or creating the session fails.
- Start a session with the vaultPass the vault's ID in vault_ids when you create the session, then send it a task.
The agent
Each MCP server on an agent needs a name, its address and a matching mcp_toolset. MCP tools ask for approval before each call by default (always_ask). For a server whose tools only read, you can let them run without asking: add "default_config": {"permission_policy": {"type": "always_allow"}} to the toolset.
curl -sS https://api.anthropic.com/v1/agents \
-H "x-api-key: $ANTHROPIC_API_KEY" \
-H "anthropic-version: 2026-10-21" \
-H "anthropic-beta: managed-agents-2026-04-01" \
-H "content-type: application/json" \
-d '{
"name": "Orders assistant",
"model": "claude-opus-5-5",
"mcp_servers": [
{"type": "url", "name": "your-server", "url": "https://api.kaiv.ai/api/bridge/mcp/your-server"}
],
"tools": [
{"type": "mcp_toolset", "mcp_server_name": "your-server"}
]
}'The key, in a vault
A gateway key (kv_live_...) calls one server. Create it on the server's Connect tab or under Keys & access. It is shown once; Bridge keeps only its hash.
A vault holds the key so it never sits in the agent's definition. The vault matches a credential to a server by its address, so mcp_server_url must be the same address as in mcp_servers.
curl -sS https://api.anthropic.com/v1/vaults \
-H "x-api-key: $ANTHROPIC_API_KEY" \
-H "anthropic-version: 2026-10-21" \
-H "anthropic-beta: managed-agents-2026-04-01" \
-H "content-type: application/json" \
-d '{"display_name": "Kaiva Bridge"}'
curl -sS "https://api.anthropic.com/v1/vaults/$VAULT_ID/credentials" \
-H "x-api-key: $ANTHROPIC_API_KEY" \
-H "anthropic-version: 2026-10-21" \
-H "anthropic-beta: managed-agents-2026-04-01" \
-H "content-type: application/json" \
-d '{
"display_name": "your-server key",
"auth": {
"type": "static_bearer",
"mcp_server_url": "https://api.kaiv.ai/api/bridge/mcp/your-server",
"token": "kv_live_..."
}
}'The environment and the session
With limited networking, every MCP server's host must be in allowed_hosts. Then create the session with the vault.
curl -sS https://api.anthropic.com/v1/environments \
-H "x-api-key: $ANTHROPIC_API_KEY" \
-H "anthropic-version: 2026-10-21" \
-H "anthropic-beta: managed-agents-2026-04-01" \
-H "content-type: application/json" \
-d '{
"name": "kaiva-bridge",
"config": {
"type": "cloud",
"networking": {"type": "limited", "allowed_hosts": ["api.kaiv.ai"]}
}
}'
curl -sS https://api.anthropic.com/v1/sessions \
-H "x-api-key: $ANTHROPIC_API_KEY" \
-H "anthropic-version: 2026-10-21" \
-H "anthropic-beta: managed-agents-2026-04-01" \
-H "content-type: application/json" \
-d '{
"agent": "'"$AGENT_ID"'",
"environment_id": "'"$ENVIRONMENT_ID"'",
"vault_ids": ["'"$VAULT_ID"'"]
}'Check it works
Send the session a task that needs the server, such as a question about your data. Its events show agent.mcp_tool_use and agent.mcp_tool_result for each call.
A session.error event names the problem: mcp_authentication_failed_error when the key is missing or wrong, mcp_connection_failed_error when the server cannot be reached. To check the server itself, run the CLI's check:
npx @kaiva/bridge doctor your-serverOther ways to do it
- The Claude API's MCP connectorFor a single Messages API request in your own code, the MCP connector takes the same address, with the key as its authorization token.
- Claude Code or CodexFor an agent you run on your own machine, add the server to Claude Code or Codex instead.
Questions
- Can Managed Agents sign in to the server with OAuth instead of a key?
- Yes, with an mcp_oauth credential in the vault. A key stored as a static_bearer credential is simpler for an agent that runs with no person present.
- Why does creating the session fail with a 400?
- With limited networking, every MCP server's host must be in the environment's allowed_hosts. Add api.kaiv.ai.
- Can I limit which tools the agent sees?
- Yes. Switch tools on or off for the server in Kaiva Bridge, or set default_config enabled to false on the mcp_toolset and enable tools by name.
- Do tool calls wait for approval?
- By default, yes: MCP toolsets use always_ask. Set the toolset's permission_policy to always_allow for tools that only read.