{"record":{"id":"2c484717f8917b14","repo":"PrefectHQ/fastmcp","slug":"got-unexpected-keyword-argument-s-join-sor","errorCode":null,"errorMessage":"Got unexpected keyword argument(s): {', '.join(sorted(unknown_args))}","messagePattern":"Got unexpected keyword argument\\(s\\): (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"fastmcp_slim/fastmcp/tools/tool_transform.py","lineNumber":736,"sourceCode":"            \"properties\": new_props,\n            # Iterate props (not the set) for deterministic ordering\n            \"required\": [p for p in new_props if p in new_required],\n            \"additionalProperties\": False,\n        }\n\n        if parent_defs:\n            schema[\"$defs\"] = parent_defs\n            schema = compress_schema(schema)\n\n        # Create forwarding function that closes over everything it needs\n        async def _forward(**kwargs: Any):\n            # Validate arguments\n            valid_args = set(new_props.keys())\n            provided_args = set(kwargs.keys())\n            unknown_args = provided_args - valid_args\n\n            if unknown_args:\n                raise TypeError(\n                    f\"Got unexpected keyword argument(s): {', '.join(sorted(unknown_args))}\"\n                )\n\n            # Check required arguments\n            missing_args = new_required - provided_args\n            if missing_args:\n                raise TypeError(\n                    f\"Missing required argument(s): {', '.join(sorted(missing_args))}\"\n                )\n\n            # Map arguments to parent names\n            parent_args = {}\n            for new_name, value in kwargs.items():\n                old_name = new_to_old.get(new_name, new_name)\n                parent_args[old_name] = value\n\n            # Add hidden defaults (constant values for hidden parameters)\n            for old_name, transform in hidden_defaults.items():","sourceCodeStart":718,"sourceCodeEnd":754,"githubUrl":"https://github.com/PrefectHQ/fastmcp/blob/1f021142978e0861cd910c8df4e8074bc7cf3978/fastmcp_slim/fastmcp/tools/tool_transform.py#L718-L754","documentation":"The forwarded tool's _forward validates keyword arguments against the transformed tool's new schema. Any argument not present in the new (post-ArgTransform) schema is rejected with a TypeError, since the transformation renamed or removed the original parameter names.","triggerScenarios":"Calling the transformed tool with a keyword argument that was renamed or dropped by an ArgTransform, or using the parent tool's original parameter name after it was remapped to a new name.","commonSituations":"Caching old parameter names after refactoring the transform; LLM clients calling with stale tool schemas; renaming a parameter in an ArgTransform while callers still pass the old name.","solutions":["Update the call site to use the new (transformed) parameter names","Inspect the transformed tool's schema to confirm valid argument names","Adjust the ArgTransform to keep the old name if backward compatibility is required"],"exampleFix":"// before\nawait transformed_tool(query=\"x\")  # renamed to q\n\n// after\nawait transformed_tool(q=\"x\")","handlingStrategy":"try-catch","validationCode":"valid = set(transformed_tool.parameters[\"properties\"].keys())\nunknown = set(kwargs) - valid\nif unknown:\n    raise TypeError(f\"Unknown args: {unknown}\")","typeGuard":null,"tryCatchPattern":"try:\n    result = await transformed_tool(**kwargs)\nexcept TypeError as e:\n    if \"unexpected keyword\" in str(e):\n        kwargs = {k: v for k, v in kwargs.items() if k in valid_args}\n        result = await transformed_tool(**kwargs)\n    else:\n        raise","preventionTips":["Re-fetch tool schemas after changing ArgTransforms","Keep a single source of truth for parameter names","Add tests that call transformed tools with current schemas"],"tags":["python","tool-transform","arguments","typeerror"],"backgroundTag":"unexpected-keyword-argument","analyzedSha":"1f021142978e0861cd910c8df4e8074bc7cf3978","analyzedAt":"2026-08-29T14:31:16.082Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}