Skip to content

fix(mcp): remove delete_memory tool to close authorization-bypass gap - #1228

Merged
nicoloboschi merged 1 commit into
mainfrom
fix/mcp-remove-delete-memory
Apr 23, 2026
Merged

fix(mcp): remove delete_memory tool to close authorization-bypass gap#1228
nicoloboschi merged 1 commit into
mainfrom
fix/mcp-remove-delete-memory

Conversation

@nicoloboschi

Copy link
Copy Markdown
Collaborator

Summary

Fixes #1218. MemoryEngine.delete_memory_unit never called validate_bank_write, so any authenticated MCP client could delete memories in any bank regardless of the configured OperationValidatorExtension policy. Every sibling delete method (delete_document, delete_bank, delete_mental_model, delete_directive) follows the validator pattern — delete_memory_unit was the lone exception.

The MCP delete_memory tool was the only external caller:

  • No REST endpoint exposes single-memory deletion (http.py has no DELETE /v1/default/banks/{bank_id}/memories/{memory_id} route).
  • The CLI already stubs delete_memory with anyhow::bail!("Individual memory deletion is no longer supported") (hindsight-cli/src/api.rs:383).

The product direction was already "no single-memory delete via public API." This PR finishes the removal for MCP rather than papering the validator gap.

Changes

  • Remove both delete_memory MCP tool registrations and _register_delete_memory in hindsight-api-slim/hindsight_api/mcp_tools.py; drop "delete_memory" from _ALL_TOOLS, _AUDITABLE_MCP_TOOLS, and the default tool set.
  • Drop "delete_memory" from _SINGLE_BANK_TOOLS in hindsight-api-slim/hindsight_api/api/mcp.py.
  • Remove delete_memory_unit from the MemoryEngineInterface abstract class (it's no longer part of the documented public surface). The concrete method stays on MemoryEngine so tests/test_observation_invalidation.py can still cover the stale-observation sweep through a single-unit entry point.
  • Delete the MCP-tool tests for delete_memory in tests/test_mcp_tools.py and adjust the default-tool-count assertion (30 → 29).
  • Remove delete_memory from the Memories group in the Control Plane bank-config UI.
  • Update hindsight-docs/docs/developer/mcp-server.md, configuration.md, api/memory-banks.mdx, docs-integrations/local-mcp.md, and the skills/hindsight-docs mirrors. Versioned docs for 0.4/0.5 left untouched.

Test plan

  • ./scripts/hooks/lint.sh — all lints pass
  • uv run pytest tests/test_mcp_tools.py — 168 passed
  • python -c "from hindsight_api.api import mcp; from hindsight_api import mcp_tools" — imports fine; _ALL_TOOLS is now 29 entries
  • CI

MemoryEngine.delete_memory_unit never called validate_bank_write, so any
authenticated MCP client could delete memories in any bank regardless of
the configured OperationValidatorExtension policy (issue #1218).

No REST endpoint exposes single-memory deletion, and the CLI already
errors out on it. Drop the matching MCP tool and remove delete_memory_unit
from the public MemoryEngineInterface. The engine method stays so internal
observation-invalidation tests still cover the stale-observation sweep.

Also updates the control plane bank-config UI, MCP docs, and skill mirrors
to drop references to the tool.
@nicoloboschi
nicoloboschi merged commit 90674ae into main Apr 23, 2026
52 of 54 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Security: delete_memory_unit bypasses OperationValidatorExtension — no validate_bank_write call

1 participant