Repository navigation
fix(mcp): let optional tool arguments accept an explicit null - #47
Merged
Merged
Conversation
The *_create tools' _id and judgements_search's filter, sort and _source default to None but were typed str / Dict, so FastMCP advertised "default": null on fields whose type excludes null. A client that sends that default back got a validation error before the tool ran. Typed as Optional[...].
|
💚 CLA has been signed |
Contributor
Author
|
I've signed the Elastic Contributor Agreement; commenting so the CLA check re-runs. |
Contributor
Author
|
Hi, just checking whether this one is on your radar. It's a small fix (let optional tool arguments accept an explicit null) and the branch is still mergeable. Happy to change anything. |
davemoore-
approved these changes
Nov 4, 2026
Contributor
Author
|
Thanks for merging this, @davemoore-! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In
src/server/fastmcp.py, the*_createtools (conversations,workspaces,displays,strategies,benchmarks) declare_id: str = None, andjudgements_searchdeclaresfilter: str = None,sort: str = Noneand_source: Dict[str, Any] = None. FastMCP advertises"default": nullon fields whose type excludes null, so a client that sends that default back (some agent frameworks fill in every optional argument) gets a validation error before the tool runs:This types them as
Optional[...].Optionalis already imported, and the API functions already treatNoneas "not provided".Checked:
fastmcp==3.2.0, the same signatures asworkspaces_create:_id: str = Nonewith an explicit null fails as above, andOptional[str]accepts it. Calling the real server in-memory isn't possible without an HTTP request, because of the MCP auth check.pytest tests/unit: 2352 passed, on main and on this branch.