Improve ambiguity handling in argument processing - #43
Open
3dgiordano wants to merge 4 commits into
Open
Conversation
Collaborator
|
Looks like
|
diego-ferrand
requested changes
Aug 17, 2026
| return action, args | ||
|
|
||
|
|
||
| def validate_required_args(action: str, args: Optional[Dict[str, Any]], required: list[str]) -> Optional[BaseResult]: |
Collaborator
There was a problem hiding this comment.
This method is new but never used. Is it dead code?
| icon_data = base64.standard_b64encode(icon_path.read_bytes()).decode() | ||
| return f"data:image/png;base64,{icon_data}" | ||
|
|
||
| def normalize_action_args(arguments: Optional[Dict[str, Any]] = None) -> tuple[str, Dict[str, Any]]: |
Collaborator
There was a problem hiding this comment.
Can we include some tests for this logic?
| ctx: Context = Field(description="Context object providing access to MCP capabilities") | ||
| ) -> BaseResult: | ||
| action, args = normalize_action_args(arguments) | ||
| if args is None: |
Collaborator
There was a problem hiding this comment.
normalize_action_args never returns None and will default to {}, this is now dead code and should be removed on all managers.
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.
This pull request introduces a standardized approach for handling tool arguments across multiple managers and patches the MCP argument model to improve payload handling. The main change is the addition of a
normalize_action_argsutility, which ensures consistent parsing of action and argument data, and updates all tool managers to use a singleargumentsparameter. This makes the codebase more robust against variations in client payloads and simplifies argument handling logic.Core infrastructure improvements:
normalize_action_argsand validation utilities totools/utils.pyto standardize and simplify argument parsing for all tool endpoints. This function supports multiple payload formats and ensures all managers receive arguments in a consistent(action, args)tuple.mcp.server.fastmcp.utilities.func_metadata.ArgModelBaseinmain.pyto ensure tools with anargumentsparameter always receive the full payload, even if the client omits theargumentswrapper. This increases compatibility with different client payload styles.Tool manager refactoring:
registerendpoints (ai_scriptless_manager.py,device_manager.py,execution_manager.py,help_manager.py,user_manager.py) to accept a singleargumentsparameter instead of separateactionandargs, and to usenormalize_action_argsfor argument extraction. [1] [2] [3] [4] [5]normalize_action_args. [1] [2] [3] [4] [5]API and documentation consistency:
ai_scriptless_manager.pyto rename parameters fromargumentstocmd_argumentsfor clarity, and updated all related docstrings and dispatch logic to match the new naming and argument handling convention. [1] [2] [3] [4] [5]These changes collectively make the argument handling more robust and maintainable, reducing the risk of errors from inconsistent payloads and simplifying the interface for future tool development.