Multi-Server Chatbot with Model Context Protocol (MCP)
This project demonstrates how to build and run a multi-server chatbot using the Model Context Protocol (MCP), inspired by the deeplearning.ai tutorial. It includes math, weather, and research servers, and a chatbot interface.
Features
- Modular chatbot that routes queries to different servers (math, weather, research, LLM, etc.)
- Easily extensible via
server_config.json - Example integration with Grok API and a local copy/echo server
Prerequisites
- Python 3.8+
- uv (for running servers)
- Required Python packages (see
requirements.txt)
Setup
-
Install dependencies:
powershell uv pip install -r requirements.txt
Or, if you use pip:powershell pip install -r requirements.txt -
Check server configuration:
Theserver_config.jsonfile defines how each MCP server is started or connected.
Step-by-Step Usage
1. Start the Weather Server
The weather server must be running before starting the chatbot, as it is accessed via HTTP.```powershell
python weather_server.py
Leave this terminal open and running.
### 2. Start the Chatbot (MCP Chatbot)
In a new terminal, run:```powershell
uv run mcp_chatbot.py
This will start the chatbot, which will connect to the math, weather, and research servers as defined in server_config.json.
3. Example Questions
Math Example```
> What is 12 * 8?
#### Weather Example```
> What is the weather in Paris?
Research Example```
> Find recent papers on quantum chemistry.
```
4. Stopping the Servers
- Press
Ctrl+Cin each terminal to stop the servers.
Notes
- You can modify
server_config.jsonto add or change servers. - The chatbot will route your questions to the appropriate server based on the query.
- For more details, see the deeplearning.ai MCP tutorial.
Happy experimenting with MCP!
