AWS Bedrock MCP server

Integrates AWS Bedrock, enabling natural language processing and task automation.
Back to servers
Provider
David Shtian
Release date
Dec 26, 2024
Language
Python
Stats
51 stars

This simple implementation demonstrates Anthropic's Model Context Protocol (MCP) integration with AWS Bedrock, allowing you to interact with MCP-enabled tools through AWS Bedrock's runtime service.

Prerequisites

  • Python 3.10 or higher
  • AWS account with Bedrock access
  • Configured AWS credentials
  • UV package manager

Installation and Setup

Setting Up the STDIO Client

  1. Install the required dependencies:
uv pip install boto3
  1. Run the client:
uv run client_stdio.py

Setting Up the SSE Client

  1. Install the required dependencies:
uv pip install boto3 uvicorn
  1. Start the MCP tool server:
uv run mcp-simple-tool --transport sse --port 8000
  1. In a separate terminal, run the client:
uv run client_sse.py

How It Works

When you run the client, it performs the following actions:

  • Initializes a connection to AWS Bedrock
  • Starts the MCP tool server
  • Lists available tools and converts them to the format required by Bedrock
  • Handles communication between Bedrock and the MCP tools

Client Modes

STDIO Mode

The STDIO mode provides a simple way to interact with MCP tools through standard input/output.

uv run client_stdio.py

SSE Mode

The Server-Sent Events (SSE) mode enables asynchronous communication:

  1. Start the server:

    uv run mcp-simple-tool --transport sse --port 8000
    
  2. Run the client:

    uv run client_sse.py
    

Key Features

  • AWS Bedrock Integration: Connects seamlessly with AWS Bedrock runtime
  • Tool Format Conversion: Converts MCP tools to Bedrock-compatible format
  • Asynchronous Communication: Handles async communication between components
  • Structured Logging: Provides detailed logging for troubleshooting

How to add this MCP server to Cursor

There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.

If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.

Adding an MCP server to Cursor globally

To add a global MCP server go to Cursor Settings > MCP and click "Add new global MCP server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

{
    "mcpServers": {
        "cursor-rules-mcp": {
            "command": "npx",
            "args": [
                "-y",
                "cursor-rules-mcp"
            ]
        }
    }
}

Adding an MCP server to a project

To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.

How to use the MCP server

Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.

The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.

You can also explictly ask the agent to use the tool by mentioning the tool name and describing what the function does.

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later