---
title: "🏓 MCP Ping Utility"
source: Panaversity Learn Agentic AI
source_url: https://github.com/panaversity/learn-agentic-ai
licence: Apache-2.0
domain: agentic-ai
subdomain: panaversity-agentic
date_added: 2026-04-25
---

# 🏓 MCP Ping Utility

> **Analogy:** Think of the ping utility like sonar on a submarine. You send out a "ping" into the dark water. If you hear an echo, you know the connection is alive and can even tell how "far away" the server is by measuring the delay. If you hear nothing, the connection might be lost in the depths. MCP Ping is that sonar for your digital connections.

This lesson demonstrates how to use the simple but vital `ping` utility to monitor connection health and responsiveness.

## 🎯 What You Will Learn

-   **Server-Side**: How `FastMCP` handles `ping` requests automatically, requiring no extra code.
-   **Client-Side**: How to send a `ping` request and handle the empty `pong` (result) response.
-   **Protocol-Level**: How to use `ping` for basic health checks and latency measurement.
-   **Interactive Testing**: How to use Postman to send `ping` requests and validate the server's response against the MCP specification.

## ✅ How to Use This Example

You can test the `ping` utility in two ways:

### 1. Using the Python Client (Automated Test)

This script initializes an MCP session and runs a basic `ping` test.

```bash
# Navigate to the code directory
cd mcp-decoded/02_server_engineering/09_ping/mcp_code

# Terminal 1: Start the server
uv run uvicorn server:mcp_app --reload

# Terminal 2: Run the client test
uv run client.py
```

### 2. Using the Postman Collection (Interactive Test)

This is the best way to see the request/response flow for yourself.

1.  **Start the Server**: Make sure the Python server from the step above is running.
2.  **Use the Collection**: Open the `postman/` directory and import the `MCP_Ping_Tests.postman_collection.json` file into Postman.
3.  **Follow the Instructions**: The collection's `README.md` provides a step-by-step guide for testing the `ping` lifecycle. You will initialize a connection and then send pings.

## ⚙️ The Code

-   `mcp_code/server.py`: A minimal `FastMCP` server. Notice that there is no special code for `ping`—the framework handles it for you, which is a key lesson here.
-   `mcp_code/client.py`: A simple Python client that connects to the server, sends a `ping`, and prints the result.
-   `postman/`: Contains the Postman collection for interactive testing and its documentation.

## 🎯 Key Takeaway

MCP ping is the simplest but most essential utility for connection health. Master this foundation before moving to more complex utilities like logging and progress tracking! 🏓
