Skip to content

fix(mcp): expose edit_note operation enum - #1037

Merged
phernandez merged 1 commit into
mainfrom
codex/edit-note-operation-enum
Jul 5, 2026
Merged

fix(mcp): expose edit_note operation enum#1037
phernandez merged 1 commit into
mainfrom
codex/edit-note-operation-enum

Conversation

@phernandez

Copy link
Copy Markdown
Member

Why

  • OpenAI's app submission review flagged edit_note.operation as a free-form string even though Basic Memory only supports a fixed set of edit operations.
  • Exposing the supported operations in the MCP tool schema lowers incorrect-call risk without changing runtime behavior.

What Changed

  • Added a single EDIT_OPERATIONS source of truth in src/basic_memory/mcp/tools/edit_note.py.
  • Annotated the edit_note.operation parameter with JSON schema enum metadata while keeping the existing string runtime validation.
  • Added a tool-contract regression that asserts the protocol-level edit_note.operation schema advertises the supported enum values.

Implementation Details

  • Kept the Python parameter type as str instead of a Literal so direct Python callers, CLI paths, and invalid-operation tests do not need casts.
  • The enum is emitted through Field(json_schema_extra={"enum": ...}), which FastMCP includes in tools/list while preserving the existing docstring-derived description.
  • Runtime validation still rejects unsupported operations before the edit request is sent.

Testing

Automated

  • uv run pytest tests/mcp/test_tool_contracts.py -q: passed, 4 passed.
  • just fast-check: passed; cold testmon selected a broad run, 3397 passed, 43 skipped, 20 warnings.
  • uv run ruff check src/basic_memory/mcp/tools/edit_note.py tests/mcp/test_tool_contracts.py: passed.
  • uv run ruff format --check src/basic_memory/mcp/tools/edit_note.py tests/mcp/test_tool_contracts.py: passed.
  • uv run ty check src tests test-int: passed.

Manual

  • Inspected mcp.list_tools() for edit_note and confirmed inputSchema.properties.operation.enum contains append, prepend, find_replace, replace_section, insert_before_section, and insert_after_section.

Risks / Follow-ups

  • Low risk: this changes schema metadata and reuses the existing validation path.
  • Follow-up: once merged, Basic Memory Cloud should bump its basic-memory dependency so the hosted MCP endpoint advertises the new schema.

Signed-off-by: phernandez <paul@basicmachines.co>
@phernandez
phernandez merged commit 39fe75f into main Jul 5, 2026
23 checks passed
@phernandez
phernandez deleted the codex/edit-note-operation-enum branch July 5, 2026 00:34
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.

1 participant