MCP Two AI Models Communicating Server

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.

Category
访问服务器

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

  • 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.

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选