mcpField
A
aws-agentcore

aws-agentcore

github.com/hoodiniエージェントワークフロー291148 回インストール5 日前に更新
リポジトリ

aws-agentcore について

AWS Bedrock AgentCore は、AIエージェントの構築と運用に使う AWS のプリミティブ群です。実行、メモリ、認証、可観測性、オーケストレーションに加え、APIやLambdaをMCP対応ツールに変換できます。

主な機能

  1. 01フレームワーク非依存のサーバーレス実行環境
  2. 02APIとLambdaのMCPツール化
  3. 03セマンティックおよびユーザー設定のメモリ戦略
  4. 04サブエージェントによるオーケストレーション
  5. 05認証、ガードレール、可観測性

活用シーン

  1. 01APIまたはLambdaのツールを使うエージェントの構築
  2. 02セマンティックメモリを持つエージェントの作成
  3. 03専門のリサーチ用サブエージェントの連携

MCP 対応

AgentCore Gatewayは、APIやLambda関数をMCP対応ツールに変換し、エージェントから利用できるようにします。

インストール

コマンドをコピーしてターミナルで実行します。

$npx skills add https://github.com/hoodini/ai-agents-skills --skill aws-agentcore

インストール後、Claude Code で/aws-agentcoreを入力して読み込まれたか確認します。

詳細

AWS Bedrock AgentCore

AWS インフラストラクチャ上で本番環境に対応した AI エージェントを構築します。

クイックスタート

import boto3
from agentcore import Agent, Tool

# Initialize AgentCore client
client = boto3.client('bedrock-agent-runtime')

# Define a tool
@Tool(name="search_database", description="Search the product database")
def search_database(query: str, limit: int = 10) -> dict:
    # Tool implementation
    return {"results": [...]}

# Create agent
agent = Agent(
    model_id="anthropic.claude-3-sonnet",
    tools=[search_database],
    instructions="You are a helpful product search assistant."
)

# Invoke agent
response = agent.invoke("Find laptops under $1000")

AgentCore のコンポーネント

AgentCore は、以下のプリミティブを提供します。

コンポーネント目的
Runtimeサーバーレスのエージェント実行(フレームワークに依存しません)
GatewayAPI/Lambda を MCP 互換のツールに変換
Memory複数の戦略に対応したメモリ(セマンティック、ユーザー設定)
IdentityCognito、Okta、Google、EntraID による認証
Toolsコードインタープリター、ブラウザツール
Observability詳細な分析とトレース

Lambda ツールの統合

# Lambda function as tool
import json

def lambda_handler(event, context):
    action = event.get('actionGroup')
    function = event.get('function')
    parameters = event.get('parameters', [])
    
    # Parse parameters
    params = {p['name']: p['value'] for p in parameters}
    
    if function == 'get_weather':
        result = get_weather(params['city'])
    elif function == 'book_flight':
        result = book_flight(params['origin'], params['destination'])
    
    return {
        'response': {
            'actionGroup': action,
            'function': function,
            'functionResponse': {
                'responseBody': {
                    'TEXT': {'body': json.dumps(result)}
                }
            }
        }
    }

エージェントのオーケストレーション

from agentcore import SupervisorAgent, SubAgent

# Create specialized sub-agents
research_agent = SubAgent(
    name="researcher",
    model_id="anthropic.claude-3-sonnet",
    instructions="You research and gather information."
)

writer_agent = SubAgent(
    name="writer", 
    model_id="anthropic.claude-3-sonnet",
    instructions="You write clear, engaging content."
)

# Create supervisor
supervisor = SupervisorAgent(
    model_id="anthropic.claude-3-opus",
    sub_agents=[research_agent, writer_agent],
    routing_strategy="supervisor"  # or "intent_classification"
)

response = supervisor.invoke("Write a blog post about AI agents")

ガードレールの統合

from agentcore import Agent, Guardrail

# Define guardrail
guardrail = Guardrail(
    guardrail_id="my-guardrail-id",
    guardrail_version="1"
)

agent = Agent(
    model_id="anthropic.claude-3-sonnet",
    guardrails=[guardrail],
    tools=[...],
)

AgentCore Gateway

既存の API を MCP 互換のツールに変換します。

# gateway_setup.py
from bedrock_agentcore import GatewayClient

gateway = GatewayClient()

# Create gateway from OpenAPI spec
gateway.create_target(
    name="my-api",
    type="OPENAPI",
    openapi_spec_path="./api-spec.yaml"
)

# Create gateway from Lambda function
gateway.create_target(
    name="my-lambda-tool",
    type="LAMBDA",
    function_arn="arn:aws:lambda:us-east-1:123456789:function:my-tool"
)

AgentCore Memory

from agentcore import Agent, Memory

# Create memory with multiple strategies
memory = Memory(
    name="customer-support-memory",
    strategies=["semantic", "user_preference"]
)

agent = Agent(
    model_id="anthropic.claude-3-sonnet",
    memory=memory,
    tools=[...],
)

# Memory persists across sessions
response = agent.invoke(
    "What did we discuss last time?",
    session_id="user-123"
)

公式ユースケースリポジトリ

AWS は、本番環境に対応した実装を提供しています。

リポジトリ:https://github.com/awslabs/amazon-bedrock-agentcore-samples

利用可能なユースケース(02-use-cases/)
ユースケース説明
A2A Multi-Agent Incident ResponseStrands + OpenAI SDK を使用したエージェント間連携
Customer Support Assistantメモリ、ナレッジベース、Google OAuth
Market Trends Agentブラウザツールを使用した LangGraph
DB Performance AnalyzerPostgreSQL の統合
Device Management AgentCognito 認証を使用した IoT
Enterprise Web Intelligence調査用のブラウザツール
Text to Python IDEAgentCore Code Interpreter
Video Games Sales AssistantAmplify + CDK によるデプロイ
ユースケースを使ったクイックスタート
git clone https://github.com/awslabs/amazon-bedrock-agentcore-samples.git
cd amazon-bedrock-agentcore-samples/02-use-cases/customer-support-assistant
# Follow README for deployment

リソース

コメント