MCP Client-Server Python Example
@sofianhw
About MCP Client-Server Python Example
Basic implementation mcp client server
Config
Add this server to your MCP-compatible client using the configuration below.
{
"mcpServers": {
"mcp-client-server-python": {
"command": "uv",
"args": [
"sync"
]
}
}
}Tools
No tools detected
We auto-extract tools from the README. The maintainer can list them under a ## Tools heading to populate this section.
Overview
What is MCP Client-Server Python Example?
This project demonstrates a simple client-server implementation of the Model Context Protocol (MCP), an open protocol by Anthropic that enables large language models to interact with external tools and resources. It is intended for developers learning how to build MCP servers and clients using Python.
How to use MCP Client-Server Python Example?
Install dependencies with uv sync, create a .env file with OPENAI_API_KEY and MCP_SSE_URL, start the server with uv run server.py --host 0.0.0.0 --port 8080, then run the client with uv run client.py. The client will list available tools and start an interactive chat loop. Type quit to exit.
Key features of MCP Client-Server Python Example
- Exposes tools (e.g., addition) and resources (e.g., greetings) via SSE.
- Client connects to server and lists available tools.
- Uses OpenAI GPT models to process queries and call tools.
- Built with Python 3.12+ and the MCP Python SDK.
- Uses SSE (Server-Sent Events) for transport.
- Managed with
uvfor fast dependency resolution.
Use cases of MCP Client-Server Python Example
- Learning how to build an MCP server and client from scratch.
- Prototyping an agentic workflow where an LLM calls external tools.
- Testing SSE-based communication between MCP components.
- Demonstrating integration of MCP with OpenAI’s chat completions API.
- Educational reference for implementing the Model Context Protocol.
FAQ from MCP Client-Server Python Example
What is MCP?
MCP stands for Model Context Protocol, an open protocol introduced by Anthropic that allows language models to interact with external tools, APIs, and resources in a standardized and secure way. It supports agentic workflows and multi-channel communication.
What are the runtime requirements?
Python 3.12 or higher, along with the MCP Python SDK, OpenAI Python SDK, Uvicorn, python-dotenv, and uv as the package installer.
How do I set up the server?
Create a .env file with an OPENAI_API_KEY and the server SSE URL (MCP_SSE_URL=http://localhost:8080/sse), then run uv run server.py --host 0.0.0.0 --port 8080. The server exposes tools and resources at the /sse endpoint.
How do I run the client?
In a separate terminal, run uv run client.py. The client will connect to the server, list available tools, and start an interactive prompt. Type your query, and the client uses OpenAI to decide whether to call a server tool.
How do I stop the client?
Type quit at the prompt to exit the interactive chat loop.
Frequently asked questions
What is MCP?
MCP stands for Model Context Protocol, an open protocol introduced by Anthropic that allows language models to interact with external tools, APIs, and resources in a standardized and secure way. It supports agentic workflows and multi-channel communication.
What are the runtime requirements?
Python 3.12 or higher, along with the MCP Python SDK, OpenAI Python SDK, Uvicorn, python-dotenv, and `uv` as the package installer.
How do I set up the server?
Create a `.env` file with an `OPENAI_API_KEY` and the server SSE URL (`MCP_SSE_URL=http://localhost:8080/sse`), then run `uv run server.py --host 0.0.0.0 --port 8080`. The server exposes tools and resources at the `/sse` endpoint.
How do I run the client?
In a separate terminal, run `uv run client.py`. The client will connect to the server, list available tools, and start an interactive prompt. Type your query, and the client uses OpenAI to decide whether to call a server tool.
How do I stop the client?
Type `quit` at the prompt to exit the interactive chat loop.
Basic information
More Other MCP servers
🪟 Windows-MCP
CursorTouchMCP Server for Computer Use in Windows
XcodeBuildMCP
cameroncookeA Model Context Protocol (MCP) server and CLI that provides tools for agent use when working on iOS and macOS projects.
MCP Toolbox for Databases
googleapisMCP Toolbox for Databases is an open source MCP server for databases.

Glasswarp
GlasswarpSee and control a real Windows PC you own — from any MCP client, locally or remotely. Observe (UIA + screenshots), click/type/drag/scroll, launch apps, owner Live View. BYOH: your machine, your key.

DeepMark
DeepMark helps teachers deliver rapid, consistent marking with meaningful feedback for every student — in a fraction of the time. What once took a week, now takes one free period.
Comments