fix(gti): accept explicit null for parameters that default to None by vishalhabib99 · Pull Request #323 · google/mcp-security · GitHub
Skip to content

fix(gti): accept explicit null for parameters that default to None - #323

Open
vishalhabib99 wants to merge 1 commit into
google:mainfrom
vishalhabib99:fix/gti-null-defaults
Open

vishalhabib99 wants to merge 1 commit into
google:mainfrom
vishalhabib99:fix/gti-null-defaults

Conversation

@vishalhabib99

Copy link
Copy Markdown

Summary

Seven GTI tool parameters default to None but are annotated with a non-Optional type (e.g. collection_type: str = None in search_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 with null) is rejected at argument validation:

Error executing tool search_threats: 1 validation error for search_threatsArguments
collection_type
  Input should be a valid string [type=string_type, input_value=None, input_type=NoneType]

…even though None is 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 becomes anyOf: [{type: X}, {type: null}]. No behavior change for callers that omit the argument.

  • search_threats: collection_type
  • update_collection_attributes: attributes
  • get_collection_rules: rule_types
  • search_digital_threat_monitoring: since, until, page, truncate

Tests

  • test_none_default_params_accept_null: fails if any tool advertises "default": null on a type that excludes null.
  • test_search_threats_accepts_null_collection_type: end-to-end call with collection_type=None through the existing mock VT fixture.

Both fail on main and pass with this change; server/gti suite: 55 → 57 passed.

The same pattern exists in server/scc (6 tools) and server/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

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.
@vishalhabib99
vishalhabib99 requested a review from a team October 9, 2026 23:47
@vishalhabib99

Copy link
Copy Markdown
Author

This branch has not been deployed

No deployments
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.

1 participant