Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -14,6 +15,7 @@
->withSkip([
ReadOnlyPropertyRector::class,
EncapsedStringsToSprintfRector::class,
NewlineBetweenClassLikeStmtsRector::class,
])
->withPreparedSets(
deadCode: true,
Expand Down
7 changes: 4 additions & 3 deletions src/Server/Tool.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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();

Expand Down
4 changes: 2 additions & 2 deletions stubs/tool.stub
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -29,7 +29,7 @@ class {{ class }} extends Tool
/**
* Get the tool's input schema.
*
* @return array<string, \Illuminate\JsonSchema\JsonSchema>
* @return array<string, \Illuminate\Contracts\JsonSchema\JsonSchema>
*/
public function schema(JsonSchema $schema): array
{
Expand Down
3 changes: 2 additions & 1 deletion tests/Feature/Console/StartCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion tests/Fixtures/SayHiTool.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion tests/Fixtures/SayHiTwiceTool.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion tests/Fixtures/SayHiWithMetaTool.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion tests/Fixtures/StreamingTool.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion tests/Fixtures/StructuredContentTool.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion tests/Fixtures/StructuredContentWithMetaTool.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion tests/Fixtures/ToolWithBothMetaTool.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion tests/Fixtures/ToolWithOutputSchema.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion tests/Fixtures/ToolWithResultMetaTool.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion tests/Fixtures/ToolWithoutOutputSchema.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 3 additions & 2 deletions tests/Unit/Methods/ListToolsTest.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php

use Illuminate\Contracts\JsonSchema\JsonSchema;
use Laravel\Mcp\Request;
use Laravel\Mcp\Server\Methods\ListTools;
use Laravel\Mcp\Server\ServerContext;
Expand All @@ -15,7 +16,7 @@
eval("
namespace Tests\\Unit\\Methods;
use Generator;
use Illuminate\JsonSchema\JsonSchema;
use Illuminate\Contracts\JsonSchema\JsonSchema;
use Laravel\\Mcp\\Server\\Tool;
use Laravel\\Mcp\\Server\\Tools\\ToolResult;
class DummyTool{$i} extends Tool {
Expand Down Expand Up @@ -503,7 +504,7 @@ public function shouldRegister(Request $request): bool

$toolWithDefaultObjectType = new class extends SayHiTool
{
public function outputSchema(\Illuminate\JsonSchema\JsonSchema $schema): array
public function outputSchema(JsonSchema $schema): array
{
return [];
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/Resources/ListToolsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
eval("
namespace Tests\\Unit\\Methods;
use Generator;
use Illuminate\JsonSchema\JsonSchema;
use Illuminate\Contracts\JsonSchema\JsonSchema;
use Laravel\\Mcp\\Server\\Tool;
use Laravel\\Mcp\\Server\\Tools\\ToolResult;
class DummyTool{$i} extends Tool {
Expand Down
11 changes: 6 additions & 5 deletions tests/Unit/Tools/ToolTest.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
<?php

use Illuminate\Contracts\JsonSchema\JsonSchema;
use Laravel\Mcp\Response;
use Laravel\Mcp\Server\Tool;
use Laravel\Mcp\Server\Tools\Annotations\IsDestructive;
use Laravel\Mcp\Server\Tools\Annotations\IsIdempotent;
use Laravel\Mcp\Server\Tools\Annotations\IsOpenWorld;
use Laravel\Mcp\Server\Tools\Annotations\IsReadOnly;
use Laravel\Mcp\Server\Tools\ToolResult;

test('the default name is in kebab case', function (): void {
$tool = new AnotherComplexToolName;
Expand Down Expand Up @@ -122,9 +123,9 @@ public function description(): string
return 'A test tool';
}

public function handle(): ToolResult|Generator
public function handle(): Response
{
return ToolResult::text('test');
return Response::text('test');
}
}

Expand Down Expand Up @@ -169,7 +170,7 @@ class CustomToolName extends TestTool

class ToolWithSchema extends TestTool
{
public function schema(\Illuminate\JsonSchema\JsonSchema $schema): array
public function schema(JsonSchema $schema): array
{
return [
'message' => $schema->string()->description('The message to echo')->required(),
Expand All @@ -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(),
Expand Down