From c2d17d667f1eef34d1a50d2617299a872c19e7d5 Mon Sep 17 00:00:00 2001 From: Abhimanyu Siwach Date: Mon, 12 Oct 2026 12:33:17 -0700 Subject: [PATCH] fix(bma): pass the Gateway to BMA as connector_id BMA rejects the Gateway tool that client.py sends with --gateway: 400 "Invalid 'agent.tools[0]': value is not valid under any of the schemas listed in the 'oneOf' keyword." The AWS mcp tool takes the Gateway ARN in connector_id. It has no transport field, and BMA removed the required field. - client.py sends {type, server_label, connector_id} and --gateway takes the Gateway ARN. - The extra input asks the agent to list the Gateway tools, so it works with any Gateway. - README.md tells the user to give the ARN, and that a Gateway that lists its MCP versions must include 2025-03-26. --- .../assets.snapshot.test.ts.snap | 22 ++++++------------- src/assets/python/http/bma/base/README.md | 5 +++-- src/assets/python/http/bma/base/client.py | 17 ++++---------- 3 files changed, 14 insertions(+), 30 deletions(-) diff --git a/src/assets/__tests__/__snapshots__/assets.snapshot.test.ts.snap b/src/assets/__tests__/__snapshots__/assets.snapshot.test.ts.snap index 4446b1e96..f40245524 100644 --- a/src/assets/__tests__/__snapshots__/assets.snapshot.test.ts.snap +++ b/src/assets/__tests__/__snapshots__/assets.snapshot.test.ts.snap @@ -4079,8 +4079,9 @@ new session and prints its ID. uv run client.py --runtime --session-id --input "List the files in the workspace." \`\`\` -If you add a Gateway, add \`--gateway \` with the URL from the output of \`agentcore deploy\`. BMA adds -the Gateway tools when it creates the session, so the flag has no effect on a session that exists. +If you add a Gateway, add \`--gateway \` with the ARN from the output of \`agentcore deploy\`. Use the +flag only for a new session. The Gateway must support MCP version \`2025-03-26\`. If it does not, the agent gets no Gateway +tools, and BMA does not show an error. To delete the session after the turn, add \`--delete\`. To print each stream event as JSON, add \`--raw\`. " @@ -4186,7 +4187,7 @@ def main() -> None: ) parser.add_argument( "--gateway", - help="The Gateway URL from the output of \`agentcore deploy\`.", + help="The Gateway ARN from the output of \`agentcore deploy\`.", ) parser.add_argument( "--role-arn", @@ -4240,20 +4241,11 @@ def main() -> None: "instructions": "Use the available tools to complete the task.", } if args.gateway: - # Bedrock Managed Agents calls Gateway with IAM from the service side. + # Bedrock Managed Agents calls Gateway with the session role from the service side. agent["tools"] = [ - { - "type": "mcp", - "server_label": "team_tools", - "required": True, - "connection_origin": "service", - "transport": {"type": "http", "server_url": args.gateway}, - } + {"type": "mcp", "server_label": "team_tools", "connector_id": args.gateway} ] - args.input += ( - " Then use the Gateway's documentation and runbook tools to explain" - " how to investigate an MCP connection failure. Cite your sources." - ) + args.input += " Then list the tools that the Gateway gives you." events = sessions.create( agent=agent, environment={ diff --git a/src/assets/python/http/bma/base/README.md b/src/assets/python/http/bma/base/README.md index 050536ff0..222992327 100644 --- a/src/assets/python/http/bma/base/README.md +++ b/src/assets/python/http/bma/base/README.md @@ -172,7 +172,8 @@ new session and prints its ID. uv run client.py --runtime --session-id --input "List the files in the workspace." ``` -If you add a Gateway, add `--gateway ` with the URL from the output of `agentcore deploy`. BMA adds -the Gateway tools when it creates the session, so the flag has no effect on a session that exists. +If you add a Gateway, add `--gateway ` with the ARN from the output of `agentcore deploy`. Use the +flag only for a new session. The Gateway must support MCP version `2025-03-26`. If it does not, the agent gets no Gateway +tools, and BMA does not show an error. To delete the session after the turn, add `--delete`. To print each stream event as JSON, add `--raw`. diff --git a/src/assets/python/http/bma/base/client.py b/src/assets/python/http/bma/base/client.py index 4eac97501..bfd831cd1 100644 --- a/src/assets/python/http/bma/base/client.py +++ b/src/assets/python/http/bma/base/client.py @@ -97,7 +97,7 @@ def main() -> None: ) parser.add_argument( "--gateway", - help="The Gateway URL from the output of `agentcore deploy`.", + help="The Gateway ARN from the output of `agentcore deploy`.", ) parser.add_argument( "--role-arn", @@ -151,20 +151,11 @@ def main() -> None: "instructions": "Use the available tools to complete the task.", } if args.gateway: - # Bedrock Managed Agents calls Gateway with IAM from the service side. + # Bedrock Managed Agents calls Gateway with the session role from the service side. agent["tools"] = [ - { - "type": "mcp", - "server_label": "team_tools", - "required": True, - "connection_origin": "service", - "transport": {"type": "http", "server_url": args.gateway}, - } + {"type": "mcp", "server_label": "team_tools", "connector_id": args.gateway} ] - args.input += ( - " Then use the Gateway's documentation and runbook tools to explain" - " how to investigate an MCP connection failure. Cite your sources." - ) + args.input += " Then list the tools that the Gateway gives you." events = sessions.create( agent=agent, environment={