MCPChatbot 示例 logo

MCPChatbot 示例

Community
keli-wen

A chatbot implementation compatible with MCP (terminal / streamlit supported)

Publisherkeli-wen
Repositorymcp_chatbot
LanguagePython
Forks
55
Stars
252
Available tools
0
Transport typestdio
Categories
LicenseMIT
Links
  • Connect tools to AI workflows

    MCPChatbot 示例 exposes MCP capabilities that can be used by compatible AI clients and agents.

  • 0 available tools

    Browse the callable actions below, including names and descriptions when provided by the server.

  • Ready-to-copy setup

    Use the installation snippets to configure this server in your preferred MCP client.

  • Open source signals

    252 stars and 55 forks from the linked repository.

MCPChatbot Example

MCP Chatbot

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:

    bash
    git clone git@github.com:keli-wen/mcp_chatbot.git
    cd mcp_chatbot
  2. Set up a virtual environment (recommended):

    bash
    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:

    bash
    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:

      bash
      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: Edit mcp_servers/servers_config.json to match your local setup:

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

    Replace /path/to/your/uv with the actual path to your uv executable. You can use which uv to get the path. Replace /path/to/your/project/mcp_servers with the absolute path to the mcp_servers directory in your project. (For Windows users, you can take a look at the example in the Troubleshooting section)

  2. Environment Variables: Make sure to set proper paths in your .env file:

    MARKDOWN_FOLDER_PATH="/path/to/your/markdown/folder"
    RESULT_FOLDER_PATH="/path/to/your/result/folder"

    The application will validate these paths and throw an error if they contain placeholder values.

You can run the following command to check your configuration:

bash
bash scripts/check.sh

Usage

Unit Test

You can run the following command to run the unit test:

bash
bash scripts/unittest.sh

Examples

Single Prompt Examples

The project includes two single prompt examples:

  1. Regular Mode: Process a single prompt and display the complete response

    bash
    python example/single_prompt/single_prompt.py
  2. Streaming Mode: Process a single prompt with real-time streaming output

    bash
    python example/single_prompt/single_prompt_stream.py

Both examples accept an optional --llm parameter to specify which LLM provider to use:

bash
python example/single_prompt/single_prompt.py --llm=ollama

[!NOTE] For more details, see the Single Prompt Example README.

Terminal Chatbot Examples

The project includes two interactive terminal chatbot examples:

  1. Regular Mode: Interactive terminal chat with complete responses

    bash
    python example/chatbot_terminal/chatbot_terminal.py
  2. Streaming Mode: Interactive terminal chat with streaming responses

    bash
    python example/chatbot_terminal/chatbot_terminal_stream.py

Both examples accept an optional --llm parameter to specify which LLM provider to use:

bash
python example/chatbot_terminal/chatbot_terminal.py --llm=ollama

[!NOTE] For more details, see the Terminal Chatbot Example README.

Streamlit Web Chatbot Example

The project includes an interactive web-based chatbot example using Streamlit:

bash
streamlit run example/chatbot_streamlit/app.py

This example features:

  • Interactive chat interface.
  • Real-time streaming responses.
  • Detailed MCP tool workflow visualization.
  • Configurable LLM settings (OpenAI/Ollama) and MCP tool display via the sidebar.

MCP Chatbot Streamlit Demo

[!NOTE] For more details, see the Streamlit Chatbot Example README.

Project Structure

  • mcp_chatbot/: Core library code
    • chat/: Chat session management
    • config/: Configuration handling
    • llm/: LLM client implementation
    • mcp/: MCP client and tool integration
    • utils/: Utility functions (e.g. WorkflowTrace and StreamPrinter)
  • mcp_servers/: Custom MCP servers implementation
    • markdown_processor.py: Server for processing Markdown files
    • servers_config.json: Configuration for MCP servers
  • data-example/: Example Markdown files for testing
  • example/: Example scripts for different use cases
    • single_prompt/: Single prompt processing examples (regular and streaming)
    • chatbot_terminal/: Interactive terminal chatbot examples (regular and streaming)
    • chatbot_streamlit/: Interactive web chatbot example using Streamlit

Extending the Project

You can extend this project by:

  1. Adding new MCP servers in the mcp_servers/ directory
  2. Updating the servers_config.json to include your new servers
  3. Implementing new functionalities in the existing servers
  4. Creating new examples based on the provided templates

Troubleshooting

For Windows users, you can take the following servers_config.json as an example:

