Skip to content

Conversation

@grll
Copy link
Owner

@grll grll commented May 24, 2025

Summary

Problem

When using CrewAI with MCP servers like the GitHub MCP server, passing None values for optional parameters causes errors:

parameter head is not of type string, is <nil>

Solution

The fix inspects the tool's input schema before calling the MCP tool:

  • If a parameter's schema allows null values, the None is preserved
  • If the schema only allows non-null types (e.g., just "string"), the None value is filtered out
  • This ensures compatibility with strict MCP servers while maintaining flexibility for servers that accept null

Test plan

  • Added test case that reproduces the issue with a strict MCP server
  • Test verifies None values are filtered when schema doesn't allow null
  • All existing tests pass
  • Linting and type checking pass

grll added 2 commits May 24, 2025 16:58
…'t allow null

- Add schema-aware filtering in CrewAI adapter's _run method
- Only filter None values when the parameter's schema doesn't explicitly allow null
- Preserves None values when schema allows them (type: ["string", "null"] or anyOf with null)
- Add test to verify None values are filtered appropriately
- Fixes error "parameter X is not of type string, is <nil>" with GitHub MCP server
@grll grll merged commit f66b653 into main May 24, 2025
3 checks passed
amithkk pushed a commit to amithkk/mcpadapt that referenced this pull request Sep 6, 2025
… allow null (grll#49)

* Fix issue grll#46: Filter None values in CrewAI adapter when schema doesn't allow null

- Add schema-aware filtering in CrewAI adapter's _run method
- Only filter None values when the parameter's schema doesn't explicitly allow null
- Preserves None values when schema allows them (type: ["string", "null"] or anyOf with null)
- Add test to verify None values are filtered appropriately
- Fixes error "parameter X is not of type string, is <nil>" with GitHub MCP server

* fix formatting
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: Filter out None values in _run method of crewai_adapter.py

1 participant