⭐️Claude Managed Agentsについて整理

参考資料: https://platform.claude.com/docs/en/managed-agents/overview

基本となる概念

  • Agent
    • The model, system prompt, tools, MCP servers, and skills
  • Environment
    • Agentが動作する場所を指定
  • Session
    • Environment上でAgentが動作している状態
  • Events
    • アプリとAgentの間で発生するやり取りなど

設定方法

  • UI
  • antコマンド

設定手順

  1. Agentの作成
ant beta:agents create \
  --name "Coding Assistant" \
  --model '{id: claude-opus-4-7}' \
  --system "You are a helpful coding assistant. Write clean, well-documented code." \
  --tool '{type: agent_toolset_20260401}'

agent_toolset_20260401には、数多くの事前定義のtoolが含まれている。

toolについての詳細はこちら。

https://platform.claude.com/docs/en/managed-agents/tools

  1. environmentの作成
ant beta:environments create \
  --name "quickstart-env" \
  --config '{type: cloud, networking: {type: unrestricted}}'
  1. sessionの開始
  • agentとenvironmentの指定が必要
  • SESSION_IDが発行される
session=$(
  curl -sS --fail-with-body https://api.anthropic.com/v1/sessions \
    -H "x-api-key: $ANTHROPIC_API_KEY" \
    -H "anthropic-version: 2023-06-01" \
    -H "anthropic-beta: managed-agents-2026-04-01" \
    -H "content-type: application/json" \
    -d @- <<EOF
{
  "agent": "$AGENT_ID",
  "environment_id": "$ENVIRONMENT_ID",
  "title": "Quickstart session"
}
EOF
)

SESSION_ID=$(jq -er '.id' <<<"$session")

echo "Session ID: $SESSION_ID"
  1. Agentに対してメッセージを送信

Toolsについて

https://platform.claude.com/docs/en/managed-agents/tools

  • 事前定義のツールに加えて、自分でツールを定義することも可能
ant beta:agents create <<'YAML'
name: Weather Agent
model: claude-opus-4-7
tools:
  - type: agent_toolset_20260401
  - type: custom
    name: get_weather
    description: Get current weather for a location
    input_schema:
      type: object
      properties:
        location:
          type: string
          description: City name
      required:
        - location

MCPについて

https://platform.claude.com/docs/en/managed-agents/mcp-connector

MCPの設定は以下の2ステップ:

  1. Agent作成時に、nameとURLでどのMCPを使うかを指定
AGENT_ID=$(ant beta:agents create \
  --name "GitHub Assistant" \
  --model claude-opus-4-7 \
  --mcp-server '{type: url, name: github, url: "https://api.githubcopilot.com/mcp/"}' \
  --tool '{type: agent_toolset_20260401}' \
  --tool '{type: mcp_toolset, mcp_server_name: github}' \
  --transform id --raw-output)

MCPの利用可能なツールを絞ることも可能。

{
  "type": "mcp_toolset",
  "mcp_server_name": "github",
  "default_config": { "enabled": false },
  "configs": [
    { "name": "get_issue", "enabled": true },
    { "name": "list_issues", "enabled": true },
    { "name": "add_issue_comment", "enabled": true }
  ]
}
  1. Session作成時に(認証情報を事前登録している)vaultを元にMCPの認証情報を設定
SESSION_ID=$(ant beta:sessions create \
  --agent "$AGENT_ID" \
  --environment-id "$ENVIRONMENT_ID" \
  --vault-id "$VAULT_ID" \
  --transform id --raw-output)

vaultを使った認証について

https://platform.claude.com/docs/en/managed-agents/vaults

vaultの作成:

VAULT_ID=$(ant beta:vaults create \
  --display-name "Alice" \
  --metadata '{external_user_id: usr_abc123}' \
  --transform id --raw-output)

vaultに認証情報を追加:

  1. static bearer credentialの場合(Linearの例)
ant beta:vaults:credentials create --vault-id "$VAULT_ID" <<'YAML'
display_name: Linear API key
auth:
  type: static_bearer
  mcp_server_url: https://mcp.linear.app/mcp
  token: lin_api_your_linear_key
  1. MCP OAuth credentialの場合(Slackの例)
CREDENTIAL_ID=$(ant beta:vaults:credentials create \
  --vault-id "$VAULT_ID" \
  --display-name "Alice's Slack" \
  --transform id --raw-output <<'EOF'
auth:
  type: mcp_oauth
  mcp_server_url: https://mcp.slack.com/mcp
  access_token: xoxp-...
  expires_at: "2099-12-31T23:59:59Z"
  refresh:
    token_endpoint: https://slack.com/api/oauth.v2.access
    client_id: "1234567890.0987654321"
    scope: channels:read chat:write
    refresh_token: xoxe-1-...
    token_endpoint_auth:
      type: client_secret_post
      client_secret: abc123...
EOF
)