Skip to content

Commit 190b016

Browse files
committed
fix: improve wildcard sanitization logic in ListRoutes
1 parent 2c39415 commit 190b016

File tree

2 files changed

+1
-29
lines changed

2 files changed

+1
-29
lines changed

src/Mcp/Tools/ListRoutes.php

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public function handle(array $arguments): ToolResult
5959

6060
foreach ($optionMap as $argKey => $cliOption) {
6161
if (! empty($arguments[$argKey])) {
62-
$sanitizedValue = $this->sanitizeWildcards($arguments[$argKey], $argKey);
62+
$sanitizedValue = str_replace(['*', '?'], '', $arguments[$argKey]);
6363
if (filled($sanitizedValue)) {
6464
$options['--'.$cliOption] = $sanitizedValue;
6565
}
@@ -81,15 +81,6 @@ public function handle(array $arguments): ToolResult
8181
return ToolResult::text($routesOutput);
8282
}
8383

84-
private function sanitizeWildcards(string $value, string $parameter): string
85-
{
86-
if (in_array($parameter, ['path', 'except_path'])) {
87-
return $value;
88-
}
89-
90-
return str_replace(['*', '?'], '', $value);
91-
}
92-
9384
/**
9485
* @param array<string|bool> $options
9586
*/

tests/Feature/Mcp/Tools/ListRoutesTest.php

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -98,25 +98,6 @@
9898
->and($output)->not->toContain('admin.dashboard');
9999
});
100100

101-
test('it preserves wildcards in path parameters', function () {
102-
$tool = new ListRoutes;
103-
104-
$result = $tool->handle(['path' => '/admin/*']);
105-
expect($result)->toBeInstanceOf(ToolResult::class)
106-
->and($result->toArray()['isError'])->toBeFalse();
107-
108-
$output = $result->toArray()['content'][0]['text'];
109-
expect($output)->not->toContain('Failed to list routes');
110-
111-
$result = $tool->handle(['except_path' => '/nonexistent/*']);
112-
expect($result)->toBeInstanceOf(ToolResult::class)
113-
->and($result->toArray()['isError'])->toBeFalse();
114-
115-
$output = $result->toArray()['content'][0]['text'];
116-
expect($output)->toContain('admin.dashboard')
117-
->and($output)->toContain('user.profile');
118-
});
119-
120101
test('it handles edge cases and empty results correctly', function () {
121102
$tool = new ListRoutes;
122103

0 commit comments

Comments
 (0)