fix: handle None inputSchema in extract_mcp_commands - #69
Open
Christian-Sidak wants to merge 1 commit into
Open
Conversation
When a non-conformant MCP server returns null for inputSchema,
tool.get("inputSchema", {}) returns None (the key exists with a None
value), causing AttributeError on the subsequent .get() calls.
Change to `tool.get("inputSchema") or {}` so that both a missing key
and an explicit None value are treated as an empty schema.
Fixes knowsuchagency#41
Signed-off-by: Christian-Sidak <61099993+Christian-Sidak@users.noreply.github.com>
Contributor
Author
|
Friendly bump -- let me know if anything needs changing. |
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
inputSchema: null(or missing key) inextract_mcp_commandsProblem
When a non-conformant MCP server returns
nullforinputSchema, the calltool.get("inputSchema", {})returnsNone(the key exists, its value isNone). The subsequentschema.get("required", [])then raises:This crashes
mcp2cli --list(and any other code path that callsextract_mcp_commands) for any server that omits or nullifiesinputSchema.Fix
Change line 848 in
src/mcp2cli/__init__.pyfrom:to:
or {}treats both a missing key and an explicitNonevalue as an emptyschema, so tools without parameters are listed without error.
Test plan
test_none_input_schema-- tool withinputSchema=Noneproduces aCommandDefwith no paramstest_missing_input_schema-- tool with noinputSchemakey produces aCommandDefwith no paramstest_basicandtest_underscore_to_kebabcontinue to passFixes #41