diff --git a/rector.php b/rector.php index a8fd22a9..bf559fe5 100644 --- a/rector.php +++ b/rector.php @@ -2,6 +2,7 @@ declare(strict_types=1); +use Rector\CodingStyle\Rector\ClassLike\NewlineBetweenClassLikeStmtsRector; use Rector\CodingStyle\Rector\Encapsed\EncapsedStringsToSprintfRector; use Rector\Config\RectorConfig; use Rector\Php81\Rector\Property\ReadOnlyPropertyRector; @@ -14,6 +15,7 @@ ->withSkip([ ReadOnlyPropertyRector::class, EncapsedStringsToSprintfRector::class, + NewlineBetweenClassLikeStmtsRector::class, ]) ->withPreparedSets( deadCode: true, diff --git a/src/Server/Tool.php b/src/Server/Tool.php index 724996ac..e9950407 100644 --- a/src/Server/Tool.php +++ b/src/Server/Tool.php @@ -4,7 +4,8 @@ namespace Laravel\Mcp\Server; -use Illuminate\JsonSchema\JsonSchema; +use Illuminate\Contracts\JsonSchema\JsonSchema; +use Illuminate\JsonSchema\JsonSchema as JsonSchemaFactory; use Laravel\Mcp\Server\Concerns\HasAnnotations; use Laravel\Mcp\Server\Tools\Annotations\ToolAnnotation; @@ -55,11 +56,11 @@ public function toArray(): array { $annotations = $this->annotations(); - $schema = JsonSchema::object( + $schema = JsonSchemaFactory::object( $this->schema(...), )->toArray(); - $outputSchema = JsonSchema::object( + $outputSchema = JsonSchemaFactory::object( $this->outputSchema(...), )->toArray(); diff --git a/stubs/tool.stub b/stubs/tool.stub index 8ae9c7d6..16d7e778 100644 --- a/stubs/tool.stub +++ b/stubs/tool.stub @@ -2,7 +2,7 @@ namespace {{ namespace }}; -use Illuminate\JsonSchema\JsonSchema; +use Illuminate\Contracts\JsonSchema\JsonSchema; use Laravel\Mcp\Request; use Laravel\Mcp\Response; use Laravel\Mcp\Server\Tool; @@ -29,7 +29,7 @@ class {{ class }} extends Tool /** * Get the tool's input schema. * - * @return array + * @return array */ public function schema(JsonSchema $schema): array { diff --git a/tests/Feature/Console/StartCommandTest.php b/tests/Feature/Console/StartCommandTest.php index b7ff5b36..4807b852 100644 --- a/tests/Feature/Console/StartCommandTest.php +++ b/tests/Feature/Console/StartCommandTest.php @@ -104,7 +104,8 @@ ); $response->assertStatus(200); - $response->assertHeader('Content-Type', 'text/event-stream; charset=UTF-8'); + + expect(strtolower((string) $response->headers->get('Content-Type')))->toBe('text/event-stream; charset=utf-8'); $content = $response->streamedContent(); $messages = parseJsonRpcMessagesFromSseStream($content); diff --git a/tests/Fixtures/ResponseFactoryWithStructuredContentTool.php b/tests/Fixtures/ResponseFactoryWithStructuredContentTool.php index a3ec1bc1..e3e3f968 100644 --- a/tests/Fixtures/ResponseFactoryWithStructuredContentTool.php +++ b/tests/Fixtures/ResponseFactoryWithStructuredContentTool.php @@ -4,7 +4,7 @@ namespace Tests\Fixtures; -use Illuminate\JsonSchema\JsonSchema; +use Illuminate\Contracts\JsonSchema\JsonSchema; use Laravel\Mcp\Request; use Laravel\Mcp\Response; use Laravel\Mcp\ResponseFactory; diff --git a/tests/Fixtures/SayHiTool.php b/tests/Fixtures/SayHiTool.php index 85dc79d5..be297f02 100644 --- a/tests/Fixtures/SayHiTool.php +++ b/tests/Fixtures/SayHiTool.php @@ -2,7 +2,7 @@ namespace Tests\Fixtures; -use Illuminate\JsonSchema\JsonSchema; +use Illuminate\Contracts\JsonSchema\JsonSchema; use Laravel\Mcp\Request; use Laravel\Mcp\Response; use Laravel\Mcp\Server\Tool; diff --git a/tests/Fixtures/SayHiTwiceTool.php b/tests/Fixtures/SayHiTwiceTool.php index 29a746d4..fe16dbb0 100644 --- a/tests/Fixtures/SayHiTwiceTool.php +++ b/tests/Fixtures/SayHiTwiceTool.php @@ -2,7 +2,7 @@ namespace Tests\Fixtures; -use Illuminate\JsonSchema\JsonSchema; +use Illuminate\Contracts\JsonSchema\JsonSchema; use Laravel\Mcp\Request; use Laravel\Mcp\Response; use Laravel\Mcp\Server\Tool; diff --git a/tests/Fixtures/SayHiWithMetaTool.php b/tests/Fixtures/SayHiWithMetaTool.php index 8e0b4e1f..0ab3c7d9 100644 --- a/tests/Fixtures/SayHiWithMetaTool.php +++ b/tests/Fixtures/SayHiWithMetaTool.php @@ -4,7 +4,7 @@ namespace Tests\Fixtures; -use Illuminate\JsonSchema\JsonSchema; +use Illuminate\Contracts\JsonSchema\JsonSchema; use Laravel\Mcp\Request; use Laravel\Mcp\Response; use Laravel\Mcp\Server\Tool; diff --git a/tests/Fixtures/StreamingTool.php b/tests/Fixtures/StreamingTool.php index 90f94816..93c7aaa2 100644 --- a/tests/Fixtures/StreamingTool.php +++ b/tests/Fixtures/StreamingTool.php @@ -3,7 +3,7 @@ namespace Tests\Fixtures; use Generator; -use Illuminate\JsonSchema\JsonSchema; +use Illuminate\Contracts\JsonSchema\JsonSchema; use Laravel\Mcp\Request; use Laravel\Mcp\Response; use Laravel\Mcp\Server\Tool; diff --git a/tests/Fixtures/StructuredContentTool.php b/tests/Fixtures/StructuredContentTool.php index 30fa63c8..c43119d3 100644 --- a/tests/Fixtures/StructuredContentTool.php +++ b/tests/Fixtures/StructuredContentTool.php @@ -4,7 +4,7 @@ namespace Tests\Fixtures; -use Illuminate\JsonSchema\JsonSchema; +use Illuminate\Contracts\JsonSchema\JsonSchema; use Laravel\Mcp\Request; use Laravel\Mcp\Response; use Laravel\Mcp\ResponseFactory; diff --git a/tests/Fixtures/StructuredContentWithMetaTool.php b/tests/Fixtures/StructuredContentWithMetaTool.php index 278ae858..607cfa25 100644 --- a/tests/Fixtures/StructuredContentWithMetaTool.php +++ b/tests/Fixtures/StructuredContentWithMetaTool.php @@ -4,7 +4,7 @@ namespace Tests\Fixtures; -use Illuminate\JsonSchema\JsonSchema; +use Illuminate\Contracts\JsonSchema\JsonSchema; use Laravel\Mcp\Request; use Laravel\Mcp\Response; use Laravel\Mcp\ResponseFactory; diff --git a/tests/Fixtures/ToolWithBothMetaTool.php b/tests/Fixtures/ToolWithBothMetaTool.php index 8ab333dd..1c087e4e 100644 --- a/tests/Fixtures/ToolWithBothMetaTool.php +++ b/tests/Fixtures/ToolWithBothMetaTool.php @@ -4,7 +4,7 @@ namespace Tests\Fixtures; -use Illuminate\JsonSchema\JsonSchema; +use Illuminate\Contracts\JsonSchema\JsonSchema; use Laravel\Mcp\Request; use Laravel\Mcp\Response; use Laravel\Mcp\ResponseFactory; diff --git a/tests/Fixtures/ToolWithOutputSchema.php b/tests/Fixtures/ToolWithOutputSchema.php index b63677fd..9d283e08 100644 --- a/tests/Fixtures/ToolWithOutputSchema.php +++ b/tests/Fixtures/ToolWithOutputSchema.php @@ -4,7 +4,7 @@ namespace Tests\Fixtures; -use Illuminate\JsonSchema\JsonSchema; +use Illuminate\Contracts\JsonSchema\JsonSchema; use Laravel\Mcp\Request; use Laravel\Mcp\Response; use Laravel\Mcp\ResponseFactory; diff --git a/tests/Fixtures/ToolWithResultMetaTool.php b/tests/Fixtures/ToolWithResultMetaTool.php index 1b975940..ebdfc15b 100644 --- a/tests/Fixtures/ToolWithResultMetaTool.php +++ b/tests/Fixtures/ToolWithResultMetaTool.php @@ -4,7 +4,7 @@ namespace Tests\Fixtures; -use Illuminate\JsonSchema\JsonSchema; +use Illuminate\Contracts\JsonSchema\JsonSchema; use Laravel\Mcp\Request; use Laravel\Mcp\Response; use Laravel\Mcp\ResponseFactory; diff --git a/tests/Fixtures/ToolWithoutOutputSchema.php b/tests/Fixtures/ToolWithoutOutputSchema.php index 5a2b2503..5714e102 100644 --- a/tests/Fixtures/ToolWithoutOutputSchema.php +++ b/tests/Fixtures/ToolWithoutOutputSchema.php @@ -4,7 +4,7 @@ namespace Tests\Fixtures; -use Illuminate\JsonSchema\JsonSchema; +use Illuminate\Contracts\JsonSchema\JsonSchema; use Laravel\Mcp\Request; use Laravel\Mcp\Response; use Laravel\Mcp\Server\Tool; diff --git a/tests/Unit/Methods/ListToolsTest.php b/tests/Unit/Methods/ListToolsTest.php index 607cfbdc..c69e143b 100644 --- a/tests/Unit/Methods/ListToolsTest.php +++ b/tests/Unit/Methods/ListToolsTest.php @@ -1,5 +1,6 @@ $schema->string()->description('The message to echo')->required(), @@ -186,7 +187,7 @@ class CustomMetaTool extends TestTool class ToolWithOutputSchema extends TestTool { - public function outputSchema(\Illuminate\JsonSchema\JsonSchema $schema): array + public function outputSchema(JsonSchema $schema): array { return [ 'result' => $schema->string()->description('The result value')->required(),