MCPMathServer
by vrxtxxx
README.md
# MCPMathServer
A Model Context Protocol (MCP) server exposing math and weather tools, with a LangChain agent client powered by Groq.
## Features
- **Math tools** — `add`, `subtract`, `multiply` via MCP stdio transport
- **Weather tool** — `get_weather` via MCP streamable HTTP transport (placeholder)
- **Agent client** — LangChain agent that connects to both MCP servers and answers natural-language queries using `ChatGroq`
## Prerequisites
- Python 3.12+
- A [Groq API key](https://console.groq.com/)
## Setup
```bash
# Clone and enter the project
git clone <repo-url> && cd MCPMathServer
# Install dependencies with uv (virtual environment is created automatically)
uv init
# For virtual environment:
uv venv
```
Create a `.env` file in the project root:
```
GROQ_API_KEY=your_groq_api_key_here
```
## Usage
### Run the math server (stdio)
```bash
python mathserver.py
```
### Run the weather server (streamable HTTP)
```bash
python weather.py
```
### Run the agent client
```bash
python client.py
```
The client connects to both servers, then sends example queries:
- `"what's (3 + 5) x 12?"` — routed to the math server
- `"what is the weather in California?"` — routed to the weather server
## Project Structure
```
MCPMathServer/
├── mathserver.py # MCP math tool server (stdio)
├── weather.py # MCP weather tool server (streamable HTTP)
├── client.py # LangChain agent client
├── main.py # Entry point placeholder
├── pyproject.toml # Project metadata & dependencies
├── requirements.txt # Pip dependencies
└── .env # API keys (not committed)
```
## Dependencies
- [FastMCP](https://github.com/jlowin/fastmcp) — MCP server framework
- [LangChain](https://github.com/langchain-ai/langchain) — Agent framework
- [LangChain Groq](https://github.com/langchain-ai/langchain) — Groq LLM integration
- [LangChain MCP Adapters](https://github.com/langchain-ai/langchain-mcp-adapters) — MCP transport adapters
- [LangGraph](https://github.com/langchain-ai/langgraph) — Agent orchestration
This server cannot be deployed
Maintenance
ActivitySlowing
ResponsivenessNo issues