Skip to main content
Glama
mamidi-joseph

MCP Two AI Models Communicating Server

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.


Related MCP server: HydraMCP

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

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.py is 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.py is 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

  1. The user asks a question.

  2. Qwen receives the question.

  3. If required, Qwen consults the second AI model through MCP.

  4. The MCP server forwards the question to Llama.

  5. Llama generates its response.

  6. The response is returned to Qwen.

  7. Qwen combines the information and generates the final answer.

  8. 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.py is the recommended way to use the project.

  • app.py is 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

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.

F
license - not found
-
quality - not tested
C
maintenance

Maintenance

Maintainers
Response time
Release cycle
Releases (12mo)
Commit activity

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Servers

  • A
    license
    A
    quality
    C
    maintenance
    An MCP server that enables users to query, compare, and synthesize responses from multiple local and cloud LLMs simultaneously using existing subscriptions. It provides tools for parallel model evaluation, consensus polling with an LLM-as-judge, and response synthesis across different model providers.
    8
    12
    15
    MIT
  • F
    license
    -
    quality
    A
    maintenance
    MCP server that bridges coding agents (Claude Code, Codex, Gemini CLI) via ACP for pair programming, enabling agents to consult each other as tools.
  • F
    license
    -
    quality
    C
    maintenance
    Enables interaction with Claude and Gemini command-line tools through the MCP protocol, allowing users to send prompts to either or both LLMs and receive responses.

View all related MCP servers

Related MCP Connectors

  • MCP server for AI dialogue using various LLM models via AceDataCloud

  • AI Reasoning Cache & Consensus Layer with 11 MCP tools via Streamable HTTP.

  • Agent-to-agent reasoning-as-a-service: chain-of-thought, analysis, and decision support.

View all MCP Connectors

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/mamidi-joseph/MCP-Two-AI-Models-Communicating'

If you have feedback or need assistance with the MCP directory API, please join our Discord server