mcp_server_client_example
If you are the rightful owner of mcp_server_client_example and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.
This document provides an example of setting up a Model Context Protocol (MCP) client and server using Python.
MCP Client & Server Example
Prerequisites
- Python 3.12 or higher
- uv (Python package installer and environment manager)
- Environment variables set up in
.env
file (for Anthropic API key)
Installation
-
Clone the repository
-
Install uv if you haven't already:
curl -LsSf https://astral.sh/uv/install.sh | sh
- Create and activate a new environment:
uv venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
- Install dependencies using uv:
uv pip install -e .
- Configure .env by copying
.env.example
to.env
and filling in your Anthropic API key:
Project Structure
- Simple client and server
weather_server.py
- MCP server implementation with weather service endpoints
- Client example and Server example
weather_example.py
- Example implementation using the National Weather Service APIclient_example.py
- Interactive client with Claude AI integration