Skip to content

Commit 2e662d0

Browse files
authored
Update JsonSchema usage (#120)
* Update JsonSchema usage * Fix test * Fix charset=UTF-8 Test * Fix charset=UTF-8 Test
1 parent 3de2b22 commit 2e662d0

18 files changed

+31
-25
lines changed

rector.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
declare(strict_types=1);
44

5+
use Rector\CodingStyle\Rector\ClassLike\NewlineBetweenClassLikeStmtsRector;
56
use Rector\CodingStyle\Rector\Encapsed\EncapsedStringsToSprintfRector;
67
use Rector\Config\RectorConfig;
78
use Rector\Php81\Rector\Property\ReadOnlyPropertyRector;
@@ -14,6 +15,7 @@
1415
->withSkip([
1516
ReadOnlyPropertyRector::class,
1617
EncapsedStringsToSprintfRector::class,
18+
NewlineBetweenClassLikeStmtsRector::class,
1719
])
1820
->withPreparedSets(
1921
deadCode: true,

src/Server/Tool.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44

55
namespace Laravel\Mcp\Server;
66

7-
use Illuminate\JsonSchema\JsonSchema;
7+
use Illuminate\Contracts\JsonSchema\JsonSchema;
8+
use Illuminate\JsonSchema\JsonSchema as JsonSchemaFactory;
89
use Laravel\Mcp\Server\Concerns\HasAnnotations;
910
use Laravel\Mcp\Server\Tools\Annotations\ToolAnnotation;
1011

@@ -55,11 +56,11 @@ public function toArray(): array
5556
{
5657
$annotations = $this->annotations();
5758

58-
$schema = JsonSchema::object(
59+
$schema = JsonSchemaFactory::object(
5960
$this->schema(...),
6061
)->toArray();
6162

62-
$outputSchema = JsonSchema::object(
63+
$outputSchema = JsonSchemaFactory::object(
6364
$this->outputSchema(...),
6465
)->toArray();
6566

stubs/tool.stub

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace {{ namespace }};
44

5-
use Illuminate\JsonSchema\JsonSchema;
5+
use Illuminate\Contracts\JsonSchema\JsonSchema;
66
use Laravel\Mcp\Request;
77
use Laravel\Mcp\Response;
88
use Laravel\Mcp\Server\Tool;
@@ -29,7 +29,7 @@ class {{ class }} extends Tool
2929
/**
3030
* Get the tool's input schema.
3131
*
32-
* @return array<string, \Illuminate\JsonSchema\JsonSchema>
32+
* @return array<string, \Illuminate\Contracts\JsonSchema\JsonSchema>
3333
*/
3434
public function schema(JsonSchema $schema): array
3535
{

tests/Feature/Console/StartCommandTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,8 @@
104104
);
105105

106106
$response->assertStatus(200);
107-
$response->assertHeader('Content-Type', 'text/event-stream; charset=UTF-8');
107+
108+
expect(strtolower((string) $response->headers->get('Content-Type')))->toBe('text/event-stream; charset=utf-8');
108109

109110
$content = $response->streamedContent();
110111
$messages = parseJsonRpcMessagesFromSseStream($content);

tests/Fixtures/ResponseFactoryWithStructuredContentTool.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
namespace Tests\Fixtures;
66

7-
use Illuminate\JsonSchema\JsonSchema;
7+
use Illuminate\Contracts\JsonSchema\JsonSchema;
88
use Laravel\Mcp\Request;
99
use Laravel\Mcp\Response;
1010
use Laravel\Mcp\ResponseFactory;

tests/Fixtures/SayHiTool.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace Tests\Fixtures;
44

5-
use Illuminate\JsonSchema\JsonSchema;
5+
use Illuminate\Contracts\JsonSchema\JsonSchema;
66
use Laravel\Mcp\Request;
77
use Laravel\Mcp\Response;
88
use Laravel\Mcp\Server\Tool;

tests/Fixtures/SayHiTwiceTool.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace Tests\Fixtures;
44

5-
use Illuminate\JsonSchema\JsonSchema;
5+
use Illuminate\Contracts\JsonSchema\JsonSchema;
66
use Laravel\Mcp\Request;
77
use Laravel\Mcp\Response;
88
use Laravel\Mcp\Server\Tool;

tests/Fixtures/SayHiWithMetaTool.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
namespace Tests\Fixtures;
66

7-
use Illuminate\JsonSchema\JsonSchema;
7+
use Illuminate\Contracts\JsonSchema\JsonSchema;
88
use Laravel\Mcp\Request;
99
use Laravel\Mcp\Response;
1010
use Laravel\Mcp\Server\Tool;

tests/Fixtures/StreamingTool.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
namespace Tests\Fixtures;
44

55
use Generator;
6-
use Illuminate\JsonSchema\JsonSchema;
6+
use Illuminate\Contracts\JsonSchema\JsonSchema;
77
use Laravel\Mcp\Request;
88
use Laravel\Mcp\Response;
99
use Laravel\Mcp\Server\Tool;

tests/Fixtures/StructuredContentTool.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
namespace Tests\Fixtures;
66

7-
use Illuminate\JsonSchema\JsonSchema;
7+
use Illuminate\Contracts\JsonSchema\JsonSchema;
88
use Laravel\Mcp\Request;
99
use Laravel\Mcp\Response;
1010
use Laravel\Mcp\ResponseFactory;

0 commit comments

Comments
 (0)