Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions click_mcp/scanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,14 +274,17 @@ def _get_parameter_info(param: click.Parameter) -> Optional[Dict[str, Any]]:
if help_text:
param_data["description"] = help_text

# Handle choices if present
if hasattr(param, "choices") and param.choices is not None:
if isinstance(param.choices, (list, tuple)):
param_data["enum"] = list(param.choices)
# Handle choices if present (for click.Choice type)
if hasattr(param.type, "choices") and param.type.choices is not None:
if isinstance(param.type.choices, (list, tuple)):
param_data["enum"] = list(param.type.choices)

# Add default if available and not callable
# Filter out Click's Sentinel.UNSET and other non-JSON-serializable defaults
default = getattr(param, "default", None)
if default is not None and not callable(default):
param_data["default"] = default
# Only include JSON-serializable defaults (str, int, float, bool, list, dict, None)
if isinstance(default, (str, int, float, bool, list, dict, type(None))):
param_data["default"] = default

return param_data
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ test = [
"pytest>=6.0",
"pytest-cov",
"pytest-anyio",
"pytest-timeout",
"trio",
"jsonschema>=4.0",
]

[project.urls]
Expand Down
2 changes: 2 additions & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ testpaths = tests
python_files = test_*.py
python_classes = Test*
python_functions = test_*
timeout = 10
timeout_method = thread
Loading