Repository navigation
fix(gti): accept explicit null for parameters that default to None - #323
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.
|
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. |
|
Thanks for catching the schema/type mismatch and adding the Before we merge, could we adjust a couple of things in how these parameters are handled? 1. Make
|
…pty DTM query params attributes is the whole PATCH payload, so it should be required rather than optional. search_digital_threat_monitoring now skips "" as well as None so unused filters don't add empty query parameters.
|
Thanks @dandye, both done in dbcd2cc:
All 58 GTI tests pass locally. |
dandye
left a comment
There was a problem hiding this comment.
LGTM! Thank you for the follow-up changes and test coverage, @vishalhabib99, and thank you for your first contribution to google/mcp-security!
|
Thanks @dandye for the careful review, especially for catching that |
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