Skip to content

Commit fc18fd4

Browse files
committed
Prepare package slicing by strict namespace refactoring into Client, Schema, and Server
1 parent c5dbfb6 commit fc18fd4

425 files changed

Lines changed: 1352 additions & 1200 deletions

File tree

Some content is hidden

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

‎.gitignore‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
.deptrac.cache
12
.phpunit.cache
23
.php-cs-fixer.cache
34
composer.lock

‎CHANGELOG.md‎

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

33
All notable changes to `mcp/sdk` will be documented in this file.
44

5+
0.9.0
6+
-----
7+
8+
* [BC Break] Split the root namespace into `Mcp\Schema`, `Mcp\Client` and `Mcp\Server` to prepare package slicing. `Mcp\Schema` depends on nothing, `Mcp\Client` and `Mcp\Server` depend on `Mcp\Schema` only — enforced by Deptrac (`make deptrac`).
9+
* `Mcp\Server` => `Mcp\Server\Server`
10+
* `Mcp\Client` => `Mcp\Client\Client`
11+
* `Mcp\Capability\*` => `Mcp\Server\Capability\*` (`Attribute`, `Completion`, `Discovery`, `Formatter`, `Logger`, `Registry`, `Tool`, plus `Registry` and `RegistryInterface`)
12+
* `Mcp\Event\*` => `Mcp\Server\Event\*`
13+
* `Mcp\JsonRpc\MessageFactory` => `Mcp\Schema\MessageFactory`
14+
* `Mcp\Server\Stateless\RequestMeta` => `Mcp\Schema\RequestMeta`
15+
* [BC Break] Distribute `Mcp\Exception\*` across the three namespaces.
16+
* `Mcp\Exception\{ExceptionInterface,InvalidArgumentException,LogicException,RuntimeException}` => the same names under `Mcp\Schema\Exception\`, `Mcp\Client\Exception\` and `Mcp\Server\Exception\` — pick the one matching the package you catch around
17+
* `Mcp\Exception\Exception` => `Mcp\Client\Exception\Exception` and `Mcp\Server\Exception\Exception`
18+
* `Mcp\Exception\{InvalidInputMessageException,MissingRequestMetaException}` => `Mcp\Schema\Exception\*`
19+
* `Mcp\Exception\{ConnectionException,ElicitationException,RequestException,RootsException,SamplingException}` => `Mcp\Client\Exception\*`
20+
* `Mcp\Exception\{BadMethodCallException,ClientException,ClientRegistrationException,ConfigurationException,ContainerException,InvalidCursorException,MissingRequiredClientCapabilityException,NotFoundExceptionInterface,PromptGetException,PromptNotFoundException,RegistryException,RequestStateException,ResourceNotFoundException,ResourceReadException,ServiceNotFoundException,ToolCallException,ToolNotFoundException}` => `Mcp\Server\Exception\*`
21+
* `Mcp\Exception\TimeoutException` and `Mcp\Exception\HandlerNotFoundException` are removed; both were unused.
22+
* `Mcp\Server\Exception\ExceptionInterface` and `Mcp\Client\Exception\ExceptionInterface` extend `Mcp\Schema\Exception\ExceptionInterface`, so catching the latter still catches any SDK exception.
23+
* The named exceptions now extend their package's `RuntimeException`/`InvalidArgumentException` instead of the global ones, so `catch (Mcp\Server\Exception\RuntimeException)` reaches `ToolCallException`, `PromptGetException` and friends.
24+
525
0.8.0
626
-----
727

‎README.md‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ composer require mcp/sdk
3636
A server is a plain PHP class plus three lines of wiring:
3737

3838
```php
39-
use Mcp\Capability\Attribute\McpResource;
40-
use Mcp\Capability\Attribute\McpTool;
41-
use Mcp\Server;
39+
use Mcp\Server\Capability\Attribute\McpResource;
40+
use Mcp\Server\Capability\Attribute\McpTool;
41+
use Mcp\Server\Server;
4242
use Mcp\Server\Transport\StdioTransport;
4343

4444
class Calculator
@@ -72,7 +72,7 @@ The walkthrough in [First server](docs/get-started/first-server.md) explains eac
7272
## Build a client
7373

7474
```php
75-
use Mcp\Client;
75+
use Mcp\Client\Client;
7676
use Mcp\Client\Transport\StdioTransport;
7777

7878
$client = Client::builder()

‎composer.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@
8484
"Mcp\\Tests\\": "tests/"
8585
},
8686
"classmap": [
87-
"tests/Unit/Capability/Discovery/Fixtures/AlternativeFileNameToolHandler.class.inc"
87+
"tests/Unit/Server/Capability/Discovery/Fixtures/AlternativeFileNameToolHandler.class.inc"
8888
]
8989
},
9090
"config": {

‎docs/advanced/events.md‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ The MCP SDK provides a PSR-14 compatible event system that allows you to hook in
77
Configure an event dispatcher when building your server:
88

99
```php
10-
use Mcp\Event\RequestEvent;
11-
use Mcp\Server;
10+
use Mcp\Server\Event\RequestEvent;
11+
use Mcp\Server\Server;
1212
use Symfony\Component\EventDispatcher\EventDispatcher;
1313

