feat(mcp): expose bundled prompts as static MCP resources
Summary
- Adds
resources/listandresources/readto the MCP stdio + HTTP server so external MCP clients (Claude Desktop, Cursor, Zed) can attach OpenHuman's bundled prompt assets as conversation context. - Catalog ships 21 static, read-only resources: 3 core identity files (
IDENTITY.md,SOUL.md,USER.md) plus 18 subagentprompt.mdfiles (one perBUILTINSrow inagent::agents::loader). initializenow advertises aresourcescapability withsubscribe: falseandlistChanged: falsebecause the catalog isinclude_str!-bundled at compile time and cannot change at runtime.- 11 new unit tests cover catalog parity vs
BUILTINS, per-URI content distinctness, the wired JSON-RPC happy paths, and the-32002 Resource not found/-32602 Invalid paramserror conventions. - Single-page-per-
resources/listresponse: thecursorparameter is accepted for spec-compliance but ignored, and the response omitsnextCursor.
Problem
The MCP server today only implements initialize, ping, tools/list, and tools/call; every other spec method returns -32601 Method not found. External MCP clients connecting to openhuman-core therefore see a tools-only surface and have no way to pull OpenHuman's own prompt scaffolds into their own conversations — even though those scaffolds are already bundled into the binary at compile time and contain no per-user data.
Concretely, a Claude Desktop user who connects OpenHuman as an MCP server cannot today attach IDENTITY.md / SOUL.md / USER.md or any subagent prompt without reading the OpenHuman source tree by hand. That's the smallest user-visible spec gap on the server-side MCP surface and lands without backend coordination.
Solution
Three atomic commits:
| SHA | Title | Files |
|---|---|---|
75df6176 |
feat(mcp): add static resources catalog module |
new src/openhuman/mcp_server/resources.rs + mod.rs register. Catalog is an include_str!-bundled &[StaticResource] slice, so the asset paths are checked at compile time. Exposes pub fn list_resources_result(cursor) and pub fn read_resource_result(uri) — both pure, no I/O, no async. |
b38f425a |
feat(mcp): wire resources/list + resources/read into protocol |
src/openhuman/mcp_server/protocol.rs adds two handle_request match arms, advertises the resources capability in initialize_result, and updates the existing initialize test to assert the new capability block. Missing-uri → -32602 Invalid params. Unknown-URI lookups → -32002 Resource not found per the MCP error-code convention. |
d35c9d68 |
docs(mcp): document the resources surface and coverage row |
gitbooks/developing/mcp-server.md adds a Resources section listing the URI catalog and contract notes, plus extends the smoke-test snippet to exercise both methods against openhuman://core/identity. docs/TEST-COVERAGE-MATRIX.md adds row 11.1.7 and bumps the Covered total from 69 to 70. |
URI scheme
| URI | Source path |
|---|---|
openhuman://core/identity |
src/openhuman/agent/prompts/IDENTITY.md |
openhuman://core/soul |
src/openhuman/agent/prompts/SOUL.md |
openhuman://core/user |
src/openhuman/agent/prompts/USER.md |
openhuman://agents/<id>/prompt |
src/openhuman/agent/agents/<id>/prompt.md (one entry per BUILTINS row) |
Out of scope (deliberately, follow-up tracking only)
- Dynamic memory-as-resources (
openhuman://memory/recent,openhuman://memory/search?q=…) — needs per-user context plumbing andSecurityPolicygating; lands cleaner on top of this MVP. resources/subscribe/resources/unsubscribe/notifications/resources/list_changed— the static catalog cannot change at runtime, so subscriptions would be no-ops.resources/templates/list— no templated URIs in the MVP catalog.
Submission Checklist
- [x] Tests added or updated (happy path + at least one failure / edge case) per Testing Strategy — 7 catalog tests in
resources.rs(parity vsBUILTINS, per-URI distinctness, required-field shape, nonextCursor, unknown-URI rejection) + 4 protocol tests inprotocol.rs(list happy path, read happy path, unknown-URI-32002, missing-uri-32602). - [x] Diff coverage ≥ 80% — changed Rust lines are 100% covered by the 11 new unit tests; docs lines are not eligible.
- [x] Coverage matrix updated — added row
11.1.7 MCP resources (resources/list + resources/read)indocs/TEST-COVERAGE-MATRIX.mdand bumped the Covered total. - [x] All affected feature IDs from the matrix are listed in the PR description under
## Related— feature ID11.1.7(new row). - [x] No new external network dependencies introduced (mock backend used per Testing Strategy) — tests are pure in-memory; no HTTP, no socket, no fixtures beyond the
include_str!-bundled markdown. - [x] Manual smoke checklist updated if this touches release-cut surfaces —
N/A: stdio/HTTP MCP server is opt-in and not on the release-cut smoke path. - [x] Linked issue closed via
Closes #NNNin the## Relatedsection.
Impact
- Runtime/platform impact: none on existing tool-call flow; the new methods are additive and only fire when an MCP client invokes them.
- Performance: zero overhead at startup (catalog is a
const); request-time cost is aVec<Value>build of ≈21 entries forresources/listand a linear scan to find a single URI forresources/read. - Security: the catalog is
include_str!-bundled at compile time and contains only assets already in the repo; there is no async I/O, no filesystem traversal, and no user-context plumbing introduced.SecurityPolicyis unchanged. - Migration / compatibility: backwards-compatible — older clients that ignore the
resourcescapability and never call the new methods continue to see the same surface.
Related
- Closes: #2732
- Feature ID 11.1.7 in
docs/TEST-COVERAGE-MATRIX.md. - MCP spec — server-side resources surface: https://modelcontextprotocol.io/specification/2025-06-18/server/resources.
- Follow-up PR(s)/TODOs: dynamic memory-as-resources surface (
openhuman://memory/…);resources/templates/listonce a templated URI is introduced.
AI Authored PR Metadata (required for Codex/Linear PRs)
Keep this section for AI-authored PRs. For human-only PRs, mark each field
N/A.
Linear Issue
- Key: N/A
- URL: N/A
Commit & Branch
- Branch: N/A
- Commit SHA: N/A
Validation Run
- [x]
pnpm --filter openhuman-app format:check— N/A: noapp/code changed. - [x]
pnpm typecheck— N/A: no TS source changed. - [x] Focused tests: ran
cargo test --lib openhuman::mcp_server::resources::tests(7/7 pass) andcargo test --lib openhuman::mcp_server::protocol::tests::resources(4/4 pass) pluscargo test --lib openhuman::mcp_server::protocol::tests::initialize(9/9 pass) to confirm the amendedinitializeassertion. - [x] Rust fmt/check (if changed):
cargo fmt --manifest-path Cargo.toml --checkclean on the touched files;cargo check --manifest-path Cargo.toml --libproduces no new warnings. - [x] Tauri fmt/check (if changed): N/A — no Tauri code changed.
Validation Blocked
command:N/Aerror:N/Aimpact:N/A
Behavior Changes
- Intended behavior change: MCP server now exposes 21 static read-only resources via
resources/list+resources/read, and theinitializecapability response advertises the new surface. - User-visible effect: external MCP clients (Claude Desktop, Cursor, Zed) connected to
openhuman-corecan attach OpenHuman's bundled prompts as conversation context.
Parity Contract
- Legacy behavior preserved: yes — existing
tools/list/tools/callpaths are untouched and the new methods are purely additive. - Guard/fallback/dispatch parity checks: no production code outside
mcp_server/changed; tool dispatch, security policy, and session lifecycle are unaffected.
Duplicate / Superseded PR Handling
- Duplicate PR(s): none.
- Canonical PR: this PR.
- Resolution: N/A.
Summary by CodeRabbit
-
New Features
- Added MCP resources surface with
resources/listandresources/readto expose bundled prompt assets via stableopenhuman://URIs. - Initialization now advertises a
resourcescapability.
- Added MCP resources surface with
-
Documentation
- Added a Resources section describing supported URIs and error behavior.
- Updated smoke test expectations to include resources results (four compact JSON lines).
-
Tests
- Added unit and integration tests for listing, reading, not-found, and invalid-params paths.
- Updated test-coverage matrix totals.
No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: d6f9585c-67a0-4b55-897f-053b290b1783
📥 Commits
Reviewing files that changed from the base of the PR and between 4b533545aa34d75335ee296153e81e36574aaf3b and e44f8b442fa34871a04460036815df5c595dfc2c.
📒 Files selected for processing (4)
docs/TEST-COVERAGE-MATRIX.mdgitbooks/developing/mcp-server.mdsrc/openhuman/mcp_server/protocol.rssrc/openhuman/mcp_server/resources.rs
✅ Files skipped from review due to trivial changes (2)
- docs/TEST-COVERAGE-MATRIX.md
- gitbooks/developing/mcp-server.md
🚧 Files skipped from review as they are similar to previous changes (2)
- src/openhuman/mcp_server/resources.rs
- src/openhuman/mcp_server/protocol.rs
📝 Walkthrough
Walkthrough
This PR implements the MCP resources/list and resources/read methods, exposing OpenHuman's bundled prompt assets—three core identity files and each subagent's static prompt—as a compile-time static catalog accessible to external MCP clients. The implementation includes request dispatch, error mapping, capability advertisement, comprehensive tests, and updated documentation.
Changes
MCP Static Resources Surface
| Layer / File(s) | Summary |
|---|---|
Resource catalog and data model src/openhuman/mcp_server/resources.rs (module doc, catalog def) |
Module documentation and RESOURCES constant define a compile-time static resource catalog with StaticResource metadata and markdown bodies embedded via include_str! for each openhuman://core/* and openhuman://agents/<id>/prompt URI. |
List, read, and error operations src/openhuman/mcp_server/resources.rs (operations) |
list_resources_result enumerates all catalog entries in a single page; read_resource_result looks up a URI in the catalog and returns contents or ResourceError::NotFound with formatted error message. |
Protocol dispatch and capability advertisement src/openhuman/mcp_server/protocol.rs (dispatch, initialize) |
handle_request routes resources/list (optional cursor) and resources/read (required uri) to their operation handlers, maps unknown URIs to MCP -32002 and missing uri to -32602, advertises capabilities.resources in initialize with subscribe: false and listChanged: false, and updates server instructions to reference resource methods. |
Operation and error handling validation src/openhuman/mcp_server/protocol.rs (tests) |
Async tests validate resources/list returns the full catalog with specific URIs, resources/read returns expected markdown for known resources, error code -32002 with "unknown MCP resource" message for unknown URIs, and error code -32602 with "requires a uri" message for missing parameters. |
Documentation and coverage matrix gitbooks/developing/mcp-server.md, docs/TEST-COVERAGE-MATRIX.md |
Added Resources section describing the static catalog, supported URI scheme, response shapes, and error behavior; updated MCP smoke test to exercise resources/list and resources/read with 4 expected JSON response lines; added new coverage matrix entry and updated totals (Covered: 70, Total leaves: 206). |
Estimated code review effort
🎯 3 (Moderate) | ⏱️ ~25 minutes
Possibly related PRs
- tinyhumansai/openhuman#2745: Implements the same MCP resources feature by wiring
resources/listandresources/readin protocol dispatch and defining the static catalog with the same URI scheme and error handling.
Suggested reviewers
- senamakel
Poem
🐰 A rabbit hops through MCP halls, Where static resources now live on calls—
resources/listandreadgently sing, Bundled prompts on compile-time's wing! Identity and agents, prompt by prompt, All exposed at startup, not runtime crumped.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
| Check name | Status | Explanation |
|---|---|---|
| Description Check | ✅ Passed | Check skipped - CodeRabbit’s high-level summary is enabled. |
| Title check | ✅ Passed | The title clearly and concisely summarizes the main feature: exposing bundled prompts as static MCP resources. It directly relates to the primary objective of the PR. |
| Linked Issues check | ✅ Passed | All acceptance criteria from #2732 are addressed: resources/list and resources/read implemented with proper error codes (-32602 for missing uri, -32002 for unknown), initialize advertises resources capability, catalog parity tested, docs updated, and coverage requirements met. |
| Out of Scope Changes check | ✅ Passed | All changes align with the PR scope: static MCP resources module, protocol.rs wiring, documentation updates, and test-coverage matrix. No dynamic memory resources, subscriptions, or templated URIs are introduced. |
| Docstring Coverage | ✅ Passed | Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. |
✏️ 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 @coderabbitai help to get the list of available commands and usage tips.
Done in 4b533545. Replaced the subset loop with a BTreeSet equality assertion filtered to openhuman://agents/ URIs, so catalog drift now fails in both directions (missing and stale entries).
@graycyrus rebased catalog parity test on 4b533545 (set-equality + agents-only filter). The cancelled Windows secrets ACL job was an infra glitch, not a real failure — the new push will rerun it automatically.
Closing as superseded — issue #2732 was completed by #2745 (merged 2026-05-27 18:24Z), which landed the same resources/list + resources/read MVP this branch targets. Thanks for the contribution! If there are gaps vs. what #2745 shipped, happy to look at a follow-up PR scoped to the delta.