DEV Community

Haowen Huang
Haowen Huang

Posted on

Running Claude Agent SDK with Skills on Amazon Bedrock

by Haowen Huang (LinkedIn)

The Claude Agent SDK enables building multi-agent systems with Skills, MCP servers, and subagents. By default, it requires an Anthropic API key. This post shows how to run it entirely on Amazon Bedrock instead—no Anthropic API key needed.

The Problem

The DeepLearning.AI course "Agent Skills with Anthropic" assumes you have an ANTHROPIC_API_KEY. But what if you're already using AWS and want to leverage your existing Amazon Bedrock access?

The Solution: Two Lines of Code

The Claude Agent SDK uses Claude Code under the hood, which supports Amazon Bedrock via environment variables. The key configuration is surprisingly simple:

import os

# Configure Claude Code to use Amazon Bedrock
os.environ["CLAUDE_CODE_USE_BEDROCK"] = "1"
os.environ["AWS_REGION"] = "us-west-2"  # Your preferred region
Enter fullscreen mode Exit fullscreen mode

That's it. Set these before creating ClaudeSDKClient, and the SDK will use your AWS credentials instead of an Anthropic API key.

Prerequisites

Before running, verify your AWS setup:

# Check AWS CLI
aws --version

# Verify credentials
aws configure get aws_access_key_id

# Test Bedrock access
aws bedrock list-foundation-models --query "modelSummaries[?contains(modelId, 'claude')]" --output table
Enter fullscreen mode Exit fullscreen mode

You need:

  • AWS credentials configured (~/.aws/credentials or environment variables)
  • Amazon Bedrock model access enabled in your AWS console
  • IAM permissions for bedrock:InvokeModel

Complete Example

Here's the modified agent.py for Amazon Bedrock:

import asyncio
import os
from dotenv import load_dotenv
from claude_agent_sdk import (
    AgentDefinition, ClaudeSDKClient, ClaudeAgentOptions, AssistantMessage,
)

load_dotenv()
AWS_REGION = os.environ.get("AWS_REGION", "us-west-2")

# Key configuration for Bedrock
os.environ["CLAUDE_CODE_USE_BEDROCK"] = "1"
os.environ["AWS_REGION"] = AWS_REGION

async def main():
    agents = {
        "docs_researcher": AgentDefinition(
            description="Finds information from official documentation.",
            prompt="You research official docs.",
            tools=["WebSearch", "WebFetch"],
            model="haiku"
        ),
    }

    options = ClaudeAgentOptions(
        system_prompt="You are a helpful assistant.",
        allowed_tools=["Skill", "Task", "Write", "Bash", "WebSearch", "WebFetch"],
        model="sonnet",
        agents=agents
    )

    async with ClaudeSDKClient(options=options) as client:
        await client.query("Hello!")
        async for message in client.receive_response():
            if isinstance(message, AssistantMessage):
                print(message.content)

asyncio.run(main())
Enter fullscreen mode Exit fullscreen mode

Adding MCP Servers (Optional)

MCP servers like Notion work the same way. Just ensure the token exists before adding the config:

NOTION_TOKEN = os.environ.get("NOTION_TOKEN")

mcp_servers = {}
if NOTION_TOKEN:
    mcp_servers["notion"] = {
        "command": "npx",
        "args": ["-y", "@notionhq/notion-mcp-server"],
        "env": {"NOTION_TOKEN": NOTION_TOKEN},
    }

options = ClaudeAgentOptions(
    mcp_servers=mcp_servers,
    # ... other options
)
Enter fullscreen mode Exit fullscreen mode

What Works on Amazon Bedrock

Everything from the original SDK works:

  • Skills (e.g., learning-a-tool)
  • Subagents with parallel execution
  • MCP servers (Notion, etc.)
  • All built-in tools (WebSearch, Bash, Write, etc.)

A Note on the Debugging Process

This entire migration—from identifying the Bedrock configuration, fixing MCP server issues, to successfully running Skills with subagents—was completed through conversation with Kiro, an AI-powered IDE. No external documentation was consulted. Kiro diagnosed issues in real-time, suggested fixes, and validated the setup by running test scripts directly.

The workflow:

  1. Asked Kiro how to use Bedrock instead of Anthropic API
  2. Kiro checked the environment, identified missing dependencies
  3. Kiro found the correct configuration (environment variables, not client parameters)
  4. Fixed runtime errors (MCP config validation when token was missing)
  5. Verified everything worked end-to-end

This demonstrates how AI-assisted development can accelerate debugging unfamiliar SDKs without documentation diving.

Conclusion

Running Claude Agent SDK on Amazon Bedrock requires just two environment variables. Your existing AWS credentials handle authentication, and all SDK features—Skills, subagents, MCP servers—work unchanged.

If you're already in the AWS ecosystem, this is the simplest path to using Claude Agent SDK without managing a separate Anthropic API key.

Top comments (1)

Collapse
 
max_quimby profile image
Max Quimby

The two-environment-variable setup is deceptively simple and I appreciate that you called out the exact vars without burying them — CLAUDE_CODE_USE_BEDROCK is one of those things that's easy to miss in the docs if you don't know to look for it.

A few things worth flagging for anyone taking this to production: Bedrock adds a latency layer compared to hitting the Anthropic API directly, which starts to matter when you're running Skills that chain multiple model calls. It's not a dealbreaker, but worth benchmarking before you commit to the architecture, especially for time-sensitive agentic workflows.

The bigger win for AWS-embedded teams is cross-region inference routing — Bedrock lets you configure fallback regions if capacity in your primary region is constrained. If you're running intensive agent workloads, that resilience is worth more than any per-token cost difference. Have you experimented with the multi-region setup, or are you running single-region for now?

Also curious: do the MCP server connections behave identically on Bedrock, or have you seen any edge cases with tool use that differ from direct API mode?