
MCP HTTP Client Example
Simple example client demonstrating how to connect to MCP servers over HTTP (SSE)
What is MCP HTTP Client Example?
MCP HTTP Client Example is a simple client that demonstrates how to connect to Model Context Protocol (MCP) servers over HTTP using Server-Sent Events (SSE) transport.
How to use MCP HTTP Client Example?
To use the MCP HTTP Client Example, clone the repository and run the example client with the command: uv run -- main.py <server_url>
. For instance, use uv run -- main.py http://localhost:8000/sse
to connect to a local server.
Key features of MCP HTTP Client Example?
- Connects to MCP servers over SSE transport.
- Lists available tools, resources, and prompts from the server.
- Properly handles connection lifecycle with async context managers.
Use cases of MCP HTTP Client Example?
- Connecting to MCP servers for real-time data streaming.
- Listing and utilizing available tools and resources from MCP servers.
- Demonstrating the use of the MCP Python SDK for protocol communication.
FAQ from MCP HTTP Client Example?
- What is the MCP?
The Model Context Protocol (MCP) is a protocol for real-time communication between clients and servers.
- What are the requirements to run this client?
You need to have the
uv
package installed to run the example client.
- Can I connect to any MCP server?
Yes, as long as you have the correct server URL and it supports the MCP.
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:
- Connect to the specified MCP server
- List its available capabilities
- Print them as JSON