AWS bedrock-agentcore documentation change
Summary
Removed preview notice, refactored code examples with proper auth handling, and updated model references
Security assessment
Code restructuring demonstrates authorization header usage but doesn't introduce new security concepts. Changes appear focused on code quality and API updates rather than addressing vulnerabilities.
Diff
diff --git a/bedrock-agentcore/latest/devguide/gateway-agent-integration.md b/bedrock-agentcore/latest/devguide/gateway-agent-integration.md index 6450dd222..148373e2b 100644 --- a//bedrock-agentcore/latest/devguide/gateway-agent-integration.md +++ b//bedrock-agentcore/latest/devguide/gateway-agent-integration.md @@ -5,2 +4,0 @@ -Amazon Bedrock AgentCore is in preview release and is subject to change. - @@ -18 +16,2 @@ Strands - from strands.tools.mcp import MCPClient + from strands.models import BedrockModel + from strands.tools.mcp.mcp_client import MCPClient @@ -21,4 +19,0 @@ Strands - # Replace with actual values and the Amazon Bedrock model of your choice - gateway_url = "${GatewayUrl}" - access_token = "${AccessToken}" - model_id = "us.anthropic.claude-3-7-sonnet-20250219-v1:0" @@ -26,7 +21,7 @@ Strands - # Create an MCP Client that points to the gateway - gateway_client = MCPClient(lambda: streamablehttp_client(gateway_url, headers={"Authorization": f"Bearer {access_token}"})) - - # Create an Agent that uses a Amazon Bedrock model and the gateway to answer - def product_agent(question: str): - with gateway_client: - tools = gateway_client.list_tools_sync() + def _invoke_agent( + bedrock_model, + mcp_client, + prompt + ): + with mcp_client: + tools = mcp_client.list_tools_sync() @@ -34,4 +29,2 @@ Strands - model=model_id, - tools=tools, - system_prompt="try to answer the user's question using the tools available", - callback_handler=None + model=bedrock_model, + tools=tools @@ -39 +32,2 @@ Strands - return agent(question) + return agent(prompt) + @@ -41,2 +35,27 @@ Strands - # Send a query to the agent. The agent has access to the tools in the gateway to help answer the query - print(product_agent("what types of shoes does Amazon sell?").message["content"]) + def _create_streamable_http_transport(headers=None): + url = {gatewayUrl} + access_token = {AccessToken} + headers = {**headers} if headers else {} + headers["Authorization"] = f"Bearer {access_token}" + return streamablehttp_client( + url, + headers=headers + ) + + def _get_bedrock_model(model_id): + return BedrockModel( + inference_profile_id=model_id, + temperature=0.0, + streaming=True, + ) + + mcp_client = MCPClient(_create_streamable_http_transport) + + if __name__ == "__main__": + user_prompt = "What all orders do I have?" + _response = _invoke_agent( + bedrock_model=_get_bedrock_model("us.anthropic.claude-sonnet-4-20250514-v1:0"), + mcp_client=mcp_client, + prompt=user_prompt + ) + print(_response) @@ -57,2 +76 @@ LangGraph - - model_id = "openai:gpt-4.1" + model = ChatBedrock(model_id="anthropic.claude-3-sonnet-20240229-v1:0", region_name="us-west-2") @@ -67 +85 @@ LangGraph - agent = create_react_agent(model_id, tools) + agent = create_react_agent(model, tools) @@ -96 +114 @@ Claude Code - echo "You can now use the server with: claude --mcp-server $SERVER_NAME" + echo "You can now check mcp server health with: claude mcp list"