What happened?
When calling MCP tools that have union type parameters (e.g., list[str] | None), Qwen Code rejects valid input with a contradictory error message:
params/urls must be array, params/urls must be null, params/urls must match a schema in anyOf
Steps to reproduce:
- Connect to an MCP server that uses union types in tool parameters (e.g., wet-mcp server)
- Call a tool with a parameter defined as urls: list[str] | None = None
- Pass a valid array value: extract(action="extract", urls=["https://example.com"])
- Validation fails
Example tool definition from wet-mcp:
async def extract(
action: str,
urls: list[str] | None = None, # ← union type
...
) -> str:
Actual error:
params/urls must be array, params/urls must be null, params/urls must match a schema in anyOf
This error is logically contradictory — the value ["https://example.com"] IS an array and SHOULD match the anyOf schema.
What did you expect to happen?
The value ["https://example.com"] should successfully validate against the JSON Schema anyOf construct:
{
"urls": {
"anyOf": [
{"type": "array", "items": {"type": "string"}},
{"type": "null"}
],
"default": null
}
}
According to JSON Schema specification, anyOf means the value must match at least one of the schemas. An array value should match the first schema and pass validation.
The tool call should execute successfully, as it does in other MCP clients (Gemini CLI, Cline, Claude Desktop).
Client information
Client Information
Login information
igneo-user
Anything else we need to know?
Impact:
This bug breaks compatibility with MCP servers that use Python union types (list[str] | None, int | None, etc.), which is a common pattern for optional parameters.
Comparison with other MCP clients:
Client: Status:
Gemini CLI ✅ Works
Cline (VS Code) ✅ Works
Claude desktop ✅ Works
Qwen Code ❌ Fails
Related issues (same root cause in other projects):
Suggested fix:
Update the JSON Schema validator to correctly handle anyOf constructs according to the JSON Schema specification:
- When validating against anyOf, pass if the value matches at least one schema in the array
- Consider using a standard validation library (jsonschema for Python, ajv for JavaScript) that correctly implements the specification
Workaround:
Currently, the only workaround is to use alternative MCP clients or avoid MCP servers that use union types in tool parameters.
What happened?
When calling MCP tools that have union type parameters (e.g., list[str] | None), Qwen Code rejects valid input with a contradictory error message:
params/urls must be array, params/urls must be null, params/urls must match a schema in anyOf
Steps to reproduce:
Example tool definition from wet-mcp:
async def extract(
action: str,
urls: list[str] | None = None, # ← union type
...
) -> str:
Actual error:
params/urls must be array, params/urls must be null, params/urls must match a schema in anyOf
This error is logically contradictory — the value ["https://example.com"] IS an array and SHOULD match the anyOf schema.
What did you expect to happen?
The value ["https://example.com"] should successfully validate against the JSON Schema anyOf construct:
{
"urls": {
"anyOf": [
{"type": "array", "items": {"type": "string"}},
{"type": "null"}
],
"default": null
}
}
According to JSON Schema specification, anyOf means the value must match at least one of the schemas. An array value should match the first schema and pass validation.
The tool call should execute successfully, as it does in other MCP clients (Gemini CLI, Cline, Claude Desktop).
Client information
Client Information
Login information
igneo-user
Anything else we need to know?
Impact:
This bug breaks compatibility with MCP servers that use Python union types (list[str] | None, int | None, etc.), which is a common pattern for optional parameters.
Comparison with other MCP clients:
Client: Status:
Gemini CLI ✅ Works
Cline (VS Code) ✅ Works
Claude desktop ✅ Works
Qwen Code ❌ Fails
Related issues (same root cause in other projects):
anyOfschemas fail Gemini validation - missing top-leveltypefield google/adk-python#3424 — "MCP tools with anyOf schemas fail Gemini validation"int | Noneunion type: "not valid under any of the given schemas" PrefectHQ/fastmcp#2040 — "None union type: not valid under any of the given schemas"Suggested fix:
Update the JSON Schema validator to correctly handle anyOf constructs according to the JSON Schema specification:
Workaround:
Currently, the only workaround is to use alternative MCP clients or avoid MCP servers that use union types in tool parameters.