openhuman icon indicating copy to clipboard operation
openhuman copied to clipboard

Expose bundled prompts as static MCP resources (resources/list + resources/read)

Open obchain opened this issue 6 months ago • 1 comments

Summary

Expose OpenHuman's bundled prompt assets — the three core identity files (IDENTITY.md, SOUL.md, USER.md) plus each built-in subagent's static prompt.md — as MCP resources so external MCP clients (Claude Desktop, Cursor, Zed, …) can attach them as conversation context.

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, or USER.md as context to a Claude conversation.
  • Discover or attach any subagent prompt (orchestrator, planner, researcher, etc.) without reading the OpenHuman source tree.

This is the smallest user-visible spec gap on the server-side MCP surface and lands without backend coordination.

Solution (optional)

Add a static MCP resources catalog backed by include_str!-bundled prompt files, plus the two spec handlers:

  • resources/list — returns the full catalog in one page; advertises 21 URIs (3 core + 18 subagents). cursor accepted for spec-compliance but ignored.
  • resources/read — looks up by uri and returns the markdown body under contents[0].text. Missing-uri → -32602 Invalid params. Unknown URI → -32002 Resource not found per MCP error-code convention.

initialize advertises "resources": { "subscribe": false, "listChanged": false } because the catalog cannot change without rebuilding the binary, so the server intentionally does not implement subscriptions or notifications/resources/list_changed.

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)

Scope (core only, no app/UI change):

  • src/openhuman/mcp_server/resources.rs — new module holding the catalog + the two builders.
  • src/openhuman/mcp_server/mod.rs — register the module.
  • src/openhuman/mcp_server/protocol.rs — wire the two match arms + advertise the capability + extend the existing initialize test.
  • gitbooks/developing/mcp-server.md — Resources section + extended smoke-test snippet.
  • docs/TEST-COVERAGE-MATRIX.md — new row 11.1.7.

Out of scope (deliberately, to keep the PR end-to-end shippable):

  • Dynamic memory-as-resources (openhuman://memory/recent, openhuman://memory/search?q=…) — needs per-user context plumbing and SecurityPolicy gating; tracked as a follow-up.
  • 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.

Acceptance criteria

  • [ ] resources/list returns the full static catalog — one entry per core identity file plus one per BUILTINS row, each with uri, name, title, description, and mimeType populated.
  • [ ] resources/read returns the markdown body for a known URI under contents[0].text with mimeType: "text/markdown".
  • [ ] Unknown-URI lookups surface as -32002 Resource not found with a data field that names the offending URI.
  • [ ] Missing-uri field surfaces as -32602 Invalid params so clients can distinguish a typo from a malformed request.
  • [ ] initialize advertises the resources capability with subscribe: false and listChanged: false.
  • [ ] Catalog parity is locked in — a unit test mirrors the BUILTINS list so adding a new subagent without a matching catalog entry fails CI.
  • [ ] Smoke test docs cover the new flow — gitbooks/developing/mcp-server.md lists the URIs and the smoke-test snippet exercises resources/list + resources/read.
  • [ ] Diff coverage ≥ 80% — the implementing PR meets the changed-lines coverage gate (Vitest + cargo-llvm-cov, enforced by .github/workflows/coverage.yml).

Related

obchain avatar May 27 '26 07:05 obchain

Picking this one up. PR up next.

obchain avatar May 27 '26 07:05 obchain