MCP Ping-Pong Server by Remote Call

MCP Ping-Pong Server by Remote Call

An experimental MCP-based Ping-Pong server leveraging FastAPI and FastMCP for remote calls.

1
Stars
2
Forks
1
Watchers
1
Issues
MCP Ping-Pong Server by Remote Call demonstrates the use of the Model Context Protocol (MCP) for handling command-based interactions via FastAPI. The project provides a backend powered by FastAPI and FastMCP, enabling remote MCP calls through API endpoints and Server-Sent Events (SSE). It includes thread-safe session management, command handling integration, and an interactive UI for engaging with ping, pong, and count operations. Designed as an educational tool, it showcases practical MCP usage for API-driven workflows.

Key Features

Remote MCP calls through FastAPI endpoints
Server-Sent Events (SSE) integration for asynchronous communication
Thread-safe session handling
Command-based interaction support (ping, pong, count)
Interactive HTML client for API usage
Educational Ping-Pong server example
Integration with FastMCP backend
Quick setup and installation with Poetry
API documentation and examples
Demonstrates MCP tool command invocation

Use Cases

Learning and demonstrating the Model Context Protocol in Python
Building MCP-compliant backend services
Experimenting with remote command execution over HTTP or SSE
Educational projects on context-aware server design
Developing APIs for interactive command tools
Prototyping threaded session management in web servers
Showcasing FastAPI and FastMCP integration
Testing command-based workflows for AI toolchains
Demonstrating server-client interactions with custom commands
Interactive classroom or workshop exercises on protocol usage

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:

bash
poetry install

1. Call MCP Tool through API

Run the Server

Start the FastAPI server with:

bash
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

bash
python mcp-sse-server.py

Run the SSE Client

bash
python mcp-sse-client.py

Sample Output

bash
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

Star History

Star History Chart

Repository Owner

kimtth
kimtth

User

Repository Details

Language HTML
Default Branch main
Size 207 KB
Contributors 1
MCP Verified Nov 12, 2025

Programming Languages

HTML
63.08%
Python
36.92%

Tags

Topics

fastapi fastmcp mcp mcp-client mcp-server model-context-protocol sse

Join Our Newsletter

Stay updated with the latest AI tools, news, and offers by subscribing to our weekly newsletter.

We respect your privacy. Unsubscribe at any time.

Related MCPs

Discover similar Model Context Protocol servers

  • FastMCP

    FastMCP

    TypeScript framework for building robust MCP servers with minimal setup.

    FastMCP is a TypeScript framework designed for building servers that adhere to the Model Context Protocol (MCP), enabling efficient management of client sessions and context. It streamlines the creation of MCP servers by providing intuitive APIs, built-in authentication, session and request tracking, and support for handling various content types such as images and audio. The framework also enforces best practices around error handling, logging, and streaming outputs. Developers benefit from reduced boilerplate and a focus on core MCP functionality.

    • 2,738
    • MCP
    • punkpeye/fastmcp
  • FastMCP

    FastMCP

    The fast, Pythonic way to build MCP servers and clients.

    FastMCP is a production-ready framework for building Model Context Protocol (MCP) applications in Python. It streamlines the creation of MCP servers and clients, providing advanced features such as enterprise authentication, composable tools, OpenAPI/FastAPI generation, server proxying, deployment tools, and comprehensive client libraries. Designed for ease of use, it offers both standard protocol support and robust utilities for production deployments.

    • 20,201
    • MCP
    • jlowin/fastmcp
  • mcp-cli

    mcp-cli

    A command-line inspector and client for the Model Context Protocol

    mcp-cli is a command-line interface tool designed to interact with Model Context Protocol (MCP) servers. It allows users to run and connect to MCP servers from various sources, inspect available tools, resources, and prompts, and execute commands non-interactively or interactively. The tool supports OAuth for various server types, making integration and automation seamless for developers working with MCP-compliant servers.

    • 391
    • MCP
    • wong2/mcp-cli
  • Model Context Protocol Server for Home Assistant

    Model Context Protocol Server for Home Assistant

    Seamlessly connect Home Assistant to LLMs for natural language smart home control via MCP.

    Enables integration between a local Home Assistant instance and language models using the Model Context Protocol (MCP). Facilitates natural language monitoring and control of smart home devices, with robust API support for state management, automation, real-time updates, and system administration. Features secure, token-based access, and supports mobile and HTTP clients. Designed to bridge Home Assistant environments with modern AI-driven automation.

    • 468
    • MCP
    • tevonsb/homeassistant-mcp
  • ws-mcp

    ws-mcp

    WebSocket bridge for MCP stdio servers.

    ws-mcp wraps Model Context Protocol (MCP) stdio servers with a WebSocket interface, enabling seamless integration with web-based clients and tools. It allows users to configure and launch multiple MCP servers via a flexible configuration file or command-line arguments. The tool is designed to be compatible with services such as wcgw, fetch, and other MCP-compliant servers, providing standardized access to system operations, HTTP requests, and more. Integration with tools like Kibitz enables broader applications in model interaction workflows.

    • 19
    • MCP
    • nick1udwig/ws-mcp
  • Perplexity MCP Server

    Perplexity MCP Server

    MCP Server integration for accessing the Perplexity API with context-aware chat completion.

    Perplexity MCP Server provides a Model Context Protocol (MCP) compliant server that interfaces with the Perplexity API, enabling chat completion with citations. Designed for seamless integration with clients such as Claude Desktop, it allows users to send queries and receive context-rich responses from Perplexity. Environment configuration for API key management is supported, and limitations with long-running requests are noted. Future updates are planned to enhance support for client progress reporting.

    • 85
    • MCP
    • tanigami/mcp-server-perplexity
  • Didn't find tool you were looking for?

    Be as detailed as possible for better results