This repository provides a client-server example using the Model Context Protocol (MCP), demonstrating how to connect large language models with tools and data. It includes implementations for BMI calculation and
This project demonstrates a client-server implementation using the Model Context Protocol (MCP), a standardized way to connect large language models with tools and data.
This example showcases the creation of an MCP server with custom tools, connecting to the server using an MCP client, and calling tools to get responses from the server.
The project includes a pyproject.toml
file, README.md
, a src
directory containing the client (mcp_client.py
) and server (example_server.py
) implementations, and a uv.lock
file.
The server exposes two tools: calculate_bmi
, which computes Body Mass Index, and fetch_weather
, an async tool that retrieves weather data from an external API.
The client connects to the server via stdio, initializes a session, and calls the server's tools.
To get started, you need Python 3.9+ and uv (Python package manager). Install dependencies using uv install -e .
. Run the example using uv run src/client/mcp_client.py
.
The client connects to the server, lists available tools, calls the BMI calculator with sample data, and calls the weather tool with sample coordinates.
Run mcp dev src/server/example_server.py
and visit http://localhost:5173
to test with the MCP Inspector.
This project uses the Model Context Protocol Python SDK and refers to the MCP Official Documentation.