Skip to content

Let the linex MCP tools accept null for kernel_filter - #202

Merged
mawad-amd merged 1 commit into
AMDResearch:mainfrom
vishalhabib99:fix/optional-args-accept-null
Oct 14, 2026
Merged

mawad-amd merged 1 commit into
AMDResearch:mainfrom
vishalhabib99:fix/optional-args-accept-null

Conversation

@vishalhabib99

Copy link
Copy Markdown
Contributor

profile_application and analyze_instruction_hotspots declare kernel_filter: str = None. FastMCP turns that into {"type": "string", "default": null}, so the schema advertises a default the server then refuses. A client that sends the default back explicitly, for example profile_application(command="./app", kernel_filter=null), gets:

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

Some MCP clients and LLM tool callers fill in every parameter from the schema, so they hit this.

Fix

Annotations only: kernel_filter: str = None -> kernel_filter: str | None = None in both tools (1 parameter in each of 2 tools). The schema becomes anyOf: [string, null] with default: null, and both tool bodies already pass None through to Linex.profile(). ruff format wrapped the analyze_instruction_hotspots signature onto one parameter per line because the new annotation pushed it past 100 characters. Nothing else changed.

Test

Added TestToolRegistration::test_null_default_params_accept_null in linex/tests/test_mcp_server.py. It lists the registered tools and checks that every parameter whose schema says "default": null also accepts null. To share the lookup, I split the existing _registered_tools() helper into _registered_tool_objects() plus the name set; _registered_tools() returns the same names as before.

  • Before the fix: fails with profile_application.kernel_filter defaults to null but rejects it
  • After the fix: passes
  • I checked it on fastmcp 4.1.0 and on 2.14.7 (the package pins fastmcp>=2.0.0)

Suite, pytest linex/tests on macOS (no ROCm):

passed failed
main 27 8
this branch 28 8

The 8 failures are the same on both: every test in test_inline_hip_sqtt.py needs hipcc and an AMD GPU, so they didn't run here. test_mcp_server.py is 28/28. ruff check and ruff format --check pass at the CI version (0.15.22).

Not included

profile_application and analyze_instruction_hotspots annotate kernel_filter as `str = None`, so FastMCP advertises "default": null on a string-only field and rejects a client that sends the default back explicitly. Annotate it `str | None`; the tool bodies already handle None. A test checks that every parameter defaulting to null also accepts null.

@mawad-amd mawad-amd left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great. Thank you!

@mawad-amd
mawad-amd merged commit b61ea5e into AMDResearch:main Oct 14, 2026
15 checks passed
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