json
{
    "mcpServers": {
        "markdown_processor": {
            "command": "C:\\Users\\13430\\.local\\bin\\uv.exe",
            "args": [
                "--directory",
                "C:\\Users\\13430\\mcp_chatbot\\mcp_servers",
                "run", 
                "markdown_processor.py"
            ]
        }
    }
}
  • Path Issues: Ensure all paths in the configuration files are absolute paths appropriate for your system
  • MCP Server Errors: Make sure the tools are properly installed and configured
  • API Key Errors: Verify your API key is correctly set in the .env file

Installation

TypingMind
Prerequisites:

Node.js 18+

{
  "mcpServers": {
    "keli-wen-mcp_chatbot": {
      "command": "",
      "args": []
    }
  }
}

Use MCPChatbot 示例 MCP with multiple AI models

TypingMind connects MCP tools at the workspace level, so once MCPChatbot 示例 is connected, you can use it with different AI models in TypingMind instead of setting it up separately for each model. This MCP runs locally through the TypingMind MCP connector on your device.

Setup guide to use the local connector

Use this when the MCP server needs access to local files, apps, or private resources on your computer.

1

Open the MCP settings

In TypingMind, go to Settings, Advanced Settings, then Model Context Protocol and choose Setup Connector.

  1. Open TypingMind in your browser.
  2. Click the Settings icon.
  3. Go to Advanced Settings.
  4. Open the Model Context Protocol section.
  5. Click Setup Connector and choose This Device.
TypingMind MCP connector setup screen with This Device selected
2

Run the connector command

Choose This Device, copy the command from TypingMind, and run it in Terminal. Keep the process running while you use MCP.

  1. Copy the setup command shown by TypingMind.
  2. Open Terminal on macOS or Windows Terminal on Windows.
  3. Paste and run the command.
  4. Approve the package install if Terminal asks you to proceed.
  5. Keep the Terminal window running while using MCP tools.
3

Add MCPChatbot 示例 as a server

When the connector status is Ready, click Edit Servers and paste the MCP server configuration.

  1. Wait until the connector status shows Ready.
  2. Click Edit Servers.
  3. Paste the MCPChatbot 示例 MCP server configuration.
  4. Save the server list.
  5. Refresh if you want to confirm the connector is still ready.
TypingMind MCP settings showing active server and Edit Servers button
{
  "mcpServers": {
    "keli-wen-mcp_chatbot": {
      "command": "npx",
      "args": [
        "-y",
        "mcp-simple-chatbot"
      ]
    }
  }
}
4

Use it across models

Save the server list, open Plugins, enable the MCPChatbot 示例 MCP tools, then select any supported AI model in TypingMind and use the tools in chat or assign them to an AI agent.

  1. Open the Plugins page in TypingMind.
  2. Enable the MCPChatbot 示例 MCP tools.
  3. Start a chat and choose the AI model you want to use.
  4. Use the MCP tools in chat or assign them to an AI agent.
  5. Switch to another AI model whenever needed without reconnecting MCP.
TypingMind chat using enabled MCP tools with a selected AI model
Can you use MCPChatbot 示例 to help me with this task?
MCPChatbot 示例
Sure. I read it.
Here is what I found using MCPChatbot 示例.

Frequently asked questions

What is the MCPChatbot 示例 MCP server used for?

MCPChatbot 示例 is an MCP server that lets compatible AI clients connect to external tools and context. In TypingMind, you can add this MCP server once and make its tools available in your AI workspace.

Can I use MCPChatbot 示例 MCP with multiple AI models in TypingMind?

Yes. TypingMind connects MCP tools at the workspace level, so you can use MCPChatbot 示例 with different AI models such as Claude, ChatGPT, Gemini, or other models you have configured in TypingMind without setting up the MCP server separately for each model.

Why use MCPChatbot 示例 MCP with TypingMind?

TypingMind is one of the best frontends for LLM chat because it brings multiple AI models, prompts, plugins, AI agents, API keys, and MCP tools into one workspace. With MCPChatbot 示例 connected, you can use its MCP tools across your preferred models while keeping your chat workflow organized in TypingMind.

How do I connect MCPChatbot 示例 MCP to TypingMind?

MCPChatbot 示例 runs through the TypingMind local MCP connector. This is best when the MCP server needs access to local files, desktop apps, command-line tools, or private resources on your computer.

What tools does MCPChatbot 示例 MCP provide in TypingMind?

MCPChatbot 示例 exposes MCP capabilities that can be enabled from the TypingMind Plugins page and used in chat or assigned to AI agents.

Do I need to share my API keys with TypingMind to use MCPChatbot 示例 MCP?

No. TypingMind is local-first and lets you keep your model providers, API keys, prompts, and MCP configuration under your control. If MCPChatbot 示例 requires authentication, add the required headers, OAuth settings, or local configuration for that MCP server when you create the connection.

Related MCP Servers

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