fix: move MCPClient imports inside try block, add TOOLS.md placeholder
This commit is contained in:
@@ -5,8 +5,6 @@ Entrypoint for AgentCore CodeZip deployment.
|
|||||||
"""
|
"""
|
||||||
import os
|
import os
|
||||||
from strands import Agent, tool
|
from strands import Agent, tool
|
||||||
from strands.tools.mcp import MCPClient
|
|
||||||
from mcp.client.streamable_http import streamablehttp_client
|
|
||||||
from strands.models import BedrockModel
|
from strands.models import BedrockModel
|
||||||
from bedrock_agentcore.runtime import BedrockAgentCoreApp
|
from bedrock_agentcore.runtime import BedrockAgentCoreApp
|
||||||
|
|
||||||
@@ -470,13 +468,17 @@ async def main(payload: dict, context):
|
|||||||
_aws_mcp_client = None
|
_aws_mcp_client = None
|
||||||
_aws_mcp_tools = []
|
_aws_mcp_tools = []
|
||||||
try:
|
try:
|
||||||
|
from strands.tools.mcp import MCPClient
|
||||||
|
from mcp.client.streamable_http import streamablehttp_client
|
||||||
_aws_mcp_client = MCPClient(
|
_aws_mcp_client = MCPClient(
|
||||||
lambda: streamablehttp_client(config.AWS_MCP_URL, auth=_AwsMcpSigV4Auth())
|
lambda: streamablehttp_client(config.AWS_MCP_URL, auth=_AwsMcpSigV4Auth())
|
||||||
)
|
)
|
||||||
_aws_mcp_client.start()
|
_aws_mcp_client.start()
|
||||||
_aws_mcp_tools = [_aws_mcp_client]
|
_aws_mcp_tools = [_aws_mcp_client]
|
||||||
except Exception as _e:
|
except Exception as _e:
|
||||||
print(f'[main] AWS MCP client failed to start: {_e}')
|
import traceback
|
||||||
|
print(f"[main] AWS MCP client failed to start: {type(_e).__name__}: {_e}")
|
||||||
|
print(traceback.format_exc())
|
||||||
|
|
||||||
all_tools = base_tools + mcp_clients + _aws_mcp_tools
|
all_tools = base_tools + mcp_clients + _aws_mcp_tools
|
||||||
|
|
||||||
|
|||||||
3
workspace/TOOLS.md
Normal file
3
workspace/TOOLS.md
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
# Tools
|
||||||
|
|
||||||
|
This file documents available tools for the agent-claw runtime.
|
||||||
Reference in New Issue
Block a user