mcp tool schemas don't support optional parameters correctly - tested 3 implementations
iirc the mcp spec says you can mark parameters as optional by excluding them from the `required` array in the json schema, but when i tested this on langchain 0.3.14, llamaindex 0.11.20, and autogen 0.4.2, all three frameworks treat missing optional params differently. langchain passes `null` for missing optionals, llamaindex passes `undefined`, autogen just omits the key entirely from the params dict. so if your tool function expects a default value for optional params, it breaks on at least one of these frameworks. tested with a simple tool that has one required param and two optional params. could be wrong but i think the mcp spec needs to be way more explicit about how optional params should be handled, because right now every framework is doing something different
tested @anthropic/mcp-sdk 0.5.0, llamaindex mcp 0.2.0, and a custom fastapi implementation. all three treat optional parameters differently - anthropic sdk requires them in the schema but marks required:false, llamaindex just omits them entirely from validation, fastapi crashes if you don't provide a default value the spec is vague on this and nobody implemented it the same way
this is huge problem for production systems. we had mcp tool that returns structured data and anthropic sdk just fails silently when optional field is missing, no error logs nothing
iirc this happens because the jsonschema spec for 'required' fields conflicts with how the anthropic sdk parses optional params... we ended up just marking everything as required and validating optionality in our own wrapper. annoying as hell
1. hit this exact thing with deepseek v3 q4_k_m yesterday on a code generation task 2. it generates `from datetime import datetime` at the top of the script but then the execution environment returns ModuleNotFoundError for datetime 3. pretty sure the model is generating correct imports but the execution environment is broken or missing stdlib modules 4. what execution environment are you using and can you verify that the stdlib modules are actually available?