Skip to main content
Glama
manifullstackdeveloper

Amazon Bedrock AgentCore MCP Gateway

MCP Server POC for Amazon Bedrock AgentCore

This POC demonstrates deployment and management of Model Context Protocol (MCP) servers on Amazon Bedrock AgentCore using the Gateway method.

Overview

The Model Context Protocol (MCP) provides a standardized interface for AI applications to access tools, resources, and enterprise data sources. This solution implements:

  • Gateway Method: Wraps existing Lambda functions or REST APIs as MCP tools, handling protocol translation automatically

  • MCP Server: Direct implementation using FastMCP framework

Architecture

┌─────────────────┐ │ Bedrock │ │ AgentCore │ └────────┬────────┘ │ ▼ ┌─────────────────┐ │ MCP Gateway │ ← Protocol Translation │ (Lambda) │ └────────┬────────┘ │ ┌────┴────┐ ▼ ▼ ┌────────┐ ┌────────┐ │Lambda │ │ REST │ │Functions│ │ APIs │ └────────┘ └────────┘

Components

  1. MCP Gateway (gateway/): Translates MCP protocol to Lambda/REST API calls

  2. MCP Server (server/): Direct MCP server implementation using FastMCP

  3. Example Tools (tools/): Sample Lambda functions and REST APIs

  4. Infrastructure (infrastructure/): AWS SAM templates for deployment

Prerequisites

  • Python 3.11+

  • AWS CLI configured

  • AWS SAM CLI installed

  • Docker (for local testing)

Quick Start

1. Install Dependencies

pip install -r requirements.txt

2. Deploy Infrastructure

Option A: Using AWS SAM (Recommended for beginners)

cd infrastructure sam build sam deploy --guided

Option B: Using Terraform

cd terraform cp terraform.tfvars.example terraform.tfvars # Edit terraform.tfvars with your values terraform init terraform plan terraform apply

See TERRAFORM_QUICKSTART.md for detailed Terraform deployment guide with Python dependencies layer configuration.

3. Test MCP Gateway

python test_gateway.py

Project Structure

mcp_1/ ├── gateway/ # MCP Gateway implementation │ ├── __init__.py │ ├── gateway.py # Main gateway handler │ └── protocol.py # MCP protocol translation ├── server/ # Direct MCP server │ ├── __init__.py │ └── mcp_server.py # FastMCP server ├── tools/ # Example tools │ ├── lambda_functions/ # Lambda functions as MCP tools │ └── rest_apis/ # REST API endpoints ├── infrastructure/ # AWS SAM deployment │ ├── template.yaml # SAM template │ └── README.md # SAM deployment guide ├── terraform/ # Terraform deployment │ ├── main.tf # Main Terraform configuration │ ├── variables.tf # Variable definitions │ ├── outputs.tf # Output values │ ├── versions.tf # Provider versions │ ├── README.md # Terraform deployment guide │ └── Makefile # Helper commands ├── TERRAFORM_QUICKSTART.md # Quick Terraform deployment guide ├── QUICKSTART.md # Local development quick start ├── tests/ # Test files ├── requirements.txt # Python dependencies └── README.md # This file

Gateway Method

The Gateway method automatically:

  • Translates MCP tool calls to Lambda invocations

  • Translates MCP tool calls to REST API requests

  • Handles authentication and error handling

  • Provides unified interface for multiple backends

Example Usage

Registering a Lambda Function as MCP Tool

from gateway.gateway import MCPGateway gateway = MCPGateway() gateway.register_lambda_tool( name="weather_lookup", lambda_arn="arn:aws:lambda:us-east-1:123456789:function:WeatherFunction", description="Get weather information for a location" )

Registering a REST API as MCP Tool

gateway.register_rest_tool( name="stock_price", endpoint="https://api.example.com/stock", method="GET", description="Get stock price information" )

Testing

Run the test suite:

pytest tests/

Test the gateway locally:

python -m gateway.gateway

Deployment

  • Terraform: See TERRAFORM_QUICKSTART.md for quick Terraform deployment (includes Python dependencies layer)

  • SAM: See DEPLOYMENT.md for detailed SAM deployment instructions

  • Terraform Details: See terraform/README.md for comprehensive Terraform guide

License

MIT

-
security - not tested
F
license - not found
-
quality - not tested

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/manifullstackdeveloper/gaab_mcp_poc'

If you have feedback or need assistance with the MCP directory API, please join our Discord server