MCP ExplorerExplorer

Amazon Bedrock Mcp

@mikegc-awson a year ago
90 MIT-0
FreeCommunity
AI Systems
Anthropic的开源MCP与Amazon Bedrock Converse API结合使用的演示

Overview

What is Amazon Bedrock Mcp

Amazon-bedrock-mcp is a demonstration of Anthropic’s open-source Model Control Protocol (MCP) integrated with the Amazon Bedrock Converse API, allowing users to leverage various models supported by the Converse API.

Use cases

Use cases include interactive chatbots, automated customer support systems, and applications that require real-time conversation management and response generation.

How to use

To use amazon-bedrock-mcp, clone the repository, set up a Python virtual environment, install the required packages, configure your AWS credentials, and run the application using ‘python app.py’.

Key features

Key features include integration with Amazon Bedrock, a core agent that manages conversation flow, tool execution capabilities, and the ability to maintain conversation context.

Where to use

Amazon-bedrock-mcp can be used in various fields such as customer service, virtual assistants, and any application requiring conversational AI capabilities.

Content

Amazon Bedrock Converse API MCP Demo

This is a demo of Anthropic’s open source MCP used with Amazon Bedrock Converse API. This combination allows for the MCP to be used with any of the many models supported by the Converse API.

Prerequisites

  • Python 3.8+
  • AWS account with Bedrock access
  • AWS credentials configured locally
  • SQLite database (Follow the instructions in the MCP Quick Start Guide to set this up.)

Installation

  1. Clone the repository:
git clone <repository-url>
cd <project-directory>
  1. Create and activate a virtual environment:
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate
  1. Install required packages:
pip install -r requirements.txt

Configuration

  1. Ensure AWS credentials are properly configured in ~/.aws/credentials or via environment variables:
export AWS_ACCESS_KEY_ID=your_access_key
export AWS_SECRET_ACCESS_KEY=your_secret_key
export AWS_DEFAULT_REGION=us-west-2
  1. The default configuration uses:
  • Model: anthropic.claude-3-5-sonnet-20241022-v2:0
  • Region: us-west-2
  • SQLite database path: ~/test.db

Project Structure

  • app.py: Main application entry point and interactive loop
  • converse_agent.py: Core agent implementation with Bedrock integration
  • converse_tools.py: Tool management and execution system
  • mcp_client.py: MCP (Model Control Protocol) client implementation

Usage

  1. Start the application:
python app.py
  1. Enter prompts when prompted. The agent will:
  • Process your input
  • Execute any necessary tools
  • Provide responses
  • Maintain conversation context
  1. Exit the application by typing ‘quit’, ‘exit’, ‘q’, or using Ctrl+C

Key Components

ConverseAgent

The main agent class that:

  • Manages conversation flow
  • Integrates with Bedrock
  • Handles tool execution
  • Processes responses

Reference:

startLine: 3
endLine: 109

ConverseToolManager

Manages tool registration and execution:

  • Tool registration with schemas
  • Name sanitization
  • Tool execution handling

Reference:

startLine: 5
endLine: 76

MCPClient

Handles communication with the MCP server:

  • Tool discovery
  • Tool execution
  • Server connection management

Reference:

startLine: 6
endLine: 48

Security

See CONTRIBUTING for more information.

License

This library is licensed under the MIT-0 License. See the LICENSE file.

Tools

No tools

Comments

Recommend MCP Servers

View All MCP Servers