Skip to content

Numeric enum without 'type' is uncallable (invalid choice) #83

Description

@dhruvkej9

Problem

A JSON Schema property with a numeric enum but no type key is legal and common. schema_type_to_python() returns str whenever type is missing, so argparse parses the flag value as a string and then rejects it against the numeric choices:

$ mcp2cli --mcp-stdio "python server.py" set-level --level 2
usage: mcp2cli set-level [-h] [--stdin] [--level {1,2,3}]
mcp2cli set-level: error: argument --level: invalid choice: '2' (choose from '1', '2', '3')

The tool is uncallable from the CLI — no flag value can ever match.

Reproduction

Minimal stdio MCP server exposing one tool:

{"name": "set_level", "inputSchema": {"type": "object", "properties": {"level": {"enum": [1, 2, 3]}}}}

Verified against v3.5.0 (commit 6b8ae5f).

Expected

--level 2 works and the tool receives the integer 2. The argparse type can be inferred from the enum values when type is absent.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions