MCP HTTP Client Example logo

MCP HTTP Client Example

by slavashvets

A simple example client demonstrating how to connect to Model Context Protocol (MCP) servers over HTTP using Server-Sent Events (SSE) transport. It uses the official MCP Python SDK to handle protocol communication and server interactions.

View on GitHub

Last updated: N/A

What is MCP HTTP Client Example?

This is a simple example client built to connect to Model Context Protocol (MCP) servers over HTTP using Server-Sent Events (SSE). It's designed to demonstrate basic interaction with an MCP server.

How to use MCP HTTP Client Example?

Clone the repository. Ensure you have uv installed. Run the client using the command uv run -- main.py <server_url> providing the MCP server's SSE endpoint URL. The client will connect, list available capabilities, and print them as JSON.

Key features of MCP HTTP Client Example

  • Connects to MCP servers over SSE transport

  • Lists available tools, resources, and prompts

  • Properly handles connection lifecycle with async context managers

  • Uses the official MCP Python SDK

Use cases of MCP HTTP Client Example

  • Testing MCP server implementations

  • Learning how to interact with MCP servers

  • Demonstrating basic MCP client functionality

  • Prototyping MCP client applications

FAQ from MCP HTTP Client Example

What is MCP?

Model Context Protocol. See https://spec.modelcontextprotocol.io

What is SSE?

Server-Sent Events. A server push technology enabling real-time data streaming.

What is the MCP Python SDK used for?

It handles the protocol communication and server interactions.

What are the 'tools, resources, and Prompts' being listed?

They are properties of the MCP services.

What is uv?

uv is a very fast Python package installer and resolver, written in Rust. See https://github.com/astral-sh/uv