mcp-http-client-example

This repository provides a simple example client for connecting to Model Context Protocol (MCP) servers over HTTP using Server-Sent Events, leveraging the official MCP Python SDK for protocol handling and server interaction.

17
0

MCP HTTP Client Example

This is a basic example client demonstrating how to connect to Model Context Protocol (MCP) servers over HTTP, utilizing Server-Sent Events (SSE) for transport. It leverages the official MCP Python SDK to manage protocol communication and interactions with the server.

Features

  • Establishes connections to MCP servers using SSE transport.
  • Retrieves and lists available tools, resources, and prompts offered by the server.
  • Implements proper connection lifecycle management using asynchronous context managers for efficient resource handling.

Requirements

Usage

To use the client, clone the repository and execute the main.py script, providing the server URL as an argument:

uv run -- main.py <server_url>

For instance:

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

The client will then connect to the specified MCP server, retrieve its capabilities, and display them in JSON format.

Documentation

Repository

SL
slavashvets

slavashvets/mcp-http-client-example

Created

January 7, 2025

Updated

March 28, 2025

Language

Python

Category

AI