DEV Community

Vadym Kazulkin for AWS Heroes

Posted on • Edited on

Amazon Bedrock AgentCore Gateway - Part 5 Adding API Gateway REST API as a target for Amazon Bedrock AgentCore Gateway

Introduction

In part 1 of this article series, we introduced Amazon Bedrock AgentCore and specifically Amazon Bedrock AgentCore Gateway, which transforms existing APIs and AWS Lambda functions into agent-ready tools, offering unified access across protocols, including into Model Context Protocol (MCP), and runtime discovery. In part 2 of the series, we used Amazon Bedrock AgentCore Gateway to convert the existing Amazon API Gateway REST API into MCP-compatible tools and made it available to agents through the Gateway endpoint. We also used Strands MCP Client to talk to this AgentCore Gateway endpoint. In the example, we extracted the Open API spec to transform the existing Amazon Gateway API REST API into MCP tools using Bedrock AgentCore Gateway, because AgentCore Gateway didn't support directly creating Amazon API Gateway REST API as a target as of the time of writing (only AWS Lambda was supported as an AWS internal service). This has now changed, and this feature is supported:

Let's explore it in detail.

Adding API Gateway REST API as a target for Amazon Bedrock AgentCore Gateway

Let's expose the same Amazon Gateway REST API as we did in part 2.

Let's focus on the part of creating an API Gateway REST API as a target type of AgentCore Gateway. We first need to give Target a name and optionally a description, and select the existing API Gateway API and the stage:

Then all existing API operations will be displayed:

We select both GET HTTP methods to expose them as MCP tools (as we did in part 2):

We are required to set a proper name (which will be the MCP tool name). The full tool name will be exposed as the AgentCore Gateway target name and "__" and our selected tool name, and is currently limited to 64 characters maximum. So, please carefully select both target and tool names as they are used by the search for the right MCP tool. Please also set a proper tool description:

Please review part 2 on how to set other parameters of the AgentCore Gateway as "API Key" of "Outbound Auth configurations" as they remain completely the same.

Before you create the AgentCore Gateway, make sure that each of your Amazon API Gateway operations/resources has at least one method response like this:

It even concerns operations that you don't want to expose as MCP tools. Otherwise, I've got an error message when creating an AgentCore Gateway target that the Open API specification couldn’t be extracted from the Amazon API Gateway API because the path element didn't contain response(s) value. All such operations are listed in the error message:

After having created the API Gateway REST API as a target for the Amazon Bedrock AgentCore Gateway, the target itself looks like this:

Conclusion

In this article, we explored how to create an Amazon API Gateway REST API as a target for the Amazon Bedrock AgentCore Gateway. I think it's a good add-on to the other target types as it allows us to create this target type much quicker without extracting the Open API specification of the API Gateway REST API. You can find more information about this feature in the official article Add an API Gateway REST API as a target for Amazon Bedrock AgentCore Gateway.

Top comments (0)