Skip to content

fix: accept explicit null for parameters that default to None (scc, secops, secops-soar) - #351

Open
atrearyan wants to merge 4 commits into
google:mainfrom
atrearyan:fix/explicit-null-defaults
Open

atrearyan wants to merge 4 commits into
google:mainfrom
atrearyan:fix/explicit-null-defaults

Conversation

@atrearyan

Copy link
Copy Markdown
Contributor

Summary

Tool parameters that default to None but are typed with a non-nullable annotation (for example severity: str = None) advertise {"type": "string", "default": null}. A client that sends that advertised default explicitly is rejected at argument validation, before the tool runs. This applies the fix from #323 (gti) to the remaining packages: these parameters are now typed X | None, so an explicit null is accepted and behaves the same as omitting the argument.

Closes #349

Changes

The work is split into one commit per package:

  • scc: 30 parameters across 6 tools in scc_mcp.py. The _build_parent helper gets the same 2-parameter change so its types match the tools that call it.
  • secops: 10 parameters across 4 tools:
    • search_udm, export_udm_search_csv and find_udm_field_values: project_id, customer_id, region
    • update_feed: feed_details
  • secops-soar: 3,310 parameters across 946 tools in 214 marketplace modules. Annotated[T, Field(default=None, ...)] becomes Annotated[T | None, Field(default=None, ...)]. The edit is mechanical: the only change on every modified line is the added | None.

Tool docstrings are unchanged.

Tests

  • test_none_default_params_accept_null, ported from server/gti (fix(gti): accept explicit null for parameters that default to None #323), is added to each package. It fails if any tool advertises "default": null on a type that excludes null. Each package also gets one end-to-end call that passes null and checks it behaves like omitting the argument:
    • scc: search_findings(severity=None)
    • secops: search_udm(project_id=None, ...)
    • secops-soar: csv_save_json_to_csv(overwrite=None)
  • All 6 new tests fail on main with the validation error from Tool parameters typed str = None reject explicit null in scc, secops, and secops-soar marketplace #349 and pass with this change.
  • Results by package, run with mcp 1.30.0:
    • scc: 2 passed.
    • secops: 54 passed. Another 54 error because they are live integration tests that need tests/config.json with credentials; none of them exercise the changed code.
    • secops-soar tests/unit: 13 passed.

Schema check

I dumped every tool's list_tools() output before and after the change: 6 scc tools, 70 secops tools and 2,123 marketplace tools. Exactly 30, 10 and 3,310 input properties changed, each from type: X to anyOf: [X, {type: null}], with default, title and description unchanged. No other property, output schema or tool description changed.

Notes

  • The marketplace modules are generated outside this repo, so the generator needs the same change, or a regeneration will reintroduce the bug.
  • Left unchanged: the search_findings and search_findings_by_compliance docstrings in scc say to set state to None to search all states, but state: str = "ACTIVE" rejects an explicit null. I can follow up separately if that should accept null too.
  • chore(scc): bump version to 0.2.0, fix SetMuteRequest, and add unit test suite #300 also edits server/scc/scc_mcp.py, but none of the lines changed here.

Closes #349

FastMCP decodes a string argument that holds a JSON object or array
whenever the parameter is not annotated exactly `str`. After the
`str | None` change, '{"field": "value"}' sent to a parameter such as
arcsight additional_fields arrived as a dict and failed string
validation.

Marketplace `str | None` parameters now use OptionalStr, which encodes
a decoded object or array back to JSON text. The advertised schema is
unchanged.
@atrearyan

Copy link
Copy Markdown
Contributor Author

Hi @dandye , Follow-up comment: with the str | None change, FastMCP decoded JSON text arguments (e.g. '{"field": "value"}' for arcsight additional_fields) into a dict before validation, so they failed with "Input should be
a valid string". Marketplace optional string parameters now use OptionalStr, which re-encodes a decoded object or array as JSON text. The advertised schemas are unchanged. Known limit: the literal string
"null" is still decoded to None by FastMCP before validation.

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.

Tool parameters typed str = None reject explicit null in scc, secops, and secops-soar marketplace

1 participant