Sponsored by Deepsite.site

AWS Bedrock MCP Client and Server

Created By
sverze6 months ago
AWS API/lambda hosting MCP client server that queries bedrock LLM using MCP hosted tools
Content

AWS Bedrock MCP Client and Server

A Spring Boot application that serves as a client for the Model Context Protocol (MCP), enabling interaction with Amazon Bedrock AI models with tool-using capabilities.

Application Overview

This application provides a REST API for:

  • Communicating with Amazon Bedrock models
  • Using MCP tools for calculations, weather information, and web page retrieval
  • Handling complex AI queries that might require multiple tools
  • The application runs as an AWS Lambda function behind API Gateway, making it serverless and scalable.

Prerequisites

  • Java 21 or later
  • Maven 3.8+
  • AWS CLI configured with appropriate credentials
  • AWS CDK installed (npm install -g aws-cdk)
  • Weather API key from https://www.weatherapi.com/my/

Environment Setup

Clone the Repository

git clone https://github.com/sverze/aws-bedrock-mcp-client-server
cd aws-bedrock-mcp-client-server

Configure AWS

You will credentials that has priviledges to the following services

  • Lambda
  • API Gateway
  • Bedrock
  • Bedrock Model Anthropic Sonnet 4.0

To configure local credentials run the following command:

aws configure

###Building the Application

The project follows a multi-module Maven structure. To build all modules run this from the parent directory:

mvn clean package install -DWEATHER_API_KEY=<your_api_key_here>

This will build all modules in the correct order:

  • aws-bedrock-mcp-server
  • aws-bedrock-mcp-client
  • aws-bedrock-mcp-client-server-cdk

Deploying to AWS

The AWS deployment is managed using AWS CDK. To deploy the application, run the following commands:

cd aws-bedrock-mcp-client-server-cdk
cdk bootstrap
cdk deploy --context WEATHER_API_KEY=<your_api_key_here>

After deployment completes, CDK will output the API Gateway URL in the terminal. You will need this URL to interact with the API and perform the tests below.

Testing the API

Once deployed, you can test the API endpoints using curl or a tool like Postman:

  1. Test the Hello World endpoint

    curl https://<your-api-id>.execute-api.<region>.amazonaws.com/prod/hello
    

    Expected response: Hello World from MCP Client!

  2. List available tools

    curl https://<your-api-id>.execute-api.<region>.amazonaws.com/prod/tools
    
  3. Perform a calculation

    curl -X POST "https://<your-api-id>.execute-api.<region>.amazonaws.com/prod/calculate?operation=add&a=5&b=3"
    
  4. Get weather information

    curl -X POST "https://<your-api-id>.execute-api.<region>.amazonaws.com/prod/weather?location=New%20York&format=celsius"
    
  5. Convert a web page to markdown

    curl -X POST "https://<your-api-id>.execute-api.<region>.amazonaws.com/prod/webpage?url=https://example.com"
    
  6. Make a complex query - The Weather

    curl -X POST "https://<your-api-id>.execute-api.<region>.amazonaws.com/prod/query?query=What%20is%20the%20weather%20in%20London%20and%20calculate%2045%20divided%20by%209"
    
  7. Make a complex query - Summarise a Webpage

    curl -X POST "https://<your-api-id>.execute-api.<region>.amazonaws.com/prod/query?query=Summarise%20the%20following%20webpage%20https://example.com"
    

Monitoring and Logs

View application logs in CloudWatch Logs:

  • Navigate to AWS CloudWatch console
  • Check the /aws/lambda/McpClientServerFunction log group

Clean Up

To remove all deployed resources:

cd aws-bedrock-mcp-client-server-cdk
cdk destroy

Architecture

This application implements a serverless architecture:

  • API Gateway serves as the HTTP endpoint
  • AWS Lambda runs the Spring Boot application
  • Amazon Bedrock provides the AI model capabilities
  • MCP Server provides tool implementations
  • The AWS CDK stack creates and configures all the necessary AWS resources, including IAM roles with appropriate permissions for accessing Amazon Bedrock.
Recommend Servers
TraeBuild with Free GPT-4.1 & Claude 3.7. Fully MCP-Ready.
Zhipu Web SearchZhipu Web Search MCP Server is a search engine specifically designed for large models. It integrates four search engines, allowing users to flexibly compare and switch between them. Building upon the web crawling and ranking capabilities of traditional search engines, it enhances intent recognition capabilities, returning results more suitable for large model processing (such as webpage titles, URLs, summaries, site names, site icons, etc.). This helps AI applications achieve "dynamic knowledge acquisition" and "precise scenario adaptation" capabilities.
Visual Studio Code - Open Source ("Code - OSS")Visual Studio Code
EdgeOne Pages MCPAn MCP service designed for deploying HTML content to EdgeOne Pages and obtaining an accessible public URL.
TimeA Model Context Protocol server that provides time and timezone conversion capabilities. This server enables LLMs to get current time information and perform timezone conversions using IANA timezone names, with automatic system timezone detection.
Jina AI MCP ToolsA Model Context Protocol (MCP) server that integrates with Jina AI Search Foundation APIs.
Baidu Map百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
AiimagemultistyleA Model Context Protocol (MCP) server for image generation and manipulation using fal.ai's Stable Diffusion model.
Amap Maps高德地图官方 MCP Server
DeepChatYour AI Partner on Desktop
Playwright McpPlaywright MCP server
MiniMax MCPOfficial MiniMax Model Context Protocol (MCP) server that enables interaction with powerful Text to Speech, image generation and video generation APIs.
Howtocook Mcp基于Anduin2017 / HowToCook (程序员在家做饭指南)的mcp server,帮你推荐菜谱、规划膳食,解决“今天吃什么“的世纪难题; Based on Anduin2017/HowToCook (Programmer's Guide to Cooking at Home), MCP Server helps you recommend recipes, plan meals, and solve the century old problem of "what to eat today"
BlenderBlenderMCP connects Blender to Claude AI through the Model Context Protocol (MCP), allowing Claude to directly interact with and control Blender. This integration enables prompt assisted 3D modeling, scene creation, and manipulation.
Serper MCP ServerA Serper MCP Server
Context7Context7 MCP Server -- Up-to-date code documentation for LLMs and AI code editors
WindsurfThe new purpose-built IDE to harness magic
CursorThe AI Code Editor
MCP AdvisorMCP Advisor & Installation - Use the right MCP server for your needs
ChatWiseThe second fastest AI chatbot™
Tavily Mcp