MCP Multi-Server Demo logo

MCP Multi-Server Demo

by fredrikp999

This project demonstrates how to use the Model Context Protocol (MCP) with multiple servers using different transport methods (stdio and Server-Sent Events). It integrates with LangChain and OpenAI to create an agent that can use tools from both servers.

View on GitHub

Last updated: N/A

What is MCP Multi-Server Demo?

This is a demonstration of using the Model Context Protocol (MCP) with multiple servers. It includes a math server, a weather server, and a main application that connects to both using the MultiServerMCPClient. It integrates with LangChain and OpenAI to create an agent that can use tools from both servers.

How to use MCP Multi-Server Demo?

  1. Clone the repository. 2. Install the required dependencies using pip install -r requirements.txt. 3. Set up your OpenAI API key in a .env file. 4. Run the main application using python main.py.

Key features of MCP Multi-Server Demo

  • Uses MultiServerMCPClient to connect to multiple servers

  • Supports different transport methods (stdio and SSE)

  • Integrates with LangChain for agent functionality

  • Includes a math server for basic arithmetic operations

  • Includes a weather server for simulated weather information

Use cases of MCP Multi-Server Demo

  • Creating agents that can access multiple tools from different servers

  • Building applications that require both mathematical calculations and external data (e.g., weather)

  • Demonstrating the use of MCP with different transport methods

  • Extending the project with more tools and servers

FAQ from MCP Multi-Server Demo

What is MCP?

MCP stands for Model Context Protocol, developed by Anthropic.

What is SSE transport?

SSE stands for Server-Sent Events, an HTTP-based protocol for server-to-client push notifications.

What is the purpose of the math server?

The math server provides basic arithmetic operations (add, multiply).

What is the purpose of the weather server?

The weather server provides simulated weather information for different locations.

How do I extend this project?

You can extend this project by adding more tools to the math or weather servers, creating additional MCP servers with different functionality, modifying the agent to handle more complex queries, or connecting to real weather APIs instead of using simulated data.