Skip to content

Commit 6ca0670

Browse files
jpheinclaude
andauthored
fix(mcp): stub resources/list + prompts/list so MCP clients stop ERROR-logging (#107)
opencode 1.15.x and other MCP clients probe `resources/list` and `prompts/list` on connect to discover server capabilities. mempalace's MCP server only exposes tools; these probes returned `-32601: Unknown method`, which clients log as ERROR even though the result is benign (no resources, no prompts). Two log-noise lines per session. Both methods are optional per the MCP spec. Return empty lists instead of the error, matching what other MCP servers without resources/prompts do (e.g. server-everything, filesystem reference server). Tests: tests/test_mcp_server.py — two new TestProtocol cases assert the empty-list shape and absence of ERROR. Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent dfe3cb8 commit 6ca0670

2 files changed

Lines changed: 32 additions & 0 deletions

File tree

mempalace/mcp_server.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3029,6 +3029,17 @@ def handle_request(request):
30293029
]
30303030
},
30313031
}
3032+
elif method == "resources/list":
3033+
# MCP spec optional method. We don't expose any resources — the
3034+
# palace surfaces drawers via the tools/call interface, not via
3035+
# the resource model. Return an empty list rather than -32601 so
3036+
# clients that probe on connect (e.g. OpenCode 1.15.x) don't log
3037+
# an ERROR every session. (#-32601-noise / fork follow-up.)
3038+
return {"jsonrpc": "2.0", "id": req_id, "result": {"resources": []}}
3039+
elif method == "prompts/list":
3040+
# MCP spec optional method. We don't expose any prompts. Same
3041+
# rationale as resources/list above — quiet client probes.
3042+
return {"jsonrpc": "2.0", "id": req_id, "result": {"prompts": []}}
30323043
elif method == "tools/call":
30333044
if not isinstance(params, dict) or "name" not in params:
30343045
return {

tests/test_mcp_server.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -537,6 +537,27 @@ def test_tools_list(self):
537537
assert "mempalace_add_drawer" in names
538538
assert "mempalace_kg_add" in names
539539

540+
def test_resources_list_returns_empty_not_error(self):
541+
"""MCP clients (OpenCode 1.15.x, others) probe ``resources/list`` on
542+
connect. We don't expose any resources — the palace surfaces drawers
543+
via ``tools/call`` — but return ``{resources: []}`` rather than
544+
``-32601`` so the client doesn't log an ERROR every session."""
545+
from mempalace.mcp_server import handle_request
546+
547+
resp = handle_request({"method": "resources/list", "id": 7, "params": {}})
548+
assert "error" not in resp
549+
assert resp["result"] == {"resources": []}
550+
551+
def test_prompts_list_returns_empty_not_error(self):
552+
"""Same rationale as ``test_resources_list_returns_empty_not_error``:
553+
``prompts/list`` is an optional MCP method some clients probe on
554+
connect; returning an empty list quiets the noise."""
555+
from mempalace.mcp_server import handle_request
556+
557+
resp = handle_request({"method": "prompts/list", "id": 8, "params": {}})
558+
assert "error" not in resp
559+
assert resp["result"] == {"prompts": []}
560+
540561
def test_null_arguments_does_not_hang(self, monkeypatch, config, palace_path, seeded_kg):
541562
"""Sending arguments: null should return a result, not hang (#394)."""
542563
_patch_mcp_server(monkeypatch, config, seeded_kg)

0 commit comments

Comments
 (0)