File tree Expand file tree Collapse file tree 10 files changed +41
-438
lines changed Expand file tree Collapse file tree 10 files changed +41
-438
lines changed Original file line number Diff line number Diff line change @@ -101,13 +101,15 @@ php artisan make:mcp-tool ExampleTool
101
101
Your tools can request arguments from the MCP client using a tool input schema:
102
102
103
103
``` php
104
- public function schema(ToolInputSchema $schema): ToolInputSchema
105
- {
106
- $schema->string('iso_country_code')
107
- ->description('2 character country code')
108
- ->required();
104
+ use Illuminate\JsonSchema\JsonSchema;
109
105
110
- return $schema;
106
+ public function schema(JsonSchema $schema): array
107
+ {
108
+ return [
109
+ 'name' => $schema->string()
110
+ ->description('The name of the user')
111
+ ->required(),
112
+ ];
111
113
}
112
114
```
113
115
Original file line number Diff line number Diff line change 24
24
"illuminate/http" : " ^10.0|^11.0|^12.0" ,
25
25
"illuminate/routing" : " ^10.0|^11.0|^12.0" ,
26
26
"illuminate/support" : " ^10.0|^11.0|^12.0" ,
27
- "illuminate/validation" : " ^10.0|^11.0|^12.0"
27
+ "illuminate/validation" : " ^10.0|^11.0|^12.0" ,
28
+ "illuminate/json-schema" : " ^12.28"
28
29
},
29
30
"require-dev" : {
30
31
"laravel/pint" : " ^1.20" ,
Original file line number Diff line number Diff line change 6
6
7
7
use Generator ;
8
8
use Illuminate \Contracts \Support \Arrayable ;
9
+ use Illuminate \JsonSchema \JsonSchema ;
9
10
use Illuminate \Support \Str ;
10
- use Laravel \Mcp \Server \Tools \ToolInputSchema ;
11
11
use Laravel \Mcp \Server \Tools \ToolNotification ;
12
12
use Laravel \Mcp \Server \Tools \ToolResult ;
13
13
use ReflectionClass ;
@@ -21,9 +21,12 @@ public function name(): string
21
21
return Str::kebab (class_basename ($ this ));
22
22
}
23
23
24
- public function schema (ToolInputSchema $ schema ): ToolInputSchema
24
+ /**
25
+ `* Get the tool input schema.
26
+ */
27
+ public function schema (JsonSchema $ schema ): array
25
28
{
26
- return $ schema ;
29
+ return [] ;
27
30
}
28
31
29
32
public function description (): string
@@ -53,7 +56,9 @@ public function toArray(): array
53
56
return [
54
57
'name ' => $ this ->name (),
55
58
'description ' => $ this ->description (),
56
- 'inputSchema ' => $ this ->schema (new ToolInputSchema )->toArray (),
59
+ 'inputSchema ' => JsonSchema::object (
60
+ fn (JsonSchema $ schema ) => $ this ->schema ($ schema ),
61
+ )->toArray (),
57
62
'annotations ' => $ this ->annotations () ?: (object ) [],
58
63
];
59
64
}
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 3
3
namespace {{ namespace }};
4
4
5
5
use Generator;
6
+ use Illuminate\JsonSchema\JsonSchema;
6
7
use Laravel\Mcp\Server\Tools\Annotations\Title;
7
8
use Laravel\Mcp\Server\Tool;
8
- use Laravel\Mcp\Server\Tools\ToolInputSchema;
9
9
use Laravel\Mcp\Server\Tools\ToolResult;
10
10
11
11
#[Title('{{ title }}')]
@@ -27,12 +27,12 @@ class {{ class }} extends Tool
27
27
/**
28
28
* Get the tool's input schema.
29
29
*/
30
- public function schema(ToolInputSchema $schema): ToolInputSchema
30
+ public function schema(JsonSchema $schema): array
31
31
{
32
- $schema->string('example')
33
- ->description('An example input description.' )
34
- ->required();
35
-
36
- return $schema ;
32
+ return [
33
+ ' example' => $schema->string( )
34
+ ->description('An example input description.')
35
+ ->required(),
36
+ ] ;
37
37
}
38
38
}
Original file line number Diff line number Diff line change 4
4
5
5
use Generator ;
6
6
use Illuminate \Contracts \Validation \Validator ;
7
+ use Illuminate \JsonSchema \JsonSchema ;
7
8
use Illuminate \Support \MessageBag ;
8
9
use Illuminate \Validation \ValidationException ;
9
10
use Laravel \Mcp \Server \Tool ;
10
- use Laravel \Mcp \Server \Tools \ToolInputSchema ;
11
11
use Laravel \Mcp \Server \Tools \ToolResult ;
12
12
use Mockery ;
13
13
14
14
class ExampleTool extends Tool
15
15
{
16
16
protected string $ description = 'This tool says hello to a person ' ;
17
17
18
- public function schema (ToolInputSchema $ schema ): ToolInputSchema
18
+ public function schema (JsonSchema $ schema ): array
19
19
{
20
- return $ schema ->string ('name ' )->description ('The name of the person to greet ' )->required ();
20
+ return [
21
+ 'name ' => $ schema ->string ()
22
+ ->description ('The name of the person to greet ' )
23
+ ->required (),
24
+ ];
21
25
}
22
26
23
27
public function handle (array $ arguments ): ToolResult |Generator
Original file line number Diff line number Diff line change 3
3
namespace Tests \Fixtures ;
4
4
5
5
use Generator ;
6
+ use Illuminate \JsonSchema \JsonSchema ;
6
7
use Laravel \Mcp \Server \Tool ;
7
- use Laravel \Mcp \Server \Tools \ToolInputSchema ;
8
8
use Laravel \Mcp \Server \Tools \ToolNotification ;
9
9
use Laravel \Mcp \Server \Tools \ToolResult ;
10
10
11
11
class StreamingTool extends Tool
12
12
{
13
13
protected string $ description = 'A tool that streams multiple responses. ' ;
14
14
15
- public function schema (ToolInputSchema $ schema ): ToolInputSchema
15
+ public function schema (JsonSchema $ schema ): array
16
16
{
17
- return $ schema ->integer ('count ' )
18
- ->description ('Number of messages to stream. ' )
19
- ->required ();
17
+ return [
18
+ 'count ' => $ schema ->integer ()
19
+ ->description ('Number of messages to stream. ' )
20
+ ->required (),
21
+ ];
20
22
}
21
23
22
24
public function handle (array $ arguments ): Generator
Original file line number Diff line number Diff line change 11
11
eval ("
12
12
namespace Tests \\Unit \\Methods;
13
13
use Generator;
14
+ use Illuminate\JsonSchema\JsonSchema;
14
15
use Laravel \\Mcp \\Server \\Tool;
15
16
use Laravel \\Mcp \\Server \\Tools \\ToolResult;
16
- use Laravel \\Mcp \\Server \\Tools \\ToolInputSchema;
17
17
class DummyTool {$ i } extends Tool {
18
18
public function description(): string { return 'Description for dummy tool {$ i }'; }
19
- public function schema(ToolInputSchema \$schema): ToolInputSchema { return \$schema; }
20
19
public function handle(array \$arguments): ToolResult|Generator { return []; }
21
20
}
22
21
" );
You can’t perform that action at this time.
0 commit comments