1 Commits

Author SHA1 Message Date
siaochuan 6510a820a7 fix(mcp): use JSON Schema types in tool input models; exclude None from MCP calls
When non-Anthropic models (MiniMax, Moonshot, etc.) call MCP tools, they
sometimes send `null` for parameters they consider optional. The previous
implementation typed all fields as `object | None`, so:

1. Pydantic accepted `null` even for required fields (e.g. `query`)
2. `model_dump()` serialized these as `{"query": null, ...}`
3. The MCP server received null for required parameters → validation error

Fix:
- Map JSON Schema types to proper Python types (string→str, integer→int,
  etc.) so Pydantic rejects null for required fields
- Use `exclude_none=True` in model_dump to strip optional null parameters
  before passing to the MCP server

This affects ALL MCP tool servers, not just specific ones.

Tested with: MiniMax-M2.7-highspeed + dongtian MCP server (15 tools).
2026-04-08 11:13:09 +08:00