In `src/fastmcp/resources/template.py` line 412, boolean query parameter parsing treats any value not in `("true", "1", "yes")` as `False`:
```python
elif annotation is bool:
kwargs[param_name] = param_value.lower() in ("true", "1", "yes")
```
So `?flag=banana` silently becomes `False` instead of raising a validation error.
Interestingly, the CLI version at `src/fastmcp/cli/client.py:281-284` does this correctly — it checks both true and false sets and raises `ValueError` for unrecognized values:
```python
if raw.lower() in ("true", "1", "yes"):
return True
if raw.lower() in ("false", "0", "no"):
return False
raise ValueError(...)
```
Fix: Apply the same pattern from `client.py` to `template.py`:
```python
elif annotation is bool:
lower = param_value.lower()
if lower in ("true", "1", "yes"):
kwargs[param_name] = True
elif lower in ("false", "0", "no"):
kwargs[param_name] = False
else:
raise ValueError(f"Invalid boolean value for {param_name}: {param_value!r}")
```
In `src/fastmcp/resources/template.py` line 412, boolean query parameter parsing treats any value not in `("true", "1", "yes")` as `False`:
```python
elif annotation is bool:
kwargs[param_name] = param_value.lower() in ("true", "1", "yes")
```
So `?flag=banana` silently becomes `False` instead of raising a validation error.
Interestingly, the CLI version at `src/fastmcp/cli/client.py:281-284` does this correctly — it checks both true and false sets and raises `ValueError` for unrecognized values:
```python
if raw.lower() in ("true", "1", "yes"):
return True
if raw.lower() in ("false", "0", "no"):
return False
raise ValueError(...)
```
Fix: Apply the same pattern from `client.py` to `template.py`:
```python
elif annotation is bool:
lower = param_value.lower()
if lower in ("true", "1", "yes"):
kwargs[param_name] = True
elif lower in ("false", "0", "no"):
kwargs[param_name] = False
else:
raise ValueError(f"Invalid boolean value for {param_name}: {param_value!r}")
```