4.5 KiB
HTTP MCP Server Without Ping Support
This is a sample MCP server implementation that runs over HTTP but does not support the optional ping method. This demonstrates how to configure Bifrost to use the listTools health check method instead of ping.
What is This?
Many MCP servers may not implement the optional ping method from the MCP specification. This example shows:
- How to build an MCP server that only supports the core methods (
list_tools,call_tool) but notping - How to configure Bifrost to work with such servers using
is_ping_available: false - Why this matters: When
is_ping_availableisfalse, Bifrost will uselistToolsfor health checks instead of the lightweightpingmethod
Running the Server
Prerequisites
go 1.26.1+
Start the Server
# From this directory
go run main.go
Output:
MCP server listening on http://localhost:3001/mcp
Note: This server does NOT support ping. Use is_ping_available=false in Bifrost config.
Connecting via Bifrost
Configuration (config.json)
{
"mcp": {
"client_configs": [
{
"name": "http_no_ping_server",
"connection_type": "http",
"connection_string": "http://localhost:3001/mcp",
"is_ping_available": false,
"tools_to_execute": ["*"]
}
]
}
}
Via API
curl -X POST http://localhost:8080/api/mcp/client \
-H "Content-Type: application/json" \
-d '{
"name": "http_no_ping_server",
"connection_type": "http",
"connection_string": "http://localhost:3001/mcp",
"is_ping_available": false,
"tools_to_execute": ["*"]
}'
Via Web UI
- Navigate to MCP Gateway
- Click New MCP Server
- Fill in:
- Name:
http_no_ping_server - Connection Type: HTTP
- Connection URL:
http://localhost:3001/mcp - Ping Available for Health Check: Toggle OFF (disabled)
- Name:
- Click Create
Available Tools
This server provides three simple tools for testing:
1. echo
Echoes back the input message.
{
"name": "echo",
"arguments": {
"message": "Hello, World!"
}
}
2. add
Adds two numbers together.
{
"name": "add",
"arguments": {
"a": 5,
"b": 3
}
}
3. greet
Greets someone by name.
{
"name": "greet",
"arguments": {
"name": "Alice"
}
}
Health Check Behavior
When you add this server to Bifrost with is_ping_available: false:
- Bifrost will NOT send
pingrequests (since the server doesn't support them) - Instead, Bifrost will use
listToolsevery 10 seconds to check server health - If
listToolsfails 5 consecutive times, the server will be marked asdisconnected
Why listTools instead of ping?
pingis lighter and faster, but optional in MCPlistToolsis heavier but guaranteed to exist on all MCP servers- Using
listToolsfor health checks is a fallback for servers withoutpingsupport
Implementation Notes
This example intentionally:
- ✅ Supports all core MCP methods (list_tools, call_tool)
- ✅ Returns proper JSON-RPC responses
- ✅ Works over HTTP
- ❌ Does NOT implement the
pingmethod - ❌ Returns a JSON-RPC method-not-found error (-32601) when ping is attempted
How Ping is Blocked
The mcp-go library's NewStreamableHTTPServer automatically includes ping support by default. To demonstrate a server without ping, this example uses HTTP middleware that:
- Intercepts all POST requests
- Checks if the request is a
pingmethod call - If it's a ping request, returns a JSON-RPC error:
{"code": -32601, "message": "Method not found: ping is not supported by this server"} - For all other requests (list_tools, call_tool), passes them through normally
This allows us to:
- ✅ Keep the simple mcp-go server implementation
- ✅ Transparently block ping requests at the HTTP layer
- ✅ Return proper JSON-RPC error responses
- ✅ Demonstrate the
is_ping_available=falsebehavior in Bifrost
Key Learning: is_ping_available
The is_ping_available setting is important because:
| Setting | Health Check Method | When to Use |
|---|---|---|
true (default) |
Lightweight ping |
When your server supports ping (recommended) |
false |
Heavier listTools |
When your server doesn't support ping |