Share
Embed
Transcript
31 slides
-
MCP:実装 MCP:実装 Lambda関数 #FastMCPサーバーの初期化(ステートレスモード) mcp=FastMCP(stateless_http=True,json_response=True) #MCPツールの定義。実質CloudTrailのLookupEventsAPIをラップしただけ @mcp.tool deflookup_cloudtrail_events() #FastAPIアプリケーションを取得 app=mcp.http_app()
Dockerfile #CopyAWSLambdaWebAdapter COPY--from=public.ecr.aws/awsguru/aws-lambda-adapter:0.9.1/lambda-adapter/opt/extensions/lambda-adapter -
from strands import Agent agent = Agent( model=model, tools=tools, system_prompt=system_prompt
) Strands Agents? Strands Agents? オープンソースのエージェント開発フレームワーク 👆これだけでAIエージェントが定義できる -
モデル駆動 推論・ツール使用 ・応答生成のサイクルを 最先端LLMの性能に委ねるアプローチ 他フレームワークの例: ・LangGraph→Graph ・Mastra→Workflow Strands Agents? Strands
Agents? プ ロ ンプ ト と ツ ー ル 渡 す か ら 自 分 で 判 断 して タ ス ク して ね ! -
StrandsAgents:実装 StrandsAgents:実装 ソースコード(抜粋) #使⽤するモデルの定義 bedrock_model=BedrockModel( model_id= apac.anthropic.claude-3-5-sonnet-20241022-v2:0 , region_name= ap-northeast-1
, temperature=0.7, max_tokens=4000 ) #MCPクライアント、ツールの定義 MCP_URL=os.environ[ MCP_URL ] mcp_client=MCPClient(lambda:streamablehttp_client(MCP_URL)) mcp_tools=mcp_client.list_tools_sync() #エージェントの定義 agent=Agent( model=bedrock_model, tools=all_tools, system_prompt=system_prompt ) #エージェントの応答をストリーミング loop=asyncio.new_event_loop() response=loop.run_until_complete(stream_agent_response(agent,prompt,st.container())) loop.close() -
StrandsAgents:実装 StrandsAgents:実装 ファイル全部でこれだけ aws-detective-agent/ ├──app/#エージェントアプリ │├──main.py │├──requirements.txt │├──Dockerfile ├──lambda/#MCPサーバー │├──mcpserver/
││└──main.py │├──Dockerfile │└──pyproject.toml ├──lib/ #CDK │├──config.ts │└──stack.ts ├──bin/ #CDK │└──app.ts └──cdk.json └──package.json -
おしまい おしまい 参考 https://strandsagents.com/latest/ https://github.com/jlowin/fastmcp https://github.com/ag-ui-protocol/ag-ui https://github.com/strands-agents/sdk-python https://github.com/awslabs/mcp/blob/main/src/lambda-tool-mcp-server https://aws.amazon.com/jp/blogs/news/introducing-strands-agents-an-open-source-ai-agents-sdk/ https://qiita.com/minorun365/items/dd05a3e4938482ac6055
https://qiita.com/kyuko/items/cb75e8f0a50985ca2030 https://qiita.com/5enxia/items/0dfca327e8f14f0b9d86 https://www.ranthebuilder.cloud/post/mcp-server-on-aws-lambda https://memoribuka-lab.com/?p=4460#google_vignette https://dev.classmethod.jp/articles/aws-lambda-mpc-server/