Skip to content

Commit 8fcbb99

Browse files
Fix boolean parameter handling in ListRoutes MCP tool (#279)
* Fix boolean parameter handling in ListRoutes MCP tool The ListRoutes tool was throwing a type error when boolean parameters (except_vendor, only_vendor) were passed because str_replace() was being called on boolean values. This fix adds type checking to handle boolean parameters separately from string parameters. The error was: "str_replace(): Argument #3 ($subject) must be of type array|string, true given" Boolean parameters are now properly passed to the artisan command without string manipulation, while string parameters continue to have wildcard characters sanitized. * Fix boolean parameter handling in ListRoutes MCP tool The ListRoutes tool was throwing a type error when boolean parameters (except_vendor, only_vendor) were passed because str_replace() was being called on boolean values. This fix adds type checking to handle boolean parameters separately from string parameters. The error was: "str_replace(): Argument #3 ($subject) must be of type array|string, true given" Boolean parameters are now properly passed to the artisan command without string manipulation, while string parameters continue to have wildcard characters sanitized. --------- Co-authored-by: systempath <[email protected]> Co-authored-by: Pushpak Chhajed <[email protected]>
1 parent 3eb3dcc commit 8fcbb99

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/Mcp/Tools/ListRoutes.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,13 @@ public function handle(Request $request): Response
6464
foreach ($optionMap as $argKey => $cliOption) {
6565
$value = $request->get($argKey);
6666
if (! empty($value)) {
67-
$sanitizedValue = str_replace(['*', '?'], '', $value);
68-
if (filled($sanitizedValue)) {
69-
$options['--'.$cliOption] = $sanitizedValue;
67+
if (is_bool($value)) {
68+
$options['--'.$cliOption] = true;
69+
} else {
70+
$sanitizedValue = str_replace(['*', '?'], '', $value);
71+
if (filled($sanitizedValue)) {
72+
$options['--'.$cliOption] = $sanitizedValue;
73+
}
7074
}
7175
}
7276
}

0 commit comments

Comments
 (0)