py-mcp-sse logo

py-mcp-sse

by jayliangdl

This project provides a sample implementation of an MCP Client and MCP Server in Python, based on SSE. It utilizes OpenRouter.ai for LLM calls, adapting from a previous version that used ANTHROPIC LLM.

View on GitHub

Last updated: N/A

What is py-mcp-sse?

This is an MCP (Model Context Protocol) server and client implementation using Server-Sent Events (SSE). The server provides a tool for searching books using the Gutenberg Project API, and the client can connect to and use the server's tools.

How to use py-mcp-sse?

  1. Clone the repository. 2. Configure the environment by installing dependencies using uv or pip and setting the OpenRouter API key in the .env file. 3. Start the server using uv run mcp_server.py (optionally specifying host and port). 4. Start the client using uv run client.py http://localhost:8080/sse.

Key features of py-mcp-sse

  • SSE-based communication

  • MCP client and server implementation

  • Gutenberg Project book search tool

  • OpenRouter.ai LLM integration

  • Decoupled server and client processes

Use cases of py-mcp-sse

  • Integrating LLMs with external tools

  • Building cloud-native applications using MCP

  • Creating AI assistants with access to knowledge bases

  • Implementing a decoupled client-server architecture for AI services

FAQ from py-mcp-sse

What Python version is required?

Python 3.13 or higher is required.

How do I configure the OpenRouter API key?

Copy the .env.sample file to .env and edit the .env file, filling in your OpenRouter API key.

How do I start the server?

Use the command uv run mcp_server.py. You can optionally specify the host and port using --host and --port.

How do I start the client?

Use the command uv run client.py http://localhost:8080/sse.

What if port 8080 is already in use?

You can specify a different port using the --port parameter when starting the server, e.g., uv run mcp_server.py --port 8081.