Repository navigation
fix(gti): accept explicit null for parameters that default to None - #323
Open
vishalhabib99 wants to merge 1 commit into
Open
vishalhabib99 wants to merge 1 commit into
vishalhabib99 wants to merge 1 commit into
Conversation
Seven tool parameters default to None but were annotated with a
non-Optional type (e.g. `collection_type: str = None` in search_threats).
FastMCP derives the input schema from the annotation, so it advertised
`{"type": "string", "default": null}`. A client that sends the advertised
default explicitly (some agent frameworks fill every optional field with
null) gets a pydantic validation error instead of the default behavior.
Annotate them as Optional so the schema becomes
`anyOf: [{type: X}, {type: null}]`:
- search_threats: collection_type
- update_collection_attributes: attributes
- get_collection_rules: rule_types
- search_digital_threat_monitoring: since, until, page, truncate
Add a regression test that checks every tool's advertised schema allows
null wherever the default is null, plus an end-to-end call of
search_threats with collection_type=null.
Author
|
Hi @dandye, just checking this one is still on your radar. It's still mergeable and includes a regression test for the seven parameters. Happy to change anything. |
This branch has not been deployed
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.
Summary
Seven GTI tool parameters default to
Nonebut are annotated with a non-Optional type (e.g.collection_type: str = Noneinsearch_threats). FastMCP builds the input schema from the annotation, so it advertises{"type": "string", "default": null}. A client that sends the advertised default explicitly (some agent frameworks fill every optional field withnull) is rejected at argument validation:…even though
Noneis the intended default. Reproduced on mcp 1.23.0 and 1.30.0 with an in-memory client; the rejection happens before the tool body runs.Change
Annotate these as
typing.Optional[...]so the schema becomesanyOf: [{type: X}, {type: null}]. No behavior change for callers that omit the argument.search_threats:collection_typeupdate_collection_attributes:attributesget_collection_rules:rule_typessearch_digital_threat_monitoring:since,until,page,truncateTests
test_none_default_params_accept_null: fails if any tool advertises"default": nullon a type that excludes null.test_search_threats_accepts_null_collection_type: end-to-end call withcollection_type=Nonethrough the existing mock VT fixture.Both fail on
mainand pass with this change;server/gtisuite: 55 → 57 passed.The same pattern exists in
server/scc(6 tools) andserver/secops(4 tools); I kept this PR to GTI and can send those separately if you'd like.Found with mcp-doctor (https://github.com/vishalhabib99/mcp-doctor); happy to run a no-install scan on your other servers if useful.
🤖 Generated with Claude Code