๐ MCP Ping-Pong Server with FastAPI
LocalAbout ๐ MCP Ping-Pong Server with FastAPI
An educational FastAPI project that demonstrates remote MCP calls through HTTP endpoints and SSE. It is intended for developers exploring MCP command handling and session management.
Key features
- 01FastAPI and FastMCP backend
- 02HTTP API and SSE transports
- 03Ping, pong, and count commands
- 04Thread-safe session management
- 05Prompt retrieval endpoint
Use cases
- 01Testing MCP commands over HTTP
- 02Trying MCP communication through SSE
- 03Studying remote MCP session handling
MCP support
The project runs an MCP server and demonstrates remote calls through API endpoints or SSE. It exposes ping, pong, and count commands, plus prompt retrieval.
Configuration
Local server config is the same for every client. Copy it into your clientโs MCP config file.
We havenโt collected a package or remote endpoint for this server. Follow the instructions in the project README.
Tools
Local servers expose tools only once running on your machine, and the maintainer has not provided a tool list.
Details
From the project README๐ MCP Ping-Pong Server by Remote Call
An experimental and educational Ping-Pong server demonstrating MCP (Model Context Protocol) calls via FastAPI.
Features
- โ FastAPI/FastMCP backend for remote MCP calls through API endpoints or SSE
- ๐ MCP integration for command handling
- ๐ Thread-safe session management
Quick Start
Installation
To install the dependencies, run:
poetry install
1. Call MCP Tool through API
Run the Server
Start the FastAPI server with:
python mcp-api-server.py
The server will start at http://localhost:8080.
UI
Open mcp-api-client.html in a browser to interact with the UI.
API Endpoints
GET /ping-pong?prompt_name=<prompt_name>: Retrieves the specified prompt.POST /ping-pong: Invokes MCP tool commands (ping,pong,count).
2. Call MCP Tool through SSE transport
The following example demonstrates using Server-Sent Events (SSE) for communication with the MCP server.
Run the SSE Server
python mcp-sse-server.py
Run the SSE Client
python mcp-sse-client.py
Sample Output
Type a command (e.g., 'ping', 'pong', 'count') or 'exit' to quit:
>>> ping
Sending command: ping
Result: pong
>>> pong
Sending command: pong
Result: ping
>>> count
Sending command: count
Result: 2
References
๐ License
MIT
Comments
New to MCP?
From what the protocol is to installing your first server, these answers cover most first questions.
An open protocol that defines how AI applications connect to external tools and data in a uniform way. Clients talk to the model; MCP servers provide tools, resources and prompt templates. They exchange standard messages, so one server can be reused by many clients.