
该项目展示了如何将亚马逊贝德罗克上的基础模型与Chainlit和MCP(模式上下文协议)服务器相融合,以创建与工具增强的交互聊天界面. .
概览
该项目演示了如何将亚马逊Bedrock上的基础模型与Chainlit和MCP(模式上下文协议)服务器相融合,以创建具有工具增强能力的交互式聊天界面. - 使用Anthropic Claude 3.7与亚马逊·贝德罗克融合 Sonnet - A chainlit web 界面用于对话 AI 交互 - 一个执行基本数学操作的自定义模式背景协议(MCP)服务器 - 为平稳的用户体验而流出响应 - LangChain 与 MCP 适配器的集成连接外部工具 - LangGraph 用于创建可协调工具使用的ReAct(Reasoning and Acact)代理 在开始之前,请务必: - : 您需要一个带有 Bedrock 访问权限的 AWS 账户 - : 保证您的 AWS 账户能够访问 Anthropic Claude 3.7 Sonnet 模式 - : 配置有适当的证书和权限 - : 此工程需要 Python 3. 13 或 更新 - : 对于依赖管理和建筑(安装有 pip s安装 uv) 2. 联合国.
概述(AI 翻译)
该项目演示了如何将亚马逊Bedrock上的基础模型与Chainlit和MCP(模式上下文协议)服务器相融合,以创建具有工具增强能力的交互式聊天界面.
□ 项目概览
此样本应用程序显示:
- 使用Anthropic Claude 3.7 Sonnet与亚马逊·贝德罗克融合
- 用于对话的 AI 互动的 Chainlit 网络界面
- 执行基本数学操作的自定义模式背景协议服务器
- 为顺利的用户体验而流出答复
- LangChain与MCP适配器的集成,连接外部工具
- LangGraph 用于创建一个指挥工具使用的ReAct(Reasoning and Action)代理人
□ 先决条件
在开始之前,请务必:
- ** AWS账户**: 你需要一个AWS的账户 与贝德洛克访问
- Bedrock Access:确保您的AWS账户能够访问Anthropic Claude 3.7 Sonnet模型
- [AWS CLI**: 配置有适当的证书和权限
- ** 第3.13分部分: 这个项目需要 Python 3. 13 或更新
- UV:依赖管理和建筑(安装在[T0])
□ 安装
-
清除储存库:
-
联合国.
本页由 AI 翻译,技术细节请以原文为准。
README
以下为原文 README 节选,完整内容请查看原文。
Amazon Bedrock and MCP Server integration, the easy way
This project demonstrates how to integrate foundation models on Amazon Bedrock with Chainlit and MCP (Model Context Protocol) servers to create an interactive chat interface with tool-enhanced capabilities.
Project Overview
This sample application showcases:
- Integration with Amazon Bedrock using Anthropic Claude 3.7 Sonnet
- A Chainlit web interface for conversational AI interactions
- A custom Model Context Protocol (MCP) server that performs basic math operations
- Streaming responses for a smooth user experience
- LangChain integration with MCP adapters to connect external tools
- LangGraph for creating a ReAct (Reasoning and Acting) agent that orchestrates tool use
Prerequisites
Before getting started, ensure you have:
- AWS Account: You’ll need an AWS account with Bedrock access
- Bedrock Access: Ensure your AWS account has access to the Anthropic Claude 3.7 Sonnet model
- AWS CLI: Configured with appropriate credentials and permissions
- Python 3.13+: This project requires Python 3.13 or newer
- UV: For dependency management and building (install with
pip install uv)
Installation
-
Clone the repository:
git clone https://github.com/aws-samples/sample-bedrock-mcp.git cd sample-bedrock-chainlit-mcp -
Create a virtual environment and install dependencies using UV:
uv sync --all-groups -
Configure AWS credentials (if not already done):
aws configure
Building from Source
To build the project from source using UV:
-
Build the package:
uv build
This will create distribution files in the dist/ directory, including the wheel file dist/sample_bedrock_chainlit_mcp-0.1.0-py3-none-any.whl that can be installed or used directly as the MCP server.
Usage Guide
Starting the Chainlit Application
To start the Chainlit application:
chainlit run src/ui/app.py
This will launch a web server (typically at ) with the chat interface.
Setting up the MCP Server
The Math MCP server needs to be connected to provide calculation capabilities:
- In the Chainlit web interface, look for the small plug icon under the chat text input element
- Click on it to open the MCP connection dialog
- Enter the following details:
- Name:
math - Command:
uvx dist/sample_bedrock_chainlit_mcp-0.1.0-py3-none-any.whl - Type: default (stdio)
- Name:
- Click “Confirm”
A successful connection will be indicated in the interface, and the math tools will become available to the Claude model.
Example Usage
Once the Chainlit application is running and the MCP server is connected, you can ask mathematical questions like:
- “What’s (3 + 5) x 12?”
- “Can you calculate 144 divided by 12?”
- “If I have 7 apples and get 9 more, then give 4 away, how many do I have left?”
安装
This server does not publish a one-line install command.
Open the repository installation guide 新手?先看 mcpskill.org 教程 →