1414
$dispatcher = new EventDispatcher();
@@ -86,7 +86,7 @@ These events are dispatched when the lists of available capabilities change:
8686
These events carry no data and are used to notify clients that they should refresh their capability lists.
8787

8888
```php
89-
use Mcp\Event\ToolListChangedEvent;
89+
use Mcp\Server\Event\ToolListChangedEvent;
9090

9191
$dispatcher->addListener(ToolListChangedEvent::class, function (ToolListChangedEvent $event) {
9292
$logger->info('Tool list has changed, clients should refresh');

‎docs/advanced/extensions.md‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ the SDK places the advertisement correctly for whichever era the client speaks:
77

88
```php
99
use Mcp\Schema\Extension\Apps\McpApps;
10-
use Mcp\Server;
10+
use Mcp\Server\Server;
1111

1212
$server = Server::builder()
1313
->setServerInfo('My Server', '1.0.0')
@@ -112,11 +112,11 @@ descriptor marker: `McpApps::resourceMarker()` is a method call and cannot appea
112112
in an attribute, so spell it as `new \stdClass()` there.
113113

114114
```php
115-
use Mcp\Capability\Attribute\McpResource;
116-
use Mcp\Capability\Attribute\McpTool;
117115
use Mcp\Schema\Extension\Apps\McpApps;
118116
use Mcp\Schema\Extension\Apps\ToolVisibility;
119117
use Mcp\Schema\Extension\Apps\UiToolMeta;
118+
use Mcp\Server\Capability\Attribute\McpResource;
119+
use Mcp\Server\Capability\Attribute\McpTool;
120120

121121
final class WeatherApp
122122
{

‎docs/client/connecting.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ The `Client\Builder` provides fluent configuration of client instances.
1313
### Basic Configuration
1414

1515
```php
16-
use Mcp\Client;
16+
use Mcp\Client\Client;
1717

1818
$client = Client::builder()
1919
->setClientInfo('My Application', '1.0.0', 'Description of my client')

‎docs/client/errors.md‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ The client throws exceptions for various error conditions:
77
Thrown when connection or initialization fails:
88

99
```php
10-
use Mcp\Exception\ConnectionException;
10+
use Mcp\Client\Exception\ConnectionException;
1111

1212
try {
1313
$client->connect($transport);
@@ -21,7 +21,7 @@ try {
2121
Thrown when a request returns an error response:
2222

2323
```php
24-
use Mcp\Exception\RequestException;
24+
use Mcp\Client\Exception\RequestException;
2525

2626
try {
2727
$result = $client->callTool('unknown_tool', []);
@@ -38,12 +38,12 @@ Here's a comprehensive example demonstrating client usage:
3838
```php-file
3939
<?php
4040
41-
use Mcp\Client;
41+
use Mcp\Client\Client;
4242
use Mcp\Client\Handler\Notification\LoggingNotificationHandler;
4343
use Mcp\Client\Handler\Request\SamplingCallbackInterface;
4444
use Mcp\Client\Handler\Request\SamplingRequestHandler;
4545
use Mcp\Client\Transport\StdioTransport;
46-
use Mcp\Exception\SamplingException;
46+
use Mcp\Client\Exception\SamplingException;
4747
use Mcp\Schema\ClientCapabilities;
4848
use Mcp\Schema\Content\TextContent;
4949
use Mcp\Schema\Enum\LoggingLevel;

‎docs/client/index.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ discover what it offers, and call it. The API is synchronous — every method re
55
result or throws.
66

77
```php
8-
use Mcp\Client;
8+
use Mcp\Client\Client;
99
use Mcp\Client\Transport\StdioTransport;
1010

1111
// Build and configure the client

‎docs/client/server-requests.md‎

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,8 @@ needs; your callback presents them to the user and returns an `ElicitResult` wit
1010
three actions — accept (with the collected content), decline, or cancel:
1111

1212
```php
13-
use Mcp\Client\Handler\Request\ElicitationRequestHandler;
1413
use Mcp\Client\Handler\Request\ElicitationCallbackInterface;
15-
use Mcp\Exception\ElicitationException;
14+
use Mcp\Client\Handler\Request\ElicitationRequestHandler;
1615
use Mcp\Schema\ClientCapabilities;
1716
use Mcp\Schema\Enum\ElicitAction;
1817
use Mcp\Schema\Enum\ElicitationMode;
@@ -84,14 +83,14 @@ elicitation demo server.
8483
Handle server requests for LLM completions:
8584

8685
```php
87-
use Mcp\Client\Handler\Request\SamplingRequestHandler;
86+
use Mcp\Client\Exception\SamplingException;
8887
use Mcp\Client\Handler\Request\SamplingCallbackInterface;
89-
use Mcp\Exception\SamplingException;
88+
use Mcp\Client\Handler\Request\SamplingRequestHandler;
9089
use Mcp\Schema\ClientCapabilities;
91-
use Mcp\Schema\Request\CreateSamplingMessageRequest;
92-
use Mcp\Schema\Result\CreateSamplingMessageResult;
9390
use Mcp\Schema\Content\TextContent;
9491
use Mcp\Schema\Enum\Role;
92+
use Mcp\Schema\Request\CreateSamplingMessageRequest;
93+
use Mcp\Schema\Result\CreateSamplingMessageResult;
9594

9695
class LlmSamplingCallback implements SamplingCallbackInterface
9796
{

0 commit comments

Comments
 (0)