sofianhw
MCP Serversofianhwpublic

mcp client server python

Basic implementation mcp client server

Repository Info

0
Stars
0
Forks
0
Watchers
0
Issues
Python
Language
-
License

About This Server

Basic implementation mcp client server

Model Context Protocol (MCP) - This server can be integrated with AI applications to provide additional context and capabilities, enabling enhanced AI interactions and functionality.

Documentation

MCP Client-Server Python Example

This project demonstrates a simple client-server MCP.


What is MCP (Model Context Protocol)?

MCP is an open protocol introduced by Anthropic to enable large language models (LLMs) to interact with external tools, APIs, and resources in a standardized, extensible way.
It facilitates secure, multi-channel communication between AI models and external systems, supporting advanced agentic workflows and tool use.

🔗 Anthropic's announcement
🔗 MCP documentation


Features

  • MCP Server: Exposes tools (e.g., addition) and resources (e.g., greetings) via SSE.
  • MCP Client: Connects to the server, lists available tools, and interacts using OpenAI's chat completions.
  • OpenAI Integration: Uses OpenAI's GPT models to process user queries and call server tools as needed.

Requirements

  • Python 3.12+
  • MCP Python SDK
  • OpenAI Python SDK
  • Uvicorn (for running the server)
  • python-dotenv (for loading environment variables)
  • uv (fast Python package installer and resolver)

Project Structure

.
├── client.py      # MCP client implementation
├── server.py      # MCP server implementation
├── pyproject.toml # Project metadata and dependencies
├── .env           # Environment variables (not committed)
└── README.md      # This file

Install dependencies with uv:

uv sync

(This will install all dependencies as specified in uv.lock.)


Setup

  1. Environment Variables

    Create a .env file in the project directory:

    OPENAI_API_KEY=your-openai-api-key
    MCP_SSE_URL=http://localhost:8080/sse
    
  2. Start the Server

    uv run server.py --host 0.0.0.0 --port 8080
    

    The server exposes tools and resources via SSE at /sse.

  3. Run the Client

    In another terminal:

    uv run client.py
    

    The client will connect to the server, list available tools, and start an interactive chat loop.


Usage

  • Type your queries in the client prompt.
  • The client will use OpenAI to process your query and call server tools if needed.
  • Type quit to exit the client.

Quick Start

1

Clone the repository

git clone https://github.com/sofianhw/mcp-client-server-python
2

Install dependencies

cd mcp-client-server-python
npm install
3

Follow the documentation

Check the repository's README.md file for specific installation and usage instructions.

Repository Details

Ownersofianhw
Repomcp-client-server-python
LanguagePython
License-
Last fetched8/10/2025

Recommended MCP Servers

💬

Discord MCP

Enable AI assistants to seamlessly interact with Discord servers, channels, and messages.

integrationsdiscordchat
🔗

Knit MCP

Connect AI agents to 200+ SaaS applications and automate workflows.

integrationsautomationsaas
🕷️

Apify MCP Server

Deploy and interact with Apify actors for web scraping and data extraction.

apifycrawlerdata
🌐

BrowserStack MCP

BrowserStack MCP Server for automated testing across multiple browsers.

testingqabrowsers

Zapier MCP

A Zapier server that provides automation capabilities for various apps.

zapierautomation