Skip to content

Commit 8316453

Browse files
committed
resolves method class from the server itself
1 parent 20d28bc commit 8316453

File tree

2 files changed

+7
-14
lines changed

2 files changed

+7
-14
lines changed

src/Server/Testing/PendingTestResponse.php

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,9 @@
66

77
use Illuminate\Container\Container;
88
use Illuminate\Contracts\Auth\Authenticatable;
9-
use InvalidArgumentException;
109
use Laravel\Mcp\Server;
1110
use Laravel\Mcp\Server\Contracts\Method;
1211
use Laravel\Mcp\Server\Exceptions\JsonRpcException;
13-
use Laravel\Mcp\Server\Methods\CallTool;
14-
use Laravel\Mcp\Server\Methods\GetPrompt;
15-
use Laravel\Mcp\Server\Methods\ReadResource;
1612
use Laravel\Mcp\Server\Primitive;
1713
use Laravel\Mcp\Server\Prompt;
1814
use Laravel\Mcp\Server\Resource;
@@ -86,12 +82,9 @@ protected function run(string $method, Primitive|string $primitive, array $argum
8682
$server = $container->make($this->serverClass, ['transport' => new FakeTransporter]);
8783

8884
/** @var Method $methodInstance = */
89-
$methodInstance = $container->make(match ($method) {
90-
'tools/call' => CallTool::class,
91-
'prompts/get' => GetPrompt::class,
92-
'resources/read' => ReadResource::class,
93-
default => throw new InvalidArgumentException("Unsupported [{$method}] method."),
94-
});
85+
$methodInstance = $container->make(
86+
(fn () => $this->methods[$method])->call($server)
87+
);
9588

9689
$requestId = uniqid();
9790

tests/Unit/Console/Commands/McpInspectorCommandTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@
162162
});
163163

164164
it('handles single server with unknown type', function (): void {
165-
$unknownServer = new stdClass();
165+
$unknownServer = new stdClass;
166166

167167
$this->registrar
168168
->shouldReceive('getLocalServer')
@@ -209,6 +209,7 @@
209209
app()->bind('url', function () {
210210
$url = Mockery::mock(\Illuminate\Routing\UrlGenerator::class);
211211
$url->shouldReceive('to')->andReturn('http://localhost/api/mcp');
212+
212213
return $url;
213214
});
214215

@@ -229,14 +230,13 @@
229230
});
230231

231232
it('retrieves php binary path correctly', function (): void {
232-
$command = new \Laravel\Mcp\Console\Commands\InspectorCommand();
233+
$command = new \Laravel\Mcp\Console\Commands\InspectorCommand;
233234
$reflection = new ReflectionClass($command);
234235
$method = $reflection->getMethod('phpBinary');
235-
$method->setAccessible(true);
236236

237237
$phpBinary = $method->invoke($command);
238238

239239
// Should return either a path to php or 'php'
240240
expect($phpBinary)->toBeString();
241-
expect(strlen($phpBinary))->toBeGreaterThan(0);
241+
expect(strlen((string) $phpBinary))->toBeGreaterThan(0);
242242
});

0 commit comments

Comments
 (0)