MCP Two AI Models Communicating Server
Enables two local LLMs (Qwen and Llama) to communicate via MCP, allowing one model to consult the other for second opinions or additional reasoning.
README
MCP: Two AI Models Communicating
A Python-based AI chatbot that demonstrates how two independent open-source Large Language Models (LLMs) can communicate using the Model Context Protocol (MCP).
The first AI model (Qwen) interacts directly with the user and can consult a second AI model (Llama) whenever it determines that a second opinion or additional reasoning may be useful. Both models run locally using Ollama without requiring any paid APIs or cloud services.
Features
- Two independent AI models communicating through MCP.
- Runs completely on your local machine.
- No paid APIs or cloud services required.
- Uses Ollama to run both LLMs locally.
- Supports terminal-based interaction.
- Includes an optional Streamlit web interface.
- Demonstrates tool calling and multi-model collaboration.
Technologies Used
- Python
- Ollama
- MCP (Model Context Protocol)
- Streamlit
- Qwen 2.5 (1.5B)
- Llama 3.2 (1B)
Project Structure
project-folder/
│
├── app.py
├── client.py
├── server.py
├── requirements.txt
├── .gitignore
└── README.md
System Requirements
- Ubuntu (Recommended)
- Python 3.10 or above
- Ollama
- Internet connection (only required for downloading Ollama and the LLM models)
- Python Virtual Environment (Recommended)
Clone the Repository
git clone https://github.com/mamidi-joseph/MCP-Two-AI-Models-Communicating.git
cd MCP-Two-AI-Models-Communicating
Create a Virtual Environment
Create a virtual environment:
python3 -m venv venv
Activate the virtual environment:
source venv/bin/activate
Verify that it is activated:
which python
Install Python Dependencies
Install all required Python packages:
pip install -r requirements.txt
(Optional) Upgrade pip:
pip install --upgrade pip
Install Ollama
Run the following command:
curl -fsSL https://ollama.com/install.sh | sh
Verify the installation:
ollama --version
Download the Required LLM Models
This project uses two local LLM models.
Download Qwen 2.5 (1.5B)
ollama pull qwen2.5:1.5b
Download Llama 3.2 (1B)
ollama pull llama3.2:1b
Verify the Installed Models
Run:
ollama list
You should see both models installed:
qwen2.5:1.5b
llama3.2:1b
If both models are listed, you are ready to run the project.
Running the Project
Recommended Method - Ubuntu Terminal
The recommended way to use this project is through the Ubuntu terminal using client.py.
Run:
python client.py
You should see something similar to:
============================================================
Two AI models are now connected.
You are talking to Model 1 (Qwen2.5).
It can privately consult Model 2 (Llama 3.2) when useful.
Type 'quit' to exit.
============================================================
You can now start asking questions directly from the terminal.
To exit the application:
quit
or
exit
Note:
client.pyis the recommended way to use this project and best demonstrates how the two AI models communicate using MCP.
Optional Web Interface
This project also includes a simple Streamlit-based web interface.
Run:
streamlit run app.py
After running the command, Streamlit will provide a local URL similar to:
http://localhost:8501
Open the URL in your browser to interact with the chatbot.
Note:
app.pyis completely optional. The terminal-based version (client.py) is recommended for demonstrating MCP-based communication between the two AI models.
Example Prompts
The first AI model decides whether it needs to consult the second AI model. Because of this, some prompts may be answered directly without invoking MCP.
If you want to clearly demonstrate communication between both AI models, try prompts that explicitly request a second opinion or ask the first model to consult the second AI model.
Examples:
Ask the second AI what it thinks, then tell me if you agree.
Get a second opinion on whether cats or dogs make better pets.
Check with the other AI whether my plan makes sense: [describe your plan]
Consult the second AI and explain how MCP works.
Ask the other AI for its opinion on learning Python.
Note: The use of MCP depends on the first AI model's decision. Prompts that explicitly request a second opinion are more likely to demonstrate the interaction between the two AI models.
How It Works
User
|
v
client.py
|
v
Qwen 2.5 (1.5B)
|
v
MCP Tool Call
|
v
server.py
|
v
Llama 3.2 (1B)
|
v
Response Returned
|
v
Qwen Generates Final Answer
|
v
User
Workflow
-
The user asks a question.
-
Qwen receives the question.
-
If required, Qwen consults the second AI model through MCP.
-
The MCP server forwards the question to Llama.
-
Llama generates its response.
-
The response is returned to Qwen.
-
Qwen combines the information and generates the final answer.
-
The final response is displayed to the user.
Important Notes
- This project was developed and tested on Ubuntu.
- Using a Python virtual environment is recommended.
- Both LLM models must be downloaded before running the project.
client.pyis the recommended way to use the project.app.pyis optional and provides a simple Streamlit web interface.- No paid APIs or cloud services are required.
- Internet access is only required when downloading Ollama and the LLM models.
- All AI models run locally on your machine using Ollama.
- The first AI model decides when it should consult the second AI model.
- Not every prompt will result in communication between both models.
Troubleshooting
Ollama Command Not Found
Verify that Ollama is installed:
ollama --version
If the command is not recognized, reinstall Ollama:
curl -fsSL https://ollama.com/install.sh | sh
Model Not Found
Check the installed models:
ollama list
If a model is missing, download it again:
ollama pull qwen2.5:1.5b
or
ollama pull llama3.2:1b
Python Packages Not Found
Ensure that your virtual environment is activated:
source venv/bin/activate
Then reinstall the dependencies:
pip install -r requirements.txt
Author
Mamidi Joseph
- Email: mrjoseph569@gmail.com , mamidijoseph9@gmail.com
- GitHub: https://github.com/mamidi-joseph
- LinkedIn: https://www.linkedin.com/in/mamidi-joseph/
Feel free to connect with me or reach out if you have any questions, suggestions, or feedback regarding this project.
License
This project is intended for educational and learning purposes.
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.