This repository demonstrates a minimal Model Context Protocol (MCP) server that exposes a single weather tool alongside two client entry points:
- A configuration JSON (
src/weather-mcp-server.json) that can be consumed by MCP-aware hosts. - A LangChain-based Python client (
src/langchain_weather_client.py) that invokes the MCP tool via OpenAI function calling.
-
Create and activate a virtual environment (optional but recommended).
-
Install the project dependencies:
pip install -e . -
Update the
.envfile with a validOPENAI_API_KEYfor the LangChain example.
The server exposes a single tool named get_weather_by_city that always returns the same weather string. Launch it with:
python src/weather-mcp-server.pyThe server communicates over stdio and is ready to be consumed by any MCP-compatible client.
With the server available on stdio, run:
python src/langchain_weather_client.pyThe script loads the OpenAI API key from .env, asks “I'm going to paris. do I need a raincoat or a winter coat?”, and lets the agent decide when to call the MCP tool before composing a final answer.
src/weather-mcp-server.json provides a simple MCP host configuration snippet that launches the server using stdio. Point your MCP-compatible client to this file (or replicate its content) to register the tool.