Skip to content

Commit 4e51bca

Browse files
feat(core): Integrate php-mcp/schema package for core DTOs and messages
Replaces internal MCP data structures (Requests, Responses, Results, Content types, Enums, and model definitions like Tool, Resource) with their counterparts from the new `php-mcp/schema` package, enhancing type safety and compliance with the MCP specification.
1 parent 38ad45e commit 4e51bca

File tree

68 files changed

+952
-4614
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+952
-4614
lines changed

composer.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
"require": {
1414
"php": ">=8.1",
1515
"opis/json-schema": "^2.4",
16+
"php-mcp/schema": "dev-main",
1617
"phpdocumentor/reflection-docblock": "^5.6",
1718
"psr/container": "^1.0 || ^2.0",
1819
"psr/event-dispatcher": "^1.0",
@@ -57,5 +58,11 @@
5758
}
5859
},
5960
"minimum-stability": "dev",
60-
"prefer-stable": true
61+
"prefer-stable": true,
62+
"repositories": [
63+
{
64+
"type": "path",
65+
"url": "../schema"
66+
}
67+
]
6168
}

examples/02-discovery-http-userprofile/server.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ public function log($level, \Stringable|string $message, array $context = []): v
7171

7272
$server->discover(__DIR__, ['.']);
7373

74-
// $transport = new HttpServerTransport('127.0.0.1', 8080, 'mcp');
75-
$transport = new StreamableHttpServerTransport('127.0.0.1', 8080, 'mcp');
74+
$transport = new HttpServerTransport('127.0.0.1', 8080, 'mcp');
75+
// $transport = new StreamableHttpServerTransport('127.0.0.1', 8080, 'mcp');
7676

7777
$server->listen($transport);
7878

src/Attributes/McpResource.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
namespace PhpMcp\Server\Attributes;
44

55
use Attribute;
6-
use PhpMcp\Server\Model\Annotations;
6+
use PhpMcp\Schema\Annotations;
77

88
/**
99
* Marks a PHP class as representing or handling a specific MCP Resource instance.
@@ -27,6 +27,5 @@ public function __construct(
2727
public ?string $mimeType = null,
2828
public ?int $size = null,
2929
public ?Annotations $annotations = null,
30-
) {
31-
}
30+
) {}
3231
}

src/Attributes/McpResourceTemplate.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
namespace PhpMcp\Server\Attributes;
44

55
use Attribute;
6-
use PhpMcp\Server\Model\Annotations;
6+
use PhpMcp\Schema\Annotations;
77

88
/**
99
* Marks a PHP class definition as representing an MCP Resource Template.
@@ -25,6 +25,5 @@ public function __construct(
2525
public ?string $description = null,
2626
public ?string $mimeType = null,
2727
public ?Annotations $annotations = null,
28-
) {
29-
}
28+
) {}
3029
}

src/Attributes/McpTool.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
namespace PhpMcp\Server\Attributes;
44

55
use Attribute;
6-
use PhpMcp\Server\Model\ToolAnnotations;
6+
use PhpMcp\Schema\ToolAnnotations;
77

88
#[Attribute(Attribute::TARGET_METHOD | Attribute::TARGET_CLASS)]
99
class McpTool
@@ -17,6 +17,5 @@ public function __construct(
1717
public ?string $name = null,
1818
public ?string $description = null,
1919
public ?ToolAnnotations $annotations = null,
20-
) {
21-
}
20+
) {}
2221
}

src/Configuration.php

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

55
namespace PhpMcp\Server;
66

7-
use PhpMcp\Server\Model\Capabilities;
7+
use PhpMcp\Schema\Implementation;
8+
use PhpMcp\Schema\ServerCapabilities;
89
use Psr\Container\ContainerInterface;
910
use Psr\Log\LoggerInterface;
1011
use Psr\SimpleCache\CacheInterface;
@@ -18,9 +19,8 @@
1819
class Configuration
1920
{
2021
/**
21-
* @param string $serverName Name of this MCP server application.
22-
* @param string $serverVersion Version of this MCP server application.
23-
* @param Capabilities $capabilities Capabilities of this MCP server application.
22+
* @param Implementation $serverInfo Info about this MCP server application.
23+
* @param ServerCapabilities $capabilities Capabilities of this MCP server application.
2424
* @param LoggerInterface $logger PSR-3 Logger instance.
2525
* @param LoopInterface $loop ReactPHP Event Loop instance.
2626
* @param CacheInterface|null $cache Optional PSR-16 Cache instance for registry/state.
@@ -29,15 +29,13 @@ class Configuration
2929
* @param int $paginationLimit Maximum number of items to return for list methods.
3030
*/
3131
public function __construct(
32-
public readonly string $serverName,
33-
public readonly string $serverVersion,
34-
public readonly Capabilities $capabilities,
32+
public readonly Implementation $serverInfo,
33+
public readonly ServerCapabilities $capabilities,
3534
public readonly LoggerInterface $logger,
3635
public readonly LoopInterface $loop,
3736
public readonly ?CacheInterface $cache,
3837
public readonly ContainerInterface $container,
3938
public readonly int $definitionCacheTtl = 3600,
4039
public readonly int $paginationLimit = 50,
41-
) {
42-
}
40+
) {}
4341
}

src/Contracts/ServerTransportInterface.php

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

77
use Evenement\EventEmitterInterface;
88
use PhpMcp\Server\Exception\TransportException;
9-
use PhpMcp\Server\JsonRpc\Messages\Message;
9+
use PhpMcp\Schema\JsonRpc\Message;
1010
use React\Promise\PromiseInterface;
1111

1212
/**

src/Definitions/PromptArgumentDefinition.php

Lines changed: 0 additions & 77 deletions
This file was deleted.

src/Definitions/PromptDefinition.php

Lines changed: 0 additions & 140 deletions
This file was deleted.

0 commit comments

Comments
 (0)