Skip to content

fix: handle None inputSchema in extract_mcp_commands - #69

Open
Christian-Sidak wants to merge 1 commit into
knowsuchagency:mainfrom
Christian-Sidak:fix/issue-41
Open

fix: handle None inputSchema in extract_mcp_commands#69
Christian-Sidak wants to merge 1 commit into
knowsuchagency:mainfrom
Christian-Sidak:fix/issue-41

Conversation

@Christian-Sidak

Copy link
Copy Markdown
Contributor

Summary

  • Guard against inputSchema: null (or missing key) in extract_mcp_commands

Problem

When a non-conformant MCP server returns null for inputSchema, the call
tool.get("inputSchema", {}) returns None (the key exists, its value is
None). The subsequent schema.get("required", []) then raises:

AttributeError: 'NoneType' object has no attribute 'get'

This crashes mcp2cli --list (and any other code path that calls
extract_mcp_commands) for any server that omits or nullifies inputSchema.

Fix

Change line 848 in src/mcp2cli/__init__.py from:

schema = tool.get("inputSchema", {})

to:

schema = tool.get("inputSchema") or {}

or {} treats both a missing key and an explicit None value as an empty
schema, so tools without parameters are listed without error.

Test plan

  • test_none_input_schema -- tool with inputSchema=None produces a CommandDef with no params
  • test_missing_input_schema -- tool with no inputSchema key produces a CommandDef with no params
  • Existing test_basic and test_underscore_to_kebab continue to pass

Fixes #41

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>
@Christian-Sidak

Copy link
Copy Markdown
Contributor Author

Friendly bump -- let me know if anything needs changing.

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