Adding AWS DevOps Agent as an MCP Tool to an AgentCore AI Agent
This document shows how to give an Amazon Bedrock AgentCore AI agent the ability to call AWS DevOps Agent (chat, incident investigation, root-cause findings, mitigation recommendations) as a set of MCP tools, wired through an AgentCore Gateway with a Lambda MCP target. The pattern in one sentence: the agent speaks MCP to a Gateway, the Gateway forwards `tools/call` invocations to a Lambda function, and the Lambda calls AWS DevOps Agent's API via boto3 and hands back a clean, model-ready result.
1. What This Covers
Scope: this document covers the Gateway + Lambda MCP target pattern only. AWS
DevOps Agent also supports direct Agent-to-Agent (A2A) delegation from an agent — that
integration pattern will be covered in a separate document.
Reference implementation — every code snippet below is drawn from this path:
Concern | Path |
|---|---|
Lambda MCP server (the bridge) | lambda-mcp-server/src/app.py |
Lambda infra (SAM) | lambda-mcp-server/template.yaml |
Gateway + target provisioning | lambda-mcp-server/deploy.sh |
Tool schema exposed to the Gateway | lambda-mcp-server/tool-schema.json |
AgentCore agent runtime (the consumer) | lambda-mcp-server/agent/devopsagent/app/*/main.py |
Agent → Gateway MCP client wiring | lambda-mcp-server/agent/devopsagent/app/*/mcp_client/client.py |
Declarative agent/gateway config | lambda-mcp-server/agent/devopsagent/agentcore/agentcore.json |
Security note: every account ID, ARN, role name, and identifier in this document is a placeholder (<AWS_ACCOUNT_ID>,<GATEWAY_ID>, etc.) — replace with your own at deploy time. Apply your organization's normal security review to the roles and policies this pattern creates before rolling it out — for example, run the AWS Security Agent (or your internal equivalent) over the generated IAM roles, resource policies, and Lambda configuration as part of that review.
2. Architecture
Every call from the agent to AWS DevOps Agent crosses three hops, each authenticated and
authorized independently:
┌───────────────────────────────────────────────────────────────────┐│ AgentCore AI Agent (Strands agent on AgentCore Runtime) ││ main.py + mcp_client/client.py ││ Role: <AGENT_RUNTIME_ROLE> │└──────────────────────────────┬──────────────────────────────────────┘ │ MCP over Streamable HTTP │ SigV4-signed (service: bedrock-agentcore) ▼┌───────────────────────────────────────────────────────────────────┐│ AgentCore Gateway (protocolType=MCP, authorizerType=AWS_IAM) ││ Lambda target + registered tool schema ││ Role: <GATEWAY_ROLE> │└──────────────────────────────┬──────────────────────────────────────┘ │ lambda:InvokeFunction │ (Gateway's own IAM role — GATEWAY_IAM_ROLE) ▼┌───────────────────────────────────────────────────────────────────┐│ Lambda: devops-agent-mcp-server (private — no Function URL) ││ src/app.py — MCP tool dispatch + response processing ││ Role: <LAMBDA_EXECUTION_ROLE> │└──────────────────────────────┬──────────────────────────────────────┘ │ boto3 devops-agent client │ (aidevops:* IAM actions) ▼┌───────────────────────────────────────────────────────────────────┐│ AWS DevOps Agent (managed service) ││ AgentSpace, investigations, chat, recommendations │└───────────────────────────────────────────────────────────────────┘Each hop has its own trust boundary and its own IAM principal. No single credential
spans the whole chain — that's what makes the pattern safe to run with least-privilege
roles at every layer (see Section 8 ).
2. Why Put a Lambda Behind the Gateway
AgentCore Gateway can front several kinds of targets: an OpenAPI schema, a Smithy
model, another MCP server, or a Lambda function. A schema-based or
mcpServer target
works well when the underlying API's responses are already shaped for a model to
consume directly. Concretely, this Lambda does four jobs that a passthrough target can't:- Response shaping.
send_messagereturns a one-shot botocoreEventStreamof streaming deltas, not text. Something has to drain it into a clean string before a model can use it as a tool result — see 5.3 .
- Call collapsing. Asking DevOps Agent a question is natively two API calls
(
create_chat, thensend_message). The Lambda'schattool performs both and returns a singleanswerfield, so the agent's model spends one tool call instead of orchestrating two round-trips itself — see 5.4 .
- Error normalization. A raw boto3 exception thrown mid-invocation can surface as an
opaque Gateway/MCP error. The Lambda catches it and returns a small, consistent
{error, message}shape instead — see 5.2 .
None of this needs a heavyweight function: the reference Lambda is roughly 300 lines of
Python with zero pip dependencies (boto3 ships in the Lambda runtime already).
4. Discovering DevOps Agent's Native MCP Tool Schema
Before writing
tool-schema.json , fetch what DevOps Agent already exposes on its own
hosted MCP endpoint — that's the raw material you curate, rename, or collapse into the
Lambda's tool set.Use
awscurl , a curl-like tool that handles AWS SigV4 signing automatically using your local credentials (profile, SSO session, or env vars):pip install awscurl
awscurl --service aidevops --region <AWS_REGION> \ -X POST \ -H "Content-Type: application/json" \ -d '{"jsonrpc":"2.0","id":1,"method":"tools/list","params":{}}' \ "https://connect.aidevops.<AWS_REGION>.api.aws/mcp"The response is a JSON-RPC result containing an array of
{name, description, inputSchema} objects— the exact shape a Gateway target's toolSchema.inlinePayload expects. DevOps Agent currently exposes 30+ tools covering chat, investigations, recommendations, release testing, access tokens, and more. tool-schema.json in this code curates that full surface down to 11 tools focused on chat, investigations, and recommendations (the full list is in 5.6 ); you can expose more or fewer depending on what you want the agent to reach.After you deploy your own Gateway (Section 6), repeat this call against the Gateway's own
/mcp endpoint — signed for bedrock-agentcore instead of aidevops — to confirm it's actually serving the schema you registered. That verification step is in Section 10 .
5. Building the Lambda MCP Server
The Lambda is the only custom code in the whole chain. It has no public URL — it can only be invoked by
bedrock-agentcore.amazonaws.com , and only through the specific Gateway that owns it as a target (locked down in 6.3 ).5.1 Tool registration — a decorator, not an SDK
Every tool is registered with a small decorator instead of pulling in the MCP SDK or pydantic, which is what keeps the Lambda dependency-free:
TOOLS = {}
def tool(name, description, params_schema): """Decorator to register a tool.""" def decorator(fn): TOOLS[name] = { "function": fn, "description": description, "inputSchema": {"type": "object", "properties": params_schema}, } return fn return decorator5.2 Connecting to DevOps Agent: the boto3 bridge and error normalization
A single boto3 client, created once per warm container and reused across invocations, is the entire bridge to DevOps Agent — no third-party SDK required.
api_call() is the one choke point every tool function calls through: it strips the ResponseMetadata block the model never needs, and turns any exception into a small, consistent JSON shape instead of letting a raw stack trace surface as an opaque Gateway error. serialize() exists because DevOps Agent responses contain datetime and bytes fields that json.dumps can't handle on its own:import osimport boto3from datetime import datetime
REGION = os.environ.get("DEVOPS_AGENT_REGION", "us-east-1")SPACE_ID = os.environ.get("DEVOPS_AGENT_SPACE_ID", "") # set at deploy timeUSER_ID = os.environ.get("DEVOPS_AGENT_USER_ID", "Admin")
client = boto3.client("devops-agent", region_name=REGION)
def serialize(obj): if isinstance(obj, datetime): return obj.isoformat() if isinstance(obj, bytes): return obj.decode("utf-8", errors="replace") raise TypeError(f"Not serializable: {type(obj)}")
def api_call(fn, **kwargs): """Call a boto3 devops-agent method and return a plain, model-friendly dict.""" call_kwargs = {k: v for k, v in kwargs.items() if v is not None} try: resp = fn(**call_kwargs) resp.pop("ResponseMetadata", None) return resp except Exception as e: return {"error": type(e).__name__, "message": str(e)}
def get_space_id(params): return params.get("agent_space_id") or SPACE_IDget_space_id() is the deployment-time control point mentioned in Section 3: the agent doesn't need to know the AgentSpace ID at all — it's baked into the Lambda's environment at deploy time, with a per-call override available for multi-space setups.5.3 Response shaping: draining the event stream
DevOps Agent's
send_message API doesn't return plain text — it returns events , a botocore EventStream : a one-shot iterable of low-level streaming deltas ( content_block_delta , output_text_delta , and others). It cannot be indexed, len() 'd, or iterated twice. If a Gateway tool result passed this straight through, the calling agent's model would receive dozens of small JSON fragments as a single tool result and have to reconstruct the answer itself. This helper drains the stream exactly once and concatenates the text deltas into one clean string:def _consume_event_stream(events): """Consume a botocore EventStream (send_message's 'events' field) once.
An EventStream is a one-shot iterable — it cannot be len()'d, indexed, or iterated twice. We fully drain it here. """ parts = [] if events is None: return parts
for event in events: for event_type, payload in event.items(): if not isinstance(payload, dict): continue if event_type in ("content_block_delta", "contentBlockDelta"): delta = payload.get("delta", {}) text = (delta.get("textDelta") or delta.get("text_delta") or {}).get("text") if text: parts.append(text) return parts5.4 Call collapsing: the chat tool
Asking DevOps Agent a question is natively a two-call sequence:
create_chat to open a session, then send_message to get an answer. The chat tool performs both internally and returns a single answer field, using the two helpers from above:@tool("chat", "Ask the DevOps Agent a quick question. Returns the answer in one call.", { "message": {"type": "string", "description": "Your question"},})def chat(params): space_id = get_space_id(params) chat_resp = client.create_chat(agentSpaceId=space_id, userId=USER_ID) execution_id = chat_resp["executionId"]
resp = client.send_message( agentSpaceId=space_id, executionId=execution_id, content=params["message"], userId=USER_ID, ) parts = _consume_event_stream(resp.get("events")) return {"executionId": execution_id, "answer": "".join(parts) or "(no response)"}5.5 The investigation lifecycle: create_investigation → get_task → list_journal_records
Investigations are asynchronous — you start one, poll it, then read the findings once
DevOps Agent marks it
COMPLETED . Each step is a thin, direct call through api_call() :@tool("create_investigation", "Start an investigation for an operational incident.", { "title": {"type": "string", "description": "Issue description (max 400 chars)"}, "priority": {"type": "string", "description": "CRITICAL, HIGH, MEDIUM, LOW"},})def create_investigation(params): return api_call( client.create_backlog_task, agentSpaceId=get_space_id(params), taskType="INVESTIGATION", title=params["title"], priority=params.get("priority", "HIGH"), )
@tool("get_task", "Check status of an investigation. Poll until COMPLETED.", { "task_id": {"type": "string", "description": "Task ID from create_investigation"},})def get_task(params): return api_call( client.get_backlog_task, agentSpaceId=get_space_id(params), taskId=params["task_id"], )
@tool("list_journal_records", "Read investigation findings and root cause analysis.", { "execution_id": {"type": "string", "description": "Execution ID from get_task"},})def list_journal_records(params): return api_call( client.list_journal_records, agentSpaceId=get_space_id(params), executionId=params["execution_id"], order="ASC", )5.6 The full tool set
The same pattern (
@tool decorator + api_call() ) covers all 11 tools registered by this Lambda — this is the curated schema referenced in Section 2 and fetched natively in Section 4:Tool | Purpose |
|---|---|
list_agent_spaces , get_agent_space , list_associations | Discovery — enumerate AgentSpaces and connected services |
create_investigation , get_task , list_tasks | Start and track incident investigations |
list_journal_records | Read root-cause findings from a completed investigation |
list_recommendations , get_recommendation | Retrieve mitigation suggestions |
chat , send_message | Real-time Q&A, single call or multi-turn |
The exact schema the Gateway target needs (
tool-schema.json ) is generated straight
from these definitions:[ { "name": "chat", "description": "Ask the DevOps Agent a quick question. Returns answer in one call.", "inputSchema": { "type": "object", "properties": { "message": { "type": "string", "description": "Your question" } }, "required": ["message"] } }, { "name": "create_investigation", "description": "Start an investigation for an operational incident.", "inputSchema": { "type": "object", "properties": { "title": { "type": "string", "description": "Issue description (max 400 chars)" }, "priority": { "type": "string", "description": "CRITICAL, HIGH, MEDIUM, LOW" }, "description": { "type": "string", "description": "Detailed context" } }, "required": ["title"] } } /* ... the remaining 9 tools follow the same {name, description, inputSchema} shape — see lambda-mcp-server/tool-schema.json in this repo for the complete file. */]5.7 Dispatch: routing a Gateway invocation to the right tool
AgentCore Gateway invokes a Lambda target with the tool's raw arguments as the event payload — not a JSON-RPC envelope — and identifies which tool to run via
context.client_context.custom['bedrockAgentCoreToolName'] , formatted as
"<targetName>___<toolName>" . The handler extracts that name and falls back to plain JSON-RPC when there's no gateway context at all, which is exactly what a Lambda console test event looks like:def _get_gateway_tool_name(context): try: custom = context.client_context.custom except AttributeError: return None if not custom: return None full_name = custom.get("bedrockAgentCoreToolName") if not full_name: return None return full_name.split("___", 1)[1] if "___" in full_name else full_name
def lambda_handler(event, context): gateway_tool_name = _get_gateway_tool_name(context) if gateway_tool_name is not None: # AgentCore Gateway path: event == raw tool arguments if gateway_tool_name not in TOOLS: return {"content": [{"type": "text", "text": f"Unknown tool: {gateway_tool_name}"}], "isError": True} result = TOOLS[gateway_tool_name]["function"](event) return {"content": [{"type": "text", "text": json.dumps(result, default=serialize, indent=2)}]}
# Fallback path: plain JSON-RPC 2.0 (manual/console testing) handler = MCP_HANDLERS.get(event.get("method", "")) result = handler(event.get("params", {})) return {"jsonrpc": "2.0", "result": result, "id": event.get("id")}(The deployed handler also tolerates an HTTP-wrapped
body field, for testing through an API Gateway or Function URL-style event — not used by this template, since the Lambda has no public endpoint. See src/app.py for the complete version.)5.8 Lambda infrastructure (SAM)
The essentials of
template.yaml : a private function with no Function URL, scoped to aidevops:* , plus the resource policy that lets only AgentCore Gateway invoke it:DevOpsAgentMcpFunction: Type: AWS::Serverless::Function Properties: FunctionName: devops-agent-mcp-server CodeUri: src/ Handler: app.lambda_handler Runtime: python3.12 MemorySize: 256 Timeout: 300 Environment: Variables: DEVOPS_AGENT_REGION: !Ref DevOpsAgentRegion DEVOPS_AGENT_SPACE_ID: !Ref DevOpsAgentSpaceId DEVOPS_AGENT_USER_ID: !Ref DevOpsAgentUserId Policies: - Statement: - Effect: Allow Action: aidevops:* Resource: '*'
AgentCoreLambdaPermission: Type: AWS::Lambda::Permission Properties: FunctionName: !Ref DevOpsAgentMcpFunction Action: lambda:InvokeFunction Principal: bedrock-agentcore.amazonaws.com
6. Registering the Lambda as a Gateway Target
The Gateway is the managed MCP endpoint the agent talks to. It authenticates the caller, enforces which tools exist, and forwards
tools/call invocations to the Lambda target using its own IAM role — the agent itself never gets Lambda-invoke rights.6.1 Create the Gateway
aws bedrock-agentcore-control create-gateway \ --name "devops-agent-gateway" \ --protocol-type MCP \ --authorizer-type AWS_IAM \ --role-arn "arn:aws:iam::<AWS_ACCOUNT_ID>:role/<GATEWAY_ROLE_NAME>" \ --region <AWS_REGION>The Gateway's role needs only enough permission to invoke the one target Lambda:
{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": "lambda:InvokeFunction", "Resource": "arn:aws:lambda:<AWS_REGION>:<AWS_ACCOUNT_ID>:function:devops-agent-mcp-server" } ]}6.2 Register the Lambda as a target, with the tool schema
aws bedrock-agentcore-control create-gateway-target \ --gateway-identifier "<GATEWAY_ID>" \ --name "devops-mcp-lambda-target" \ --target-configuration '{ "mcp": { "lambda": { "lambdaArn": "arn:aws:lambda:<AWS_REGION>:<AWS_ACCOUNT_ID>:function:devops-agent-mcp-server", "toolSchema": { "inlinePayload": <contents of tool-schema.json> } } } }' \ --credential-provider-configurations '[{"credentialProviderType": "GATEWAY_IAM_ROLE"}]' \ --region <AWS_REGION>credentialProviderType: GATEWAY_IAM_ROLE means the Gateway signs the Lambda invocation with its own role — this is what removes any need for Lambda-invoke permissions on the calling agent.6.3 Lock the Lambda's resource policy to this Gateway only
Granting the
bedrock-agentcore.amazonaws.com service principal alone would let any Gateway in the account invoke this function. Pin it to this specific Gateway's ARN with --source-arn :aws lambda add-permission \ --function-name devops-agent-mcp-server \ --statement-id AllowAgentCoreGatewayInvoke \ --action lambda:InvokeFunction \ --principal bedrock-agentcore.amazonaws.com \ --source-arn "arn:aws:bedrock-agentcore:<AWS_REGION>:<AWS_ACCOUNT_ID>:gateway/<GATEWAY_ID>" \ --region <AWS_REGION>lambda-mcp-server/deploy.sh in this repo automates 6.1–6.3 end to end, idempotently — it detects and reuses an existing Gateway/target by name, and re-runs the add-permission grant scoped to whatever Gateway ARN it just created or found.
7. Connecting the AgentCore AI Agent to the Gateway
This is the piece that closes the loop: the agent runtime treats the Gateway as just another MCP server and adds it directly as a tool source. The Strands framework calls
tools/list and tools/call over that MCP session automatically — there's no custom protocol code inside the agent itself.7.1 Declaring the connection
AgentCore's declarative config links the runtime to the Gateway. At deploy time, AgentCore injects the Gateway's URL into the runtime as an environment variable derived from the connection's resource name, and
outboundAuth: { awsIam: {} } tells it to sign outbound calls with the runtime's own execution role — no static credentials involved:{ "runtimes": [ { "name": "DevOpsAssistantAgent", "build": "CodeZip", "entrypoint": "main.py", "codeLocation": "app/DevOpsAssistantAgent/", "runtimeVersion": "PYTHON_3_14", "networkMode": "PUBLIC", "protocol": "HTTP", "connections": [ { "id": "gateway-devops-agent-gateway", "to": { "type": "gateway", "arn": "arn:aws:bedrock-agentcore:<AWS_REGION>:<AWS_ACCOUNT_ID>:gateway/<GATEWAY_ID>", "outboundAuth": { "awsIam": {} } } } ] } ]}(The reference
agentcore.json also wires a memory resource on this same runtime — unrelated to the Gateway connection, omitted here for clarity.)7.2 Building the MCP client
AgentCore names the generated environment variable
GATEWAY_<CONNECTION_ID_UPPER>_URL . Since the connection id itself starts with gateway-... , the variable ends up containing "GATEWAY" twice (e.g. GATEWAY_GATEWAY_DEVOPS_AGENT_GATEWAY_<SUFFIX>_URL ) — that's expected, not a typo. The client module reads that variable and builds a SigV4-signed streamable-HTTP MCP client using
mcp-proxy-for-aws as a library — the same signing helper AWS ships for local MCP proxying, used here directly in code instead of as a CLI process:import osfrom mcp_proxy_for_aws.client import aws_iam_streamablehttp_clientfrom strands.tools.mcp.mcp_client import MCPClient
def get_devops_agent_gateway_mcp_client() -> MCPClient | None: """Returns an MCP client connected to the DevOps Agent AgentCore Gateway.""" url = os.environ.get("GATEWAY_DEVOPS_AGENT_GATEWAY_URL") if not url: return None return MCPClient( lambda: aws_iam_streamablehttp_client( url, aws_service="bedrock-agentcore", aws_region=os.environ.get("AWS_REGION"), ), prefix="devops_agent_gateway", )
def get_all_gateway_mcp_clients() -> list[MCPClient]: clients = [] client = get_devops_agent_gateway_mcp_client() if client: clients.append(client) return clientsNote
aws_service="bedrock-agentcore" — this signs requests to the Gateway's endpoint. It's a separate signing step from the Lambda's own outbound calls to DevOps Agent ( aidevops service), which happen one hop later and are invisible to the agent.7.3 Wiring the MCP client into the agent
MCPClient instances from the Strands SDK go straight into an agent's tools list — the framework discovers and exposes every tool from tool-schema.json to the model at startup:from strands import Agentfrom bedrock_agentcore.runtime import BedrockAgentCoreApp
from model.load import load_modelfrom mcp_client.client import get_all_gateway_mcp_clients
app = BedrockAgentCoreApp()
SYSTEM_PROMPT = """You are an AWS operations assistant. For any AWS cost,architecture, incident, or investigation question, use the DevOps Agenttools available to you rather than answering from memory."""
tools = [c for c in get_all_gateway_mcp_clients() if c]
agent = Agent(model=load_model(), system_prompt=SYSTEM_PROMPT, tools=tools)
@app.entrypointasync def invoke(payload, context): prompt = payload.get("prompt", "") async for event in agent.stream_async(prompt): yield event
if __name__ == "__main__": app.run()The production
main.py in this repo additionally wires in conversation memory, iteration/timeout guards, and a couple of local dev-only tools ( shell , file_operations ) — orthogonal to the DevOps Agent connection and omitted here for clarity.Finally, the model loader — Bedrock via the runtime's own IAM role, no API keys stored anywhere:
from strands.models.bedrock import BedrockModel
def load_model() -> BedrockModel: return BedrockModel(model_id="<BEDROCK_MODEL_ID>")
8. IAM / Security Model
Hop | Principal | Permission needed | Scope |
|---|---|---|---|
Agent → Gateway | AgentCore Runtime execution role ( <AGENT_RUNTIME_ROLE> ) | bedrock-agentcore:InvokeGateway | Single Gateway ARN |
Gateway (inbound) | Gateway authorizerType: AWS_IAM | Validates the caller's SigV4 identity | Enforced by the Gateway |
Gateway → Lambda | Gateway's own role ( <GATEWAY_ROLE_NAME> ), via GATEWAY_IAM_ROLE credential provider | lambda:InvokeFunction | Single Lambda ARN |
Lambda (inbound) | Lambda resource policy | Principal bedrock-agentcore.amazonaws.com | --source-arn pinned to the specific Gateway ARN |
Lambda → DevOps Agent | Lambda execution role ( <LAMBDA_EXECUTION_ROLE> ) | aidevops:* (or narrower) | Account-wide DevOps Agent API |
Network | Lambda | No Function URL, no public endpoint | Only reachable via lambda:InvokeFunction |
Hardening notes:
- No single credential spans more than one hop — the agent never holds Lambda-invoke rights; the Gateway never holds
aidevops:*; the Lambda never holds Gateway-invoke rights.
- Scope
aidevops:*down where practical — e.g. a read-only set (aidevops:List*,aidevops:Get*) for discovery/chat tools, separated from the set backingcreate_investigation/create_chat/send_message.
- Pin the Lambda's resource policy
--source-arnto the Gateway ARN, not just the service principal.
- Responses from
chat/send_messageare plain extracted text — the Lambda never passes through function-call or tool-use blocks from DevOps Agent's stream, so nothing embedded in a response can trigger unintended tool execution. Still, treat any commands or scripts appearing in that text as untrusted output requiring human review before running them.
- Run a security review over the roles and policies this pattern creates before deploying — see the note in Section 1 .
9. Deployment Walkthrough
- Deploy the Lambda (SAM build + deploy) — creates the function, its execution role (
aidevops:*), and CloudWatch log group. No public endpoint is created.
- Create the AgentCore Gateway with
protocolType=MCP,authorizerType=AWS_IAM, using a role scoped to invoke only this Lambda ( 6.1 ).
- Grant the Lambda resource policy to the specific Gateway ARN ( 6.3 ).
- Create the Gateway target, pointing at the Lambda ARN, uploading
tool-schema.jsonas the inline tool schema, withGATEWAY_IAM_ROLEas the credential provider ( 6.2 ).
- Add the
connectionsentry in the AgentCore agent'sagentcore.json, referencing the Gateway ARN withoutboundAuth: { awsIam: {} }( 7.1 ).
- Grant the agent's runtime execution role
bedrock-agentcore:InvokeGatewayon that Gateway ARN.
- Deploy the agent (
agentcore deploy) — AgentCore injects theGATEWAY_..._URLenvironment variable into the runtime automatically.
- Invoke and verify ( Section 10 ).
10. Testing & Verification
Lambda in isolation — bypasses the Gateway, direct JSON-RPC via the Lambda console
test event:
{ "jsonrpc": "2.0", "id": 1, "method": "tools/list", "params": {} }Gateway + Lambda target, without the agent — the same discovery call from Section 4, now pointed at the Gateway's own endpoint and signed for
bedrock-agentcore instead of aidevops , to confirm the tools you registered are actually being served:awscurl --service bedrock-agentcore --region <AWS_REGION> \ -X POST \ -H "Content-Type: application/json" \ -d '{"jsonrpc":"2.0","id":1,"method":"tools/list","params":{}}' \ "<GATEWAY_URL>/mcp"This matches AWS's documented approach for listing Gateway tools : a
POST to <GatewayEndpoint>/mcp with tools/list as the method and a signed Authorization header — curl --aws-sigv4 just generates that header for you.Gateway + Lambda target, from a real MCP client — useful for a quick end-to-end check before wiring up the agent, using the same
AWS_IAM signing the agent uses in production:{ "mcpServers": { "devops-agent-gateway": { "command": "uvx", "args": ["mcp-proxy-for-aws@latest", "<GATEWAY_URL>", "--service", "bedrock-agentcore", "--region", "<AWS_REGION>"] } }}Full path via the deployed agent:
agentcore invoke --agent DevOpsAssistantAgent \ --payload '{"prompt": "What are my top 3 AWS cost drivers this month?"}'A successful response streams back model output that includes an answer sourced from the
chat tool call — confirming all three hops (agent → gateway → lambda, with the Lambda's own call into DevOps Agent) are wired correctly.
11. Troubleshooting
Symptom | Likely cause | Fix |
|---|---|---|
Gateway target status FAILED | Malformed tool-schema.json or unreachable Lambda ARN | get-gateway-target for the failure reason; validate schema against the shape from Section 4 |
Agent gets AccessDenied calling the Gateway | Runtime role missing bedrock-agentcore:InvokeGateway on the Gateway ARN | Add the policy statement scoped to the Gateway ARN |
Lambda never receives Gateway invocations | Resource policy --source-arn doesn't match the Gateway ARN, or Gateway role lacks lambda:InvokeFunction | Re-run add-permission with the correct Gateway ARN; check the Gateway role policy |
Tool returns "Unknown tool: <name>" | Tool name in tool-schema.json doesn't match a key in the Lambda's TOOLS dict | Ensure names match exactly (case-sensitive) on both sides |
chat / send_message return (no response) | DevOps Agent's event stream shape changed, or agent_space_id unresolved | Check Lambda logs for the raw events; confirm DEVOPS_AGENT_SPACE_ID is set or passed per-call |
Investigation never reaches COMPLETED | Investigations take 5–8 minutes; polling too infrequently or timing out early | Poll get_task every 30–45s; allow up to ~10 minutes before treating as stuck |
References
AWS DevOps Agent also supports direct Agent-to-Agent (A2A) integration from an agent —
that pattern will be covered in a separate document.
Enjoyed reading this content? Let the author know!
Your likes, comments, shares, and saves help creators reach more builders.
Loading recommendations
Loading article