KW

keli-wen/mcp_chatbot

开发工具

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

252 stars 54 forks 质量 66 趋势 18MIT

keli-wen/mcp_chatbot 是从 https://github.com/keli-wen/mcp_chatbot. 导入的 MCP 服务器候选

概览

keli-wen/mcp_chatbot 是从 https://github.com/keli-wen/mcp_chatbot. 导入的 MCP 服务器候选

概述(AI 翻译)

该项目演示了如何将模型上下文协议(MCP)与定制的大型语言模型(如Qwen)集成,创建一个强大的聊天机器人,能够通过MCP服务器与各种工具交互。该实现展示了MCP的灵活性,使大型语言模型能够无缝使用外部工具。

[!提示] 中文版本请参阅 README_ZH.md。

概述

聊天机器人Streamlit示例

工作流程追踪示例

  • 🚩 更新(2025-04-11):
  • 新增聊天机器人流式照明示例。
  • 🚩 更新(2025-04-10):
  • 更复杂的LLM响应解析,支持多个MCP工具调用和多次聊天迭代。
  • 增加了单一提示示例,支持常规和流式两种模式。
  • 增加了交互式终端聊天机器人示例。

该项目包括:

  • 简单/复杂CLI聊天机器人界面
  • 与某些内置的MCP服务器集成,如(Markdown处理工具)
  • 支持定制大型语言模型(如Qwen)和Ollama
  • 适用于常规和流式模式的单一提示处理示例脚本
  • 交互式终端聊天机器人,具备常规和流式响应模式

要求

  • Python 3.10+
  • 依赖关系(通过需求自动安装):

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

README

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

MCPChatbot Example

This project demonstrates how to integrate the Model Context Protocol (MCP) with customized LLM (e.g. Qwen), creating a powerful chatbot that can interact with various tools through MCP servers. The implementation showcases the flexibility of MCP by enabling LLMs to use external tools seamlessly.

[!TIP] For Chinese version, please refer to README_ZH.md.

Overview

Chatbot Streamlit Example

Workflow Tracer Example

  • 🚩 Update (2025-04-11):
    • Added chatbot streamlit example.
  • 🚩 Update (2025-04-10):
    • More complex LLM response parsing, supporting multiple MCP tool calls and multiple chat iterations.
    • Added single prompt examples with both regular and streaming modes.
    • Added interactive terminal chatbot examples.

This project includes:

  • Simple/Complex CLI chatbot interface
  • Integration with some builtin MCP Server like (Markdown processing tools)
  • Support for customized LLM (e.g. Qwen) and Ollama
  • Example scripts for single prompt processing in both regular and streaming modes
  • Interactive terminal chatbot with regular and streaming response modes

Requirements

  • Python 3.10+
  • Dependencies (automatically installed via requirements):
    • python-dotenv
    • mcp[cli]
    • openai
    • colorama

Installation

  1. Clone the repository:

    git clone [email protected]:keli-wen/mcp_chatbot.git
    cd mcp_chatbot
    
  2. Set up a virtual environment (recommended):

    cd folder
    
    # Install uv if you don't have it already
    pip install uv
    
    # Create a virtual environment and install dependencies
    uv venv .venv --python=3.10
    
    # Activate the virtual environment
    # For macOS/Linux
    source .venv/bin/activate
    # For Windows
    .venv\Scripts\activate
    
    # Deactivate the virtual environment
    deactivate
    
  3. Install dependencies:

    pip install -r requirements.txt
    # or use uv for faster installation
    uv pip install -r requirements.txt
    
  4. Configure your environment:

    • Copy the .env.example file to .env:

      cp .env.example .env
      
    • Edit the .env file to add your Qwen API key (just for demo, you can use any LLM API key, remember to set the base_url and api_key in the .env file) and set the paths:

      LLM_MODEL_NAME=your_llm_model_name_here
      LLM_BASE_URL=your_llm_base_url_here
      LLM_API_KEY=your_llm_api_key_here
      OLLAMA_MODEL_NAME=your_ollama_model_name_here
      OLLAMA_BASE_URL=your_ollama_base_url_here
      MARKDOWN_FOLDER_PATH=/path/to/your/markdown/folder
      RESULT_FOLDER_PATH=/path/to/your/result/folder
      

Important Configuration Notes ⚠️

Before running the application, you need to modify the following:

  1. MCP Server Configuration:
在 GitHub 查看完整 README

安装

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

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

配置

{ "mcpServers": { "markdown_processor": { "command": "/path/to/your/uv", "args": [ "--directory", "/path/to/your/project/mcp_servers", "run", "markdown_processor.py" ] } } }