fix: ignore extra inputs on MCP tool args schema#4871
Open
gambletan wants to merge 1 commit intocrewAIInc:mainfrom
Open
fix: ignore extra inputs on MCP tool args schema#4871gambletan wants to merge 1 commit intocrewAIInc:mainfrom
gambletan wants to merge 1 commit intocrewAIInc:mainfrom
Conversation
…ontext rejection The dynamically created Pydantic args model for MCP tools used extra='forbid' (the default from create_model_from_schema), which caused validation to fail with 'Extra inputs are not permitted' when CrewAI injected security_context into tool call arguments. Set extra='ignore' on the args model so that internally-added fields like security_context are silently discarded instead of raising. Fixes crewAIInc#4796
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #4796
MCP tools fail with
Extra inputs are not permittedbecause CrewAI's tool execution framework injects asecurity_contextparameter into tool call arguments, but the dynamically created Pydantic args model usesextra='forbid'(the default fromcreate_model_from_schema), causing validation to reject the unknown field.Changes
lib/crewai-tools/src/crewai_tools/adapters/mcp_adapter.py: Pass__config__=ConfigDict(extra='ignore')tocreate_model_from_schema()so that internally-added fields likesecurity_contextare silently discarded instead of raising a validation error.ConfigDictto the pydantic import.Root cause
create_model_from_schema()defaults toConfigDict(extra="forbid"). When CrewAI injectssecurity_context(containingagent_fingerprintandmetadata) during parameter validation — before_runis called — the strict schema rejects it.Test plan
create_model_from_schemaaccepts__config__as an override parametersecurity_contextinjection no longer raiseextra_forbiddenvalidation errors🤖 Generated with Claude Code
Note
Medium Risk
Loosens Pydantic validation for MCP-adapted tool inputs by ignoring unknown fields, which could mask unexpected/typoed parameters but is scoped to the MCP adapter path.
Overview
Prevents MCP tool calls from failing validation when CrewAI injects internal arguments by creating the MCP tool
args_schemawithConfigDict(extra="ignore").This updates
mcp_adapter.pyto pass a custom Pydantic config intocreate_model_from_schema(and importsConfigDict), so extra fields likesecurity_contextare silently dropped instead of raisingextra_forbiddenerrors.Written by Cursor Bugbot for commit 7c7ab51. This will update automatically on new commits. Configure here.