Skip to content

fix(mcp): let optional tool arguments accept an explicit null - #47

Merged
davemoore- merged 1 commit into
elastic:mainfrom
vishalhabib99:fix/mcp-optional-args-null
Nov 4, 2026
Merged

davemoore- merged 1 commit into
elastic:mainfrom
vishalhabib99:fix/mcp-optional-args-null

Conversation

@vishalhabib99

Copy link
Copy Markdown
Contributor

In src/server/fastmcp.py, the *_create tools (conversations, workspaces, displays, strategies, benchmarks) declare _id: str = None, and judgements_search declares filter: str = None, sort: str = None and _source: Dict[str, Any] = None. FastMCP advertises "default": null on 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:

1 validation error for call[workspaces_create]
_id
  Input should be a valid string [type=string_type, input_value=None, input_type=NoneType]

This types them as Optional[...]. Optional is already imported, and the API functions already treat None as "not provided".

Checked:

  • With the pinned fastmcp==3.2.0, the same signatures as workspaces_create: _id: str = None with an explicit null fails as above, and Optional[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.

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-checker-service

cla-checker-service Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

💚 CLA has been signed

@vishalhabib99

Copy link
Copy Markdown
Contributor Author

I've signed the Elastic Contributor Agreement; commenting so the CLA check re-runs.

@vishalhabib99

Copy link
Copy Markdown
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-
davemoore- merged commit 7851141 into elastic:main Nov 4, 2026
4 checks passed
@vishalhabib99

Copy link
Copy Markdown
Contributor Author

Thanks for merging this, @davemoore-!

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.

2 participants