feat(mcp): implement resources/templates/list as static empty catalog#2828
Conversation
Compliant MCP clients probe resources/templates/list whenever the resources capability is advertised. The current catalog is fully static, so the spec-compliant response is an empty array. Without the handler the server returns -32601 and pollutes client debug surfaces. Fixes tinyhumansai#2826
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (5)
📝 WalkthroughWalkthroughThis PR implements the missing ChangesResource Templates List Handler
Sequence DiagramsequenceDiagram
participant Client
participant handle_request
participant list_resource_templates_result
Client->>handle_request: JSON-RPC resources/templates/list
handle_request->>list_resource_templates_result: route to handler
list_resource_templates_result->>list_resource_templates_result: return {resourceTemplates: []}
handle_request->>Client: success response
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
graycyrus
left a comment
There was a problem hiding this comment.
Clean, well-scoped fix. This is exactly what a spec-compliance stub should look like.
The new arm follows the same dispatch shape as resources/list and resources/read — consistent logging prefix, success_response wrapper, delegate to a pure helper. list_resource_templates_result() is correctly side-effect-free aside from the debug trace. Three tests cover the helper directly, the bare wire-through, and the cursor-param tolerance case — all the acceptance criteria from #2826 are hit.
One minor observation worth noting: list_resource_templates_result() emits its own log::debug! trace from inside the helper, while the dispatch arm in protocol.rs already logs the request entry. That means every resources/templates/list call produces two debug lines. For the sibling resources/list handler the count is dynamic so the helper-level trace carries information; here it will always print count=0. Not a blocker — debug noise only — but worth cleaning up in a follow-up if log verbosity becomes a concern.
Docs are thorough: English + zh-CN both updated, coverage matrix row added, smoke snippet exercises the new method. Nothing left loose.
Approved.
Summary
resources/templates/listhandler to the MCP stdio + HTTP server, returning{ "resourceTemplates": [] }because the bundled prompt catalog is fully static (every URI is concrete).-32602 Invalid params.resources: { subscribe: false, listChanged: false }); only the handler dispatch surface grows.handle_json_value) and a new coverage matrix row 11.1.8.gitbooks/developing/mcp-server.md(and the zh-CN mirror) with a Resource Templates note and extends the smoke-test snippet.Problem
The
initializeblock already advertises theresourcescapability (#2745). MCP clients that see that capability are invited by the spec to proberesources/templates/list. Today the server replies:{ "error": { "code": -32601, "message": "Method not found", "data": "unsupported MCP method `resources/templates/list`" } }Compliant clients (Claude Desktop, Cursor, Zed) treat the
-32601as a graceful fallback but log it as a spec violation, polluting their debug surfaces and signalling an incomplete server. The catalog has no templated URIs so the correct response is an empty array.Solution
src/openhuman/mcp_server/resources.rsgainspub fn list_resource_templates_result() -> Valuereturningjson!({ "resourceTemplates": [] }). Pure, no I/O.src/openhuman/mcp_server/protocol.rsadds a"resources/templates/list"match arm that calls the new helper and alog::debug!trace mirroring the existing resources handlers.Verified end-to-end against the built
openhuman-corebinary:Submission Checklist
diff-cover) meet the gate enforced by.github/workflows/coverage.yml. All new Rust lines are exercised by the new tests.docs/TEST-COVERAGE-MATRIX.md.## Related- 11.1.8.docs/RELEASE-MANUAL-SMOKE.md) - N/A: MCP stdio surface only, no release-cut user-facing path; mcp-server.md smoke snippet updated instead.Closes #NNNin the## Relatedsection - Closes MCP server returns -32601 forresources/templates/list#2826.Impact
openhuman-core mcp. No mobile/web/CLI behaviour change.json!literal returning an empty array; negligible.resources/templates/listsee no change.Related
resources/templates/list#2826resourcescapability +resources/list/resources/readon main).resources/templates/listas deliberate out-of-scope follow-up tracking).AI Authored PR Metadata (required for Codex/Linear PRs)
Linear Issue
Commit & Branch
feat/mcp-resources-templates-list95f25985b4b3639fa7d284674b7161f4fd555468Validation Run
pnpm --filter openhuman-app format:check- N/A: noapp/files changed.pnpm typecheck- N/A: no TypeScript files changed.cargo test --lib openhuman::mcp_server-> 109 passed / 0 failed (3 new);cargo test --lib list_resource_templates_returns_empty+cargo test --lib templates_listgreen.cargo check --manifest-path Cargo.tomlclean.app/src-tauri/files changed.Validation Blocked
command:N/Aerror:N/Aimpact:N/ABehavior Changes
resources/templates/listreturns{resourceTemplates: []}instead of-32601 Method not found.Parity Contract
-32601for every other unknown method; only the named arm is added.success_response(id, ...)+log::debug!shape as the siblingresources/listandresources/readarms.Duplicate / Superseded PR Handling
Summary by CodeRabbit
New Features
resources/templates/listMCP method, which returns the server's resource template catalog (currently empty).Documentation
Tests