🏓 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
Recommend MCP Servers 💡
mcp-national-rail
A Model Context Protocol (MCP) server to retrieve train schedules from National Rail
4oimage-mcp
An MCP server integrating with 4o-image API for LLMs to generate and edit images from text prompts.
lean-docker-mcp
A Dockerized Lean4 execution environment MCP server for AI agents, providing isolated code execution with transient or persistent environments.
Ryuhei-So/mermaid-cli-server
A MCP server that generates PNG images from Mermaid markdown using @mermaid-js/mermaid-cli.
Token-Minter-MCP
An MCP server providing tools for AI agents to mint ERC-20 tokens across multiple blockchains.
SharkMCP
An MCP server that integrates with Wireshark/tshark for network packet capture and analysis, enabling AI assistants to debug network traffic.