MCP Client & Server Example logo

MCP Client & Server Example

by xiaoye-hua

This project provides a simple client and server example using the Model Context Protocol (MCP). It includes a weather service implementation and an interactive client with Claude AI integration.

View on GitHub

Last updated: N/A

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

  1. Clone the repository

  2. Install uv if you haven't already:

curl -LsSf https://astral.sh/uv/install.sh | sh
  1. Create and activate a new environment:
uv venv
source .venv/bin/activate  # On Windows: .venv\Scripts\activate
  1. Install dependencies using uv:
uv pip install -e .
  1. 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 API
    • client_example.py - Interactive client with Claude AI integration