Skip to content

Add MCP tools for memory navigation and integration discovery #1908

@justinhsu1477

Description

@justinhsu1477

Summary

Add three read-only MCP tools on top of the Phase 1 surface (memory.search, memory.recall, tree.read_chunk):

  • tree.browse — paginated chunk listing with source / topic / time filters.
  • tree.search_entities — find chunks by named entity (person, org, project).
  • integrations.list_connections — list connected sources so a client can scope subsequent queries.

All three are thin adapters over existing controller-registry RPCs, follow the Phase 1 ToolCallError / enforce_read_policy model, and stay strictly read-only.

Problem

The Phase 1 surface (#1760 + #1790) is enough for "find a chunk by keyword / semantic query and read it." It leaves three gaps that show up the moment an MCP client tries to be useful beyond direct keyword recall:

  1. No way to browse. A client can only call memory.search / memory.recall and hope the query is right. There is no listing, no filtering by source, no time-window scan. A user asking "what's recent in my Gmail?" forces the LLM to guess search terms instead of paging through.
  2. No entity awareness. A client cannot ask "what does my memory say about Alice / Acme Corp?" without pretending it's a keyword. memory_tree_search_entities already exists in the registry — Phase 1 just doesn't expose it.
  3. No source discovery. Before running any query the client has no way to know which integrations (Gmail, Slack, Notion, …) actually have data. Models end up calling memory.search against keywords that have no chance of matching anything.

These are the three single-call shapes a Claude Desktop / Cursor session most often needs after the initial "I know roughly what I'm looking for" interaction.

Solution (optional)

Sketch, happy to revise per maintainer input:

MCP tool Backing RPC Why this one
tree.browse openhuman.memory_tree_list_chunks Paginated listing already supports the source_kind / source_id / entity_ids / time-window / keyword filters we want.
tree.search_entities openhuman.memory_tree_search_entities Lets the LLM say "Alice" instead of guessing every keyword permutation.
integrations.list_connections composio.list_connections Cheap discovery call. Lets the LLM pre-filter searches to sources that actually have data, instead of fishing on dead ones.

Same module + adapter pattern as Phase 1:

  • Tools live next to the existing three in src/openhuman/mcp_server/tools.rs.
  • Each runs through validate_controller_params and enforce_read_policy(ToolOperation::Read).
  • New ToolCallError variants not required — the new tools surface as InvalidParams for bad input and Internal for config-load failures, matching fix(mcp): tighten stdio server logging and error semantics #1790.
  • Tool descriptions are tuned so the LLM picks the right tool: "browse when you want pagination or a source filter; recall/search when you have a query string."

Acceptance criteria

  • tree.browse — accepts source_kind?, source_id?, entity_ids?, since?, until?, keyword?, page?, k? (defaults & caps mirror Phase 1's k); rejects unexpected args.
  • tree.search_entities — accepts entity (required, non-empty string) and k? (≤ 50); rejects unexpected args.
  • integrations.list_connections — no args; returns connected toolkits with their last-sync time. Skips sensitive fields (tokens).
  • Schema validation — every new tool round-trips through validate_controller_params against its mapped RPC schema; mapping regression caught at unit test time (same pattern as mapped_rpc_methods_are_registered).
  • enforce_read_policy — every new tool gated through SecurityPolicy with ToolOperation::Read.
  • Diff coverage ≥ 80% — happy path + at least one invalid-arg path per tool, per Testing Strategy.

Related

  • Feature IDs: 11.1.4 (MCP stdio server)
  • Builds on: #1760, #1790
  • Refs: #1586

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions