MCP Chatbot
This chatbot example demonstrates how to integrate the Model Context Protocol (MCP) into a simple CLI chatbot. The implementation showcases MCP's flexibility by supporting multiple tools through MCP servers and is compatible with any LLM provider that follows OpenAI API standards.
If you find this project helpful, don’t forget to ⭐ star the repository or buy me a ☕ coffee.
Key Features
- LLM Provider Flexibility: Works with any LLM that follows OpenAI API standards (tested with Llama 3.2 90b on Groq and GPT-4o mini on GitHub Marketplace).
- Dynamic Tool Integration: Tools are declared in the system prompt, ensuring maximum compatibility across different LLMs.
- Server Configuration: Supports multiple MCP servers through a simple JSON configuration file like the Claude Desktop App.
Requirements
- Python 3.10
python-dotenvrequestsmcpuvicorn
Installation
Clone the repository:
git clone https://github.com/3choff/mcp-chatbot.git cd mcp-chatbotInstall the dependencies:
pip install -r requirements.txtSet up environment variables:
Create a
.envfile in the root directory and add your API key:LLM_API_KEY=your_api_key_hereConfigure servers:
The
servers_config.jsonfollows the same structure as Claude Desktop, allowing for easy integration of multiple servers. Here's an example:{ "mcpServers": { "sqlite": { "command": "uvx", "args": ["mcp-server-sqlite", "--db-path", "./test.db"] }, "puppeteer": { "command": "npx", "args": ["-y", "@modelcontextprotocol/server-puppeteer"] } } }Environment variables are supported as well. Pass them as you would with the Claude Desktop App.
Example:
{ "mcpServers": { "server_name": { "command": "uvx", "args": ["mcp-server-name", "--additional-args"], "env": { "API_KEY": "your_api_key_here" } } } }






