Skip to content

fix: implement ping method in MCP server - #726

Closed
arnoldwender wants to merge 1 commit into
MemPalace:mainfrom
arnoldwender:fix/ping-method-mcp-server
Closed

fix: implement ping method in MCP server#726
arnoldwender wants to merge 1 commit into
MemPalace:mainfrom
arnoldwender:fix/ping-method-mcp-server

Conversation

@arnoldwender

Copy link
Copy Markdown
Contributor

What does this PR do?

Adds a ping handler to the MCP stdio dispatch loop.

MCP clients such as AnythingLLM v1.12.0 send a ping health-check immediately after connecting. Without a handler the server returns {"code": -32601, "message": "Unknown method: ping"}, which causes the client to kill and restart the server in an infinite loop.

The fix adds a single branch that responds with an empty result object, as specified by the MCP protocol:

{"jsonrpc": "2.0", "id": <req_id>, "result": {}}

Fixes #584

How to test

  1. Connect AnythingLLM v1.12.0 (or any MCP client that sends ping) to the server
  2. Confirm the server stays up instead of restarting in a loop

Or directly:

echo '{"jsonrpc":"2.0","id":1,"method":"ping","params":{}}' | python -m mempalace mcp run
# Expected: {"jsonrpc": "2.0", "id": 1, "result": {}}

Checklist

  • Tests pass (python -m pytest tests/ -v)
  • No hardcoded paths
  • Linter passes (ruff check .)

MCP clients such as AnythingLLM v1.12.0 send a ping health-check on
connect. Without a handler the server returns -32601 Unknown method,
which causes the client to restart the server in a loop.

Respond with an empty result object as the MCP spec requires.

Fixes MemPalace#584
@arnoldwender

Copy link
Copy Markdown
Contributor Author

Closing — PR #600 by @grtninja was already merged with the same fix. I wasn't aware it had landed. Sorry for the noise.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant