mcp-client-server-python

mcp-client-server-python

3.3

This project demonstrates a simple client-server Model Context Protocol (MCP) implementation using Python.

The 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. This project showcases a simple client-server setup where the MCP server exposes tools and resources via Server-Sent Events (SSE), and the MCP client connects to the server to list available tools and interact using OpenAI's chat completions. The integration with OpenAI's GPT models allows the client to process user queries and call server tools as needed.

Features

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

Usage with Different Platforms

Start the Server

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

Run the Client

bash
uv run client.py