MB

moritalous/bedrock-mcp-streamlit

效率工作流

本页由 AI 翻译,技术细节请以原文为准。 查看原文

10 stars 3 forks 质量 63 趋势 18MIT

This is a chat application built with Streamlit and integrated with the MCP (Model Context Protocol) tool.

概览

This is a chat application built with Streamlit and integrated with the MCP (Model Context Protocol) tool. Bedrock Chat with MCP tool is a chat application built with Streamlit and integrated with the MCP (Model Context Protocol) tool. This application uses Langchain and Bedrock to create a chat model and uses the model specified in config.json as a parameter in Langchain's init_chat_model function (https://python.langchain.com/docs/how_to/chat_models_universal_init/). It interacts with the MCP (Model Context Protocol) server defined in mcp_config.json and accesses various tools. MCP is an open protocol that standardizes how applications provide context to LLM (https://modelcontextprotocol.io/). Chat history is stored in a YAML file. The util.py module defines MessageProcessor and its subclasses to handle message processing using different models. The config.json file allows you to configure the LLM model to use, where the chat history files are stored, etc. The mcp_config.

README

以下为原文 README 节选,完整内容请查看原文。

Bedrock Chat with MCP tool

This is a chat application built with Streamlit and integrated with the MCP (Model Context Protocol) tool.

Overview

Bedrock Chat with MCP tool is a chat application built with Streamlit and integrated with the MCP (Model Context Protocol) tool.

This application uses Langchain and Bedrock to create a chat model and uses the model specified in config.json as a parameter in Langchain’s init_chat_model function (https://python.langchain.com/docs/how_to/chat_models_universal_init/). It interacts with the MCP (Model Context Protocol) server defined in mcp_config.json and accesses various tools. MCP is an open protocol that standardizes how applications provide context to LLM (https://modelcontextprotocol.io/). Chat history is stored in a YAML file. The util.py module defines MessageProcessor and its subclasses to handle message processing using different models.

The config.json file allows you to configure the LLM model to use, where the chat history files are stored, etc. The mcp_config.json file describes the configuration of the MCP server.

In the Streamlit sidebar, you can configure the following:

  • Select LLM model
  • Change chat history directory
  • Change MCP configuration file
  • Select past chat history

Features

  • Chat interface using Streamlit
  • Integration with MCP tools
  • Use Langchain and Bedrock for chat model
  • LLM model etc. can be configured in config.json
  • MCP tool integration
  • Use Langchain and Bedrock
  • Read MCP server settings from mcp_config.json
  • Save chat history in YAML format
  • Can change settings from Streamlit sidebar

Setup

  1. Install dependencies:

    pip install streamlit langchain langchain-aws langchain_mcp_adapters
    
  2. Configure MCP server in mcp_config.json.

  3. Run the application.

    streamlit run src/main.py
    

Configuration

The config.json file is where you configure the LLM model and other settings.

{
  "chat_history_dir": "chat_history",
  "mcp_config_file": "mcp_config.json",
  "models": {
    "Claude 3.7 Sonnet": {
      "model_provider": "bedrock_converse",
      "model": "us.anthropic.claude-3-7-sonnet-20250219-v1:0"
    },
    "Amazon Nova Pro": {
      "model_provider": "bedrock_converse",
      "model": "us.amazon.nova-pro-v1:0"
    },
  },
}

The mcp_config.json file contains the settings for the MCP server.

Please note that transport is required.

{
  "mcpServers": {
    "server1": {
      "command": "...",
      "args": ["..."],
      "env": {
        "API_KEY": "..."
      },
      "transport": "..."
    }
  }
}

Usage

To run the Streamlit application, run the following command.

streamlit run src/main.py

Once the application is running, enter a message in the chat input box.

在 GitHub 查看完整 README

安装

This server does not publish a one-line install command.

Open the repository installation guide 新手?先看 mcpskill.org 教程 →

配置

{ "mcpServers": { "server1": { "command": "...", "args": ["..."], "env": { "API_KEY": "..." }, "transport": "..." } } }