Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ldk-server-mcp/CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ src/
- **Version**: `2025-11-25`
- **Spec**: https://spec.modelcontextprotocol.io/
- **Transport**: stdio (one JSON-RPC 2.0 message per line)
- **Methods implemented**: `initialize`, `tools/list`, `tools/call`
- **Methods implemented**: `initialize`, `tools/list`, `tools/call`, `ping`
Comment thread
benthecarman marked this conversation as resolved.
- **Notifications handled**: `notifications/initialized` (ignored, no response)

## Config
Expand Down
2 changes: 1 addition & 1 deletion ldk-server-mcp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ Streaming RPCs such as `subscribe_events` and non-RPC HTTP endpoints such as `me

- **Protocol version**: `2025-11-25`
- **Transport**: stdio (one JSON-RPC 2.0 message per line)
- **Methods**: `initialize`, `tools/list`, `tools/call`
- **Methods**: `initialize`, `tools/list`, `tools/call`, `ping`

## Testing

Expand Down
5 changes: 5 additions & 0 deletions ldk-server-mcp/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,11 @@ async fn main() {
let resp = JsonRpcResponse::new(id, serde_json::json!({ "tools": tools }));
serde_json::to_string(&resp).unwrap()
},
"ping" => {
// Per the MCP spec, a ping must be answered with an empty result object.
let resp = JsonRpcResponse::new(id, serde_json::json!({}));
serde_json::to_string(&resp).unwrap()
},
"tools/call" => {
let params = request.params.unwrap_or(Value::Null);
match params.get("name").and_then(|v| v.as_str()) {
Expand Down
19 changes: 19 additions & 0 deletions ldk-server-mcp/tests/integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,25 @@ fn test_tools_list() {
}
}

#[test]
fn test_ping() {
let mut proc = McpProcess::spawn();

proc.send(&json!({
"jsonrpc": "2.0",
"id": 1,
"method": "ping"
}));

let resp = proc.recv();
assert_eq!(resp["jsonrpc"], "2.0");
assert_eq!(resp["id"], 1);
// Per the MCP spec, ping is answered with an empty result object.
assert!(resp["result"].is_object(), "Expected result object, got: {}", resp["result"]);
assert_eq!(resp["result"].as_object().unwrap().len(), 0, "Expected empty result object");
assert!(resp.get("error").is_none(), "Ping must not return an error");
}

#[test]
fn test_tools_call_unknown_tool() {
let mut proc = McpProcess::spawn();
Expand Down
Loading