mcp-http-client-example

MCP.Pizza Chef: slavashvets

The mcp-http-client-example is a simple, lightweight client demonstrating how to connect to Model Context Protocol (MCP) servers over HTTP using Server-Sent Events (SSE). Built with the official MCP Python SDK, it manages protocol communication and server interactions asynchronously. This client connects to MCP servers, lists available tools, resources, and prompts, and handles connection lifecycle properly with async context managers. It serves as a practical reference for developers integrating MCP clients with HTTP SSE transport, showcasing real-time context flow and tool discovery.

Use This MCP client To

Connect to MCP servers using HTTP SSE transport List available tools and resources from MCP servers Demonstrate async connection lifecycle management Serve as a reference implementation for MCP client development Test MCP server capabilities and responses

README

MCP HTTP Client Example

Simple example client demonstrating how to connect to Model Context Protocol (MCP) servers over HTTP using Server-Sent Events (SSE) transport.

Uses the official MCP Python SDK to handle protocol communication and server interactions.

Features

  • Connects to MCP servers over SSE transport
  • Lists available tools, resources and prompts
  • Properly handles connection lifecycle with async context managers

Requirements

Usage

Clone this repository, then run the example client:

uv run -- main.py <server_url>

For example:

uv run -- main.py http://localhost:8000/sse

The client will:

  1. Connect to the specified MCP server
  2. List its available capabilities
  3. Print them as JSON

Documentation

mcp-http-client-example FAQ

How do I run the mcp-http-client-example?
Clone the repository and run `uv run -- main.py <server_url>`, replacing `<server_url>` with your MCP server's SSE endpoint.
What transport protocol does this client use to connect to MCP servers?
It uses HTTP Server-Sent Events (SSE) for real-time communication.
Does the client support asynchronous operations?
Yes, it uses async context managers to properly handle connection lifecycle and communication.
What dependencies are required to run this client?
The client requires the 'uv' tool for running the Python script and the official MCP Python SDK for protocol handling.
Can this client list all available tools and prompts from an MCP server?
Yes, it connects to the server and prints available capabilities as JSON.
Is this client suitable for production use?
It is primarily a simple example and reference implementation, ideal for learning and testing MCP server interactions.
Where can I find more documentation about MCP and this client?
Refer to the MCP Specification at spec.modelcontextprotocol.io and the MCP Python SDK GitHub repository.
Can this client be used with different MCP servers?
Yes, as long as the server supports HTTP SSE transport, this client can connect and interact with it.