MCPLEARNING
Integrates with LangChain to build an agent that connects to MCP servers, discovers their tools, and uses an LLM to execute queries via a state machine workflow.
Integrates with LangGraph to build a state machine agent that manages the loop between an LLM deciding whether to call a tool and feeding tool results back for a final answer.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@MCPLEARNINGWhat is 5 + 7 and the weather in California?"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
MCP + LangChain Demo
A beginner-friendly project that demonstrates how to build MCP (Model Context Protocol) servers and connect them to an LLM agent using LangChain and LangGraph.
What is MCP?
MCP (Model Context Protocol) is an open protocol that lets you expose custom tools (functions) to LLMs in a standardized way. Think of it as a universal plugin system for AI models.
Key concepts:
Term | Definition |
MCP Server | A process that exposes tools (functions) over a transport (stdio or HTTP). The LLM can call these tools. |
MCP Client | A process that connects to one or more MCP servers, discovers their tools, and forwards them to an LLM. |
Tool | A Python function decorated with |
Transport | The communication method between client and server. |
FastMCP | A high-level Python class from the |
Related MCP server: Model Context Protocol Multi-Agent Server
Project Structure
MCPLEARNING/
├── mathserver.py # MCP Server 1 - Math tools (stdio transport)
├── weather.py # MCP Server 2 - Weather tool (HTTP transport)
├── client.py # LangChain agent that connects to both servers
├── .env # API keys (NOT pushed to GitHub)
├── .gitignore
├── requirements.txt
└── pyproject.tomlHow It Works (Step by Step)
Step 1: MCP Server — mathserver.py
This file creates an MCP server named "Math" that exposes two tools:
add(a, b)— Returns the sum of two integers.multiply(a, b)— Returns the product of two integers.
It runs on stdio transport, meaning the client spawns it as a subprocess and communicates through stdin/stdout. No port needed.
from mcp.server.fastmcp import FastMCP
mcp = FastMCP("Math")
@mcp.tool()
def add(a: int, b: int) -> int:
"""Addition of two numbers"""
return a + b
@mcp.tool()
def multiply(a: int, b: int) -> int:
"""Multiplication of two numbers"""
return a * b
if __name__ == "__main__":
mcp.run(transport="stdio")Step 2: MCP Server — weather.py
This file creates an MCP server named "Weather" that exposes one tool:
get_weather(location)— Returns weather info for a given location.
It runs on streamable-http transport, meaning it starts a web server on http://127.0.0.1:8000/mcp. The client connects to it over HTTP.
from mcp.server.fastmcp import FastMCP
mcp = FastMCP("Weather")
@mcp.tool()
async def get_weather(location: str) -> str:
"""Get the weather"""
return "It's always raining in California"
if __name__ == "__main__":
mcp.run(transport="streamable-http")Step 3: Client Agent — client.py
This is the brain of the project. It:
Connects to both MCP servers using
MultiServerMCPClient.Discovers all tools from both servers (
add,multiply,get_weather).Creates a Groq LLM (hosted open-source model) and binds the tools to it.
Builds a LangGraph agent — a state machine where:
The LLM decides whether to call a tool or respond directly.
If a tool is called, the result is fed back to the LLM for a final answer.
Tests two queries:
"What is 3 + 5?" → Uses the
addtool."What is the weather in California?" → Uses the
get_weathertool.
Prerequisites
Python 3.13+
uv package manager (recommended) or pip
A Groq API key — Get one free at console.groq.com
Setup
1. Clone the repository
git clone https://github.com/<YOUR_USERNAME>/MCPLEARNING.git
cd MCPLEARNING2. Create and activate virtual environment
# Using uv (recommended)
uv venv
uv pip install -r requirements.txt
# Or using pip
python -m venv .venv
.venv\Scripts\activate # Windows
source .venv/bin/activate # Mac/Linux
pip install -r requirements.txt3. Set up your API key
Create a .env file in the project root:
GROQ_API_KEY=your_groq_api_key_hereIMPORTANT: Never commit your
.envfile. It is excluded via.gitignore.
Running the Project
You need two terminals open:
Terminal 1 — Start the Weather MCP Server
python weather.pyYou should see:
INFO: Uvicorn running on http://127.0.0.1:8000Note: Only
weather.pyneeds to be started manually. Themathserver.pyis spawned automatically by the client (stdio transport).
Terminal 2 — Run the Client
python client.pyExpected Output
Available MCP tools:
- add
- multiply
- get_weather
==============================
Testing Math MCP
==============================
Math Response: 3 + 5 = 8.
==============================
Testing Weather MCP
==============================
Weather Response: It's always raining in California.How to Create Your Own MCP Server
Install the MCP library:
pip install mcpCreate a new Python file (e.g.,
myserver.py):
from mcp.server.fastmcp import FastMCP
mcp = FastMCP("MyServer")
@mcp.tool()
def my_tool(param: str) -> str:
"""Description of what this tool does."""
return f"Result: {param}"
if __name__ == "__main__":
mcp.run(transport="stdio") # For stdio transport
# mcp.run(transport="streamable-http") # For HTTP transportConnect it in your client by adding it to the
MultiServerMCPClientconfig:
client = MultiServerMCPClient({
"myserver": {
"command": "python",
"args": ["myserver.py"],
"transport": "stdio",
},
})Transport Comparison
Transport | How it Works | When to Use |
stdio | Client spawns the server as a subprocess. Communicates via stdin/stdout. | Local tools, simple setup, no network needed. |
streamable-http | Server runs as a web server. Client connects via HTTP. | Remote tools, multiple clients, cross-machine access. |
Key Libraries Used
Library | Purpose |
| Build MCP servers with |
| Bridge between MCP servers and LangChain tools. |
| LangChain integration for Groq-hosted LLMs. |
| Build agent workflows as a graph (agent ↔ tools loop). |
| Load API keys from |
Important Things to Take Care Of
Weather server must be running before the client — Since it uses HTTP transport, the server process must be started first. The math server (stdio) is auto-spawned by the client.
Groq API key is required — Without it, the LLM calls will fail. Get a free key at console.groq.com.
Never commit
.env— Always add.envto.gitignorebefore pushing code.Port conflicts — The weather server runs on port 8000 by default. If another process uses that port, the server will fail to start.
Windows encoding issue — On Windows, the console may not support UTF-8 characters returned by the LLM. The
client.pyhandles this withsys.stdout.reconfigure(encoding="utf-8").Model availability — The Groq model name (
openai/gpt-oss-120b) must be valid and available on the Groq platform. Check Groq's model list for current options.
This server cannot be installed
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
- Flicense-qualityDmaintenanceA Model Context Protocol (MCP) server that demonstrates mathematical capabilities through a LangChain integration, allowing clients to perform math operations via the MCP protocol.
- Flicense-qualityDmaintenanceDemonstrates custom MCP servers for math and weather operations, enabling multi-agent orchestration using LangChain, Groq, and MCP adapters for both local and remote tool integration.1
- Flicense-qualityCmaintenanceA demonstration MCP server that provides math (add/multiply) and weather tools, connecting via stdio and streamable HTTP, and integrates with LangChain and LangGraph for agentic workflows.
- Flicense-qualityDmaintenanceA collection of MCP servers demonstrating math operations, weather data, and LangGraph workflows.1
Related MCP Connectors
MCP server for AI dialogue using various LLM models via AceDataCloud
MCP server exposing the Backtest360 engine API as tools for AI agents.
MCP server for AI agents to plan, verify, and deploy Cloudflare-native apps.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
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/Reyansh1996/MCPLEARNING'
If you have feedback or need assistance with the MCP directory API, please join our Discord server