Skip to content

fix: MCP action resolver ignores operation_name, always runs first action#719

Merged
binaryk merged 1 commit into10.xfrom
fix/mcp-action-resolver-operation-name
Mar 1, 2026
Merged

fix: MCP action resolver ignores operation_name, always runs first action#719
binaryk merged 1 commit into10.xfrom
fix/mcp-action-resolver-operation-name

Conversation

@binaryk
Copy link
Copy Markdown
Collaborator

@binaryk binaryk commented Mar 1, 2026

Bug

When calling execute-operation with operation_type=action and operation_name=replicate, the wrapper always executes the first action in the list (e.g., share-invoice) instead of the requested one.

Same issue affects the second code path used by action/getter resolution.

Root Cause

McpToolsManager::executeOperation() line 381 compares the raw string $operationType ('action') against enum cases (OperationTypeEnum::action) using in_array(). In PHP, a string never equals an enum case, so the comparison always returns false. The ->when() filter never runs, and ->first() returns index 0.

// Before (bug): $operationType is a string, enum cases are not strings
->when($operationName && in_array($operationType, [OperationTypeEnum::action, ...]))

// After (fix): $operationTypeEnum is the converted enum
->when($operationName && in_array($operationTypeEnum, [OperationTypeEnum::action, ...]))

Note: getOperationDetails() had the same pattern at line 329 but was already using $operationTypeEnum correctly. The two instances fixed here are the second code path at line 378 and executeOperation at line 381.

Fix

One-character fix in two places: $operationType -> $operationTypeEnum

…ype comparison

The `executeOperation` and second code path in `McpToolsManager` compared
the string `$operationType` against enum cases in `in_array()`, which always
returned false in PHP. This caused the `->when()` filter to never execute,
so `->first()` always returned the first action in the collection regardless
of `operation_name`.

Fix: use `$operationTypeEnum` (the already-converted enum) instead of
`$operationType` (the raw string) in the `in_array()` check.
@what-the-diff
Copy link
Copy Markdown

what-the-diff bot commented Mar 1, 2026

PR Summary

  • Updated variable references in critical functions
    • The getOperationDetails and executeOperation methods have seen a consistency and correctness boost. We've moved from referencing a variable named operationType to another called operationTypeEnum. This makes sure that our checks for operations are in line with the actual data we use to determine them.

@binaryk binaryk merged commit c324c06 into 10.x Mar 1, 2026
21 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.

1 participant