loading…
Search for a command to run...
loading…
A demonstration MCP server that provides math (add/multiply) and weather tools, connecting via stdio and streamable HTTP, and integrates with LangChain and Lang
A 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.
A simple Python project demonstrating how to build and connect MCP servers using FastMCP, LangChain MCP adapters, LangGraph, and OpenAI.
stdiostreamable-httpSampleMCP/
├── client.py # MCP client + LangGraph agent
├── mathserver.py # Math MCP server with add/multiply tools
├── weather.py # Weather MCP server using streamable HTTP
├── main.py # Basic sample entry point
├── pyproject.toml # Project metadata and dependencies
├── requirements.txt # Python dependencies
└── README.md
Clone the repository:
git clone https://github.com/JayantPrakash/SampleMCP.git
cd SampleMCP
Install dependencies:
pip install -r requirements.txt
Or using uv:
uv sync
Create a .env file in the project root:
OPENAI_API_KEY=your_openai_api_key
GROQ_API_KEY=your_groq_api_key
The weather server uses streamable-http.
python weather.py
By default, it exposes the MCP endpoint at:
http://localhost:8000/mcp
The math server uses stdio and is started automatically by the client through:
"command": "python",
"args": ["mathserver.py"],
"transport": "stdio"
In a separate terminal, run:
python client.py
The client connects to:
mathserver.py through stdioweather.py through streamable_httpIt then creates a LangGraph ReAct agent and asks:
what's (3 + 5) x 12?
and:
what is the weather in California?
Defined in mathserver.py.
add(a: int, b: int) -> int
Adds two numbers.
multiple(a: int, b: int) -> int
Multiplies two numbers.
Defined in weather.py.
get_weather(location: str) -> str
Returns a sample weather response for a given location.
mathserver.py uses transport="stdio".weather.py uses transport="streamable-http".client.py, the streamable HTTP transport is configured as streamable_http.client.py.Math response: 96
Weather response: It's always raining in California
Добавь это в claude_desktop_config.json и перезапусти Claude Desktop.
{
"mcpServers": {
"samplemcp": {
"command": "npx",
"args": []
}
}
}