Amazon Bedrock AgentCore is in preview release and is subject to change.
Testing your gateway
After creating a gateway and adding targets, you can test it using the MCP protocol.
Testing your gateway using Python
The following examples show how to test your gateway using Python.
import requests import json def list_tools(gateway_url): """List all tools available in the gateway.""" headers = { "Content-Type": "application/json" } payload = { "jsonrpc": "2.0", "id": "list-tools-request", "method": "tools/list" } response = requests.post(gateway_url, headers=headers, json=payload) return response.json() def search_tools(gateway_url, query): """Search for tools based on a query.""" headers = { "Content-Type": "application/json" } payload = { "jsonrpc": "2.0", "id": "search-tools-request", "method": "tools/call", "params": { "name": "x_amz_bedrock_agentcore_search", "arguments": { "query": query } } } response = requests.post(gateway_url, headers=headers, json=payload) return response.json() def call_tool(gateway_url, tool_name, arguments): """Call a specific tool with arguments.""" headers = { "Content-Type": "application/json" } payload = { "jsonrpc": "2.0", "id": "call-tool-request", "method": "tools/call", "params": { "name": tool_name, "arguments": arguments } } response = requests.post(gateway_url, headers=headers, json=payload) return response.json() # Example usage gateway_url = "https://example-gateway-url.amazonaws.com" # List all tools tools_response = list_tools(gateway_url) print(f"Available tools: {json.dumps(tools_response, indent=2)}") # Search for tools related to orders search_response = search_tools(gateway_url, "find order information") print(f"Relevant tools: {json.dumps(search_response, indent=2)}") # Call the order status tool order_response = call_tool( gateway_url=gateway_url, tool_name="getOrderStatus", arguments={ "orderId": "ORD-12345-67890", "customerId": "CUST-98765" } ) print(f"Order status: {json.dumps(order_response, indent=2)}")
Monitoring gateway usage
Gateway emits metrics to CloudWatch, allowing you to monitor its usage and performance. These metrics include:
-
Total invocations: The number of tool invocations
-
Invocations by target type: The number of invocations by target type (Lambda, OpenAPI, Smithy)
-
Invocations by authentication type: The number of invocations by authentication type
-
Error count: The number of errors, broken down by user errors and system errors
-
Throttle errors: The number of throttle errors
-
Latency: The latency of tool invocations, broken down by overall request latency and target execution latency
To view these metrics, go to the CloudWatch console in the account that owns the gateway resources. Navigate to Metrics → All Metrics and look for the Amazon Bedrock AgentCore namespace.
For more information, see Assess Gateway performance using monitoring and observability.