Skip to content

Follow up after canonical memory rollout: safe MCP People/entity cleanup tools #8369

Closed

Description

@Git-on-my-level

Context

This is the replacement/follow-up issue for:

The old request is still valid: MCP clients can read People/contact records via get_people, but they cannot clean up false positives, duplicates, or incorrect display names through MCP-only workflows.

However, the draft PR grew into a broader mix of People cleanup tools, MCP API-key scope semantics, REST/SSE scope enforcement, and compatibility handling. That makes it the wrong PR shape to merge before the canonical memory domain rollout lands upstream.

Follow-up timing

Do this after the canonical memory rollout from fork PR Git-on-my-level#33 has been decomposed/merged upstream, or after the relevant MCP memory/auth foundation from that branch is available on upstream main.

The follow-up should be based on upstream main after that landing, not on the older #8346 branch.

Goal

Expose a safe, scoped MCP surface for People/entity cleanup so trusted clients can:

  1. List People/contact/entity records.
  2. Correct display names.
  3. Dismiss/archive false-positive records.
  4. Eventually merge duplicates or perform hard deletion only when the backend/product semantics support it safely.

Lessons learned from #8346

1. Keep the PR narrow

Do not combine all of these in one upstream PR:

  • new People mutation tools
  • API-key scope schema changes
  • REST route scope enforcement
  • SSE tool scope enforcement
  • legacy key compatibility migration
  • hard-delete data cleanup semantics

That made #8346 hard to review and generated many rounds of legitimate feedback. The next PR should assume the canonical/auth foundation already exists, or split foundation changes first.

2. Do not duplicate MCP scope/auth infrastructure from the canonical rollout

Fork PR #33 already introduces MCP API-key app_id / scopes auth context and converges MCP memory writes onto MemoryService for canonical users.

After that lands, the People cleanup follow-up should reuse the landed auth context and route/tool enforcement patterns instead of reintroducing a separate scope model.

3. Prefer soft cleanup before hard delete

delete_person is too sharp as the first MCP People write primitive. MCP tools are model-controlled, and clients may vary in how well they present human confirmation for destructive calls.

Prefer a safer progression:

  1. rename_person(person_id, name) — non-destructive correction.
  2. dismiss_person(person_id) / archive_person(person_id) / mark_person_false_positive(person_id) — soft cleanup, excluded from default People reads.
  3. merge_people(source_person_id, target_person_id) — later, once product semantics are clear.
  4. delete_person(person_id) — only if hard-delete semantics, cleanup/retry, and authorization are explicitly defined.

4. Treat destructive capability as opt-in

Do not silently grant destructive People write access to every newly-created MCP key just because it defaults to all scopes.

Recommended policy:

  • legacy keys keep their pre-existing behavior;
  • new default keys should not automatically gain destructive People cleanup;
  • people.write or a narrower people.cleanup / people.delete scope should be explicitly requested/granted;
  • if separate scopes are available, use people.rename and people.cleanup / people.delete rather than one broad write scope.

5. Scope enforcement must be consistent across transports

If a People cleanup capability is exposed in both MCP SSE/Streamable HTTP tools and REST /v1/mcp/* endpoints, enforce the same scope semantics on both. Avoid drift between advertised securitySchemes and actual runtime checks.

6. tools/list should not encourage unusable destructive calls

For keys that lack the write/cleanup scope, consider filtering unavailable write tools from tools/list or marking them clearly as unavailable. Returning all tools and failing with an insufficient-scope error at call time is compatible, but worse for agent ergonomics.

7. Hard-delete cleanup must be durable if/when implemented

If hard delete remains necessary, avoid fire-and-forget storage cleanup that returns success even if blob cleanup later fails. Prefer one of:

  • transactional/awaited cleanup when feasible;
  • a durable cleanup job with retry and observable status;
  • soft-delete first, then asynchronous hard cleanup with retry/audit.

Proposed follow-up scope after fork PR #33 lands

Start with the smallest safe upstream PR:

  • Reuse landed canonical MCP auth context / scope infrastructure.
  • Add a scoped non-destructive rename_person tool.
  • Add a soft cleanup tool if the backend has or can cheaply add a soft state (dismiss_person, archive_person, or equivalent).
  • Do not add hard delete unless product/backend deletion semantics and durable cleanup are in place.
  • Add regression tests for:
    • descriptor metadata and annotations;
    • scope enforcement for allowed and disallowed keys;
    • legacy key behavior;
    • REST/SSE parity if both surfaces expose the feature;
    • no transcript/sample leakage from write-only responses;
    • soft-dismiss exclusion from default get_people reads.

Acceptance criteria

  • Implementation is based on upstream main after the canonical memory/auth foundation lands.
  • People cleanup tools reuse the landed MCP auth/scope context instead of creating parallel scope infrastructure.
  • Non-destructive rename is supported via MCP.
  • False-positive cleanup is soft by default, or hard delete is explicitly justified with durable cleanup semantics.
  • Destructive cleanup is not granted to legacy keys or default new keys without explicit opt-in.
  • Scope enforcement is consistent across MCP transports/routes.
  • tools/list behavior is deliberate for keys without cleanup scope.
  • Tests cover compatibility and security cases from feat(mcp): add people cleanup tools #8346 review feedback.

References

Activity

  1. added
    p3
    backend
    retrieval-action
    parked
    and removed
    p3
    on Jul 2, 2026
  2. Git-on-my-level commented on Jul 23, 2026

    @Git-on-my-level
    MemberAuthor

    Blocked on: #10394 (prod MEMORY_MODE still off). Do not start until the master rollout tracker unblocks.

  3. aryanorastar commented on Aug 6, 2026

    @aryanorastar
    Collaborator

    VERIFY (2026-08-06): still parked / blocked — not starting a PR.

    Will revisit only after #10394 / canonical MCP foundation is unblocked.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    backendp3parkedretrieval-action

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions