mirror of
https://github.com/basicmachines-co/basic-memory
synced 2026-06-21 13:47:35 +00:00
fix(mcp): restore overwrite param schema for external MCP clients (#818)
AliasChoices on `overwrite: bool | None` in write_note caused FastMCP to generate a broken JSON schema where external clients (e.g. Claude Code) saw the parameter as type null-only. The boolean value was silently dropped, so `overwrite=True` arrived as None at the function body. Revert overwrite to a plain `bool | None = None` parameter. FastMCP now generates the correct `anyOf: [boolean, null]` schema, and external clients can send `overwrite=true` as intended. The `directory` alias (folder/dir/path) is unaffected — AliasChoices on a required `str` parameter does not exhibit this schema generation issue. Add regression test: test_write_note_overwrite_canonical_via_mcp verifies that overwrite=True reaches the function body through the MCP protocol. Co-authored-by: Paul Hernandez <phernandez@users.noreply.github.com> Signed-off-by: claude[bot] <41898282+claude[bot]@users.noreply.github.com>
This commit is contained in:
@@ -35,11 +35,10 @@ async def write_note(
|
||||
tags: list[str] | str | None = None,
|
||||
note_type: str = "note",
|
||||
metadata: Annotated[dict | None, BeforeValidator(coerce_dict)] = None,
|
||||
# Force/replace are the file-write idioms models default to.
|
||||
overwrite: Annotated[
|
||||
bool | None,
|
||||
Field(default=None, validation_alias=AliasChoices("overwrite", "force", "replace")),
|
||||
] = None,
|
||||
# Simple bool so FastMCP generates a correct boolean schema for external clients.
|
||||
# AliasChoices caused external clients (e.g. Claude Code) to receive a broken schema
|
||||
# where overwrite appeared as type null-only, silently dropping the value (issue #818).
|
||||
overwrite: bool | None = None,
|
||||
output_format: Literal["text", "json"] = "text",
|
||||
context: Context | None = None,
|
||||
) -> str | dict:
|
||||
|
||||
Reference in New Issue
Block a user