MCP.so
Sign In
Servers

MCP with Langchain Sample Setup

@TaQuangTu

Sample MCP Server & Client setup, compatible with LangChain

Overview

What is MCP with Langchain Sample Setup?

MCP with Langchain Sample Setup is a demonstration project that implements the Model Context Protocol (MCP) with Langchain. It includes three sample MCP servers (math, weather, and which_llm_to_use), each exposing one or two functions, and a Streamlit-based MCP client that bridges users with those servers. It is intended for developers exploring MCP and Langchain integration.

How to use MCP with Langchain Sample Setup?

Start each of the three MCP servers in the mcp_servers folder on ports 8000, 8001, and 8002 (e.g., nohup python math_mcp_server.py > math.log 2>&1 &). Then export your OpenAI API key and launch the Streamlit client with streamlit run my_chat_bot_app.py. The web UI will be available on port 8501.

Key features of MCP with Langchain Sample Setup

  • Three sample MCP servers: math, weather, and which_llm_to_use
  • Each server provides one or two functions
  • Streamlit-based web UI as the MCP client
  • Bridges user requests to multiple MCP servers
  • Demonstrates MCP integration with Langchain and OpenAI

Use cases of MCP with Langchain Sample Setup

  • Learning how to set up and run multiple MCP servers concurrently
  • Testing interactions between a chat interface and math, weather, or LLM-selection tools
  • Prototyping applications that combine several MCP services under a single client

FAQ from MCP with Langchain Sample Setup

What MCP servers are included?

Three sample servers: math_mcp_server, weather_mcp_server, and which_llm_to_use_mcp_server, each with one or two functions.

What ports do the MCP servers use?

They listen on ports 8000, 8001, and 8002 respectively.

How do I start the client?

Set the OPENAI_API_KEY environment variable and run streamlit run my_chat_bot_app.py. The client starts a web UI on port 8501.

Do I need an API key?

Yes, an OpenAI API key is required and must be set as the OPENAI_API_KEY environment variable.

What runtime dependencies are required?

Python is needed to run the servers and client. The project uses Streamlit and the OpenAI library, though exact dependency details are not listed in the README.

More from AI & Agents