You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
edit_note via MCP rejects payloads that include optional fields set to null or undefined. For example, an append operation that includes find_text: null and section: null fails with an invalid payload error.
Worked in previous BM versions — likely a regression from stricter MCP input validation
Workaround
Plugin-side fix applied in openclaw-basic-memory@8caaf86: strip undefined optional fields before sending. But BM should also handle this gracefully — null/undefined optional fields should be ignored, not rejected.
Expected Behavior
Optional fields (find_text, section, expected_replacements) that are null or absent should be silently ignored for operations that don't use them (append, prepend).
Priority: High (breaks plugin integrations like openclaw-basic-memory)
Complexity: Simple
Root Cause:
expected_replacements was typed as int = 1 (non-optional). FastMCP generates JSON Schema from Python type annotations, so this became {"type": "integer"} in the tool schema — which rejects null. When a client sends expected_replacements: null, MCP schema validation rejects the entire payload before the function body runs.
find_text and section were already Optional[str], so they correctly allow null in the schema.
Fix (src/basic_memory/mcp/tools/edit_note.py):
Changed expected_replacements: int = 1 → expected_replacements: Optional[int] = None so FastMCP generates {"anyOf": [{"type": "integer"}, {"type": "null"}]} allowing null.
Added effective_replacements = expected_replacements if expected_replacements is not None else 1 inside the function to preserve the default-1 behaviour.
Updated all internal references to use effective_replacements.
Regression test added in tests/mcp/test_tool_edit_note.py — test_edit_note_append_with_null_optional_fields — covering the exact payload shape from the issue.
Tasks
Analyze issue
Find root cause
Fix expected_replacements type annotation to allow null
Update internal logic to treat null as the default value (1)
Activity
claude commentedon Feb 25, 2026
Claude finished @bm-clawd's task in 4m 3s —— View job •
claude/issue-606-20260225-1524• Create PR ➔Analysis:
edit_noterejects null optional fields — FixedTriage:
edit_note)Root Cause:
expected_replacementswas typed asint = 1(non-optional). FastMCP generates JSON Schema from Python type annotations, so this became{"type": "integer"}in the tool schema — which rejectsnull. When a client sendsexpected_replacements: null, MCP schema validation rejects the entire payload before the function body runs.find_textandsectionwere alreadyOptional[str], so they correctly allownullin the schema.Fix (
src/basic_memory/mcp/tools/edit_note.py):expected_replacements: int = 1→expected_replacements: Optional[int] = Noneso FastMCP generates{"anyOf": [{"type": "integer"}, {"type": "null"}]}allowing null.effective_replacements = expected_replacements if expected_replacements is not None else 1inside the function to preserve the default-1 behaviour.effective_replacements.Regression test added in
tests/mcp/test_tool_edit_note.py—test_edit_note_append_with_null_optional_fields— covering the exact payload shape from the issue.Tasks
expected_replacementstype annotation to allow null|
fix: allow null optional fields in edit_note MCP tool
fix: accept null for expected_replacements in edit_note (#606)
docs: update v0.19.0 release notes with post-draft changes