Skip to content

Improve ambiguity handling in argument processing - #43

Merged
diego-ferrand merged 7 commits into
developmentfrom
ARG-AMBIGUITY
Sep 2, 2026
Merged

Improve ambiguity handling in argument processing#43
diego-ferrand merged 7 commits into
developmentfrom
ARG-AMBIGUITY

Conversation

@3dgiordano

Copy link
Copy Markdown
Collaborator

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_args utility, which ensures consistent parsing of action and argument data, and updates all tool managers to use a single arguments parameter. This makes the codebase more robust against variations in client payloads and simplifies argument handling logic.

Core infrastructure improvements:

  • Added normalize_action_args and validation utilities to tools/utils.py to 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.
  • Patched mcp.server.fastmcp.utilities.func_metadata.ArgModelBase in main.py to ensure tools with an arguments parameter always receive the full payload, even if the client omits the arguments wrapper. This increases compatibility with different client payload styles.

Tool manager refactoring:

  • Updated all tool manager register endpoints (ai_scriptless_manager.py, device_manager.py, execution_manager.py, help_manager.py, user_manager.py) to accept a single arguments parameter instead of separate action and args, and to use normalize_action_args for argument extraction. [1] [2] [3] [4] [5]
  • Updated imports in all affected managers to include normalize_action_args. [1] [2] [3] [4] [5]

API and documentation consistency:

  • Refactored ai_scriptless_manager.py to rename parameters from arguments to cmd_arguments for 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.

@diego-ferrand

Copy link
Copy Markdown
Collaborator

Looks like tools/tool_manager.py -> tools function is missing migration to new arguments

async def tools( action: str = Field(description="The action id to execute"), args: Dict[str, Any] = Field(description="Dictionary with parameters", default=None), ctx: Context = Field(description="Context object providing access to MCP capabilities") ) -> BaseResult:

Comment thread tools/utils.py Outdated
Comment thread tools/ai_scriptless_manager.py
Comment thread tools/ai_scriptless_manager.py Outdated
Comment thread tools/utils.py
Comment thread tools/ai_scriptless_manager.py Outdated
3dgiordano and others added 2 commits September 2, 2026 15:27
* Support dual store and data type

* Improve status, condition and error policy

* Support condition statement and error policy

* Variable, command contract and validations

* Update hint notes

* Contract and others improvements

* Contract/spec and improvements

---------

Co-authored-by: diego-ferrand <[email protected]>
@diego-ferrand
diego-ferrand merged commit dfb5e1d into development Sep 2, 2026
5 checks passed
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.

2 participants