You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This release marks a significant architectural refactoring of the package, aimed at improving modularity, testability, flexibility, and aligning its structure more closely with the `php-mcp/client` library. The core functionality remains, but the way servers are configured, run, and integrated has fundamentally changed.
@@ -11,27 +19,32 @@ This release marks a significant architectural refactoring of the package, aimed
11
19
#### Core Architecture Overhaul
12
20
13
21
***Decoupled Design:** The server core logic is now separated from the transport (network/IO) layer.
14
-
***`ServerBuilder`:** A new fluent builder (`Server::make()`) is the primary way to configure server identity, dependencies (Logger, Cache, Container, Loop), capabilities, and manually registered elements.
15
-
***`Server` Object:** The main `Server` class, created by the builder, now holds the configured core components (`Registry`, `Processor`, `ClientStateManager`, `Configuration`) but is transport-agnostic itself.
16
-
***`ServerTransportInterface`:** A new event-driven interface defines the contract for server-side transports (Stdio, Http). Transports are now responsible solely for listening and raw data transfer, emitting events for lifecycle and messages.
17
-
***`Protocol`:** A new internal class acts as a bridge, listening to events from a bound `ServerTransportInterface` and coordinating interactions with the `Processor` and `ClientStateManager`.
18
-
22
+
23
+
***`ServerBuilder`:** A new fluent builder (`Server::make()`) is the primary way to configure server identity, dependencies (Logger, Cache, Container, Loop), capabilities, and manually registered elements.
24
+
***`Server` Object:** The main `Server` class, created by the builder, now holds the configured core components (`Registry`, `Processor`, `ClientStateManager`, `Configuration`) but is transport-agnostic itself.
25
+
***`ServerTransportInterface`:** A new event-driven interface defines the contract for server-side transports (Stdio, Http). Transports are now responsible solely for listening and raw data transfer, emitting events for lifecycle and messages.
26
+
***`Protocol`:** A new internal class acts as a bridge, listening to events from a bound `ServerTransportInterface` and coordinating interactions with the `Processor` and `ClientStateManager`.
27
+
19
28
***Explicit Server Execution:**
20
-
* The old `$server->run(?string)` method is **removed**.
21
-
***`$server->listen(ServerTransportInterface $transport)`:** Introduced as the primary way to start a *standalone* server. It binds the `Protocol` to the provided transport, starts the listener, and runs the event loop (making it a blocking call).
22
-
29
+
30
+
* The old `$server->run(?string)` method is **removed**.
31
+
***`$server->listen(ServerTransportInterface $transport)`:** Introduced as the primary way to start a *standalone* server. It binds the `Protocol` to the provided transport, starts the listener, and runs the event loop (making it a blocking call).
32
+
23
33
24
34
#### Discovery and Caching Refinements
25
35
26
36
***Explicit Discovery:** Attribute discovery is no longer triggered automatically during `build()`. You must now explicitly call `$server->discover(basePath: ..., scanDirs: ...)`*after* building the server instance if you want to find elements via attributes.
37
+
27
38
***Caching Behavior:**
28
-
* Only *discovered* elements are eligible for caching. Manually registered elements (via `ServerBuilder->with*` methods) are **never cached**.
29
-
* The `Registry` attempts to load discovered elements from cache upon instantiation (during `ServerBuilder::build()`).
30
-
* Calling `$server->discover()` will first clear any previously discovered/cached elements from the registry before scanning. It then saves the *newly discovered* results to the cache if enabled (`saveToCache: true`).
31
-
*`Registry` cache methods renamed for clarity: `saveDiscoveredElementsToCache()` and `clearDiscoveredElements()`.
32
-
*`Registry::isLoaded()` renamed to `discoveryRanOrCached()` for better clarity.
33
-
39
+
40
+
* Only *discovered* elements are eligible for caching. Manually registered elements (via `ServerBuilder->with*` methods) are **never cached**.
41
+
* The `Registry` attempts to load discovered elements from cache upon instantiation (during `ServerBuilder::build()`).
42
+
* Calling `$server->discover()` will first clear any previously discovered/cached elements from the registry before scanning. It then saves the *newly discovered* results to the cache if enabled (`saveToCache: true`).
43
+
*`Registry` cache methods renamed for clarity: `saveDiscoveredElementsToCache()` and `clearDiscoveredElements()`.
44
+
*`Registry::isLoaded()` renamed to `discoveryRanOrCached()` for better clarity.
45
+
34
46
***Manual vs. Discovered Precedence:** If an element is registered both manually and found via discovery/cache with the same identifier (name/URI), the **manually registered version always takes precedence**.
47
+
35
48
36
49
#### Dependency Injection and Configuration
37
50
@@ -50,12 +63,16 @@ This release marks a significant architectural refactoring of the package, aimed
50
63
#### Transports
51
64
52
65
***New Implementations:** Introduced `PhpMcp\Server\Transports\StdioServerTransport` and `PhpMcp\Server\Transports\HttpServerTransport`, both implementing `ServerTransportInterface`.
53
-
*`StdioServerTransport` constructor now accepts custom input/output stream resources, improving testability and flexibility (defaults to `STDIN`/`STDOUT`).
54
-
*`HttpServerTransport` constructor now accepts an array of request interceptor callables for custom request pre-processing (e.g., authentication), and also takes `host`, `port`, `mcpPathPrefix`, and `sslContext` for server configuration.
55
-
66
+
67
+
*`StdioServerTransport` constructor now accepts custom input/output stream resources, improving testability and flexibility (defaults to `STDIN`/`STDOUT`).
68
+
*`HttpServerTransport` constructor now accepts an array of request interceptor callables for custom request pre-processing (e.g., authentication), and also takes `host`, `port`, `mcpPathPrefix`, and `sslContext` for server configuration.
69
+
56
70
***Windows `stdio` Limitation:**`StdioServerTransport` now throws a `TransportException` if instantiated with default `STDIN`/`STDOUT` on Windows, due to PHP's limitations with non-blocking pipes, guiding users to `WSL` or `HttpServerTransport`.
71
+
57
72
***Aware Interfaces:** Transports can implement `LoggerAwareInterface` and `LoopAwareInterface` to receive the configured Logger and Loop instances when `$server->listen()` is called.
73
+
58
74
***Removed:** The old `StdioTransportHandler`, `HttpTransportHandler`, and `ReactPhpHttpTransportHandler` classes.
75
+
59
76
60
77
#### Capabilities Configuration
61
78
@@ -90,28 +107,39 @@ This release marks a significant architectural refactoring of the package, aimed
90
107
This is a major refactoring with significant breaking changes:
91
108
92
109
1.**`Server->run()` Method Removed:** Replace calls to `$server->run('stdio')` with:
110
+
93
111
```php
94
112
$transport = new StdioServerTransport();
95
-
// Optionally call $server->discover(...) first
96
-
$server->listen($transport);
97
-
113
+
// Optionally call $server->discover(...) first
114
+
$server->listen($transport);
115
+
116
+
98
117
```
99
-
The `http` and `reactphp` options for `run()` were already invalid and are fully removed.
118
+
The `http` and `reactphp` options for `run()` were already invalid and are fully removed.
119
+
100
120
2. **Configuration (`ConfigurationRepositoryInterface` Removed):** Configuration is now handled via the `Configuration` VO assembled by `ServerBuilder`. Remove any usage of the old `ConfigurationRepositoryInterface`. Core settings like server name/version are set via `withServerInfo`, capabilities via `withCapabilities`.
121
+
101
122
3. **Dependency Injection:**
102
-
* If using `ServerBuilder->withContainer()` with a custom PSR-11 container, that container is now only responsible for resolving *your application's handler classes* and their dependencies.
103
-
* Core server dependencies (Logger, Cache, Loop) **must** be provided explicitly to the `ServerBuilder` using `withLogger()`, `withCache()`, `withLoop()` or rely on the builder's defaults.
104
-
123
+
124
+
* If using `ServerBuilder->withContainer()` with a custom PSR-11 container, that container is now only responsible for resolving *your application's handler classes* and their dependencies.
125
+
* Core server dependencies (Logger, Cache, Loop) **must** be provided explicitly to the `ServerBuilder` using `withLogger()`, `withCache()`, `withLoop()` or rely on the builder's defaults.
126
+
105
127
4. **Transport Handlers Replaced:**
106
-
* `StdioTransportHandler`, `HttpTransportHandler`, `ReactPhpHttpTransportHandler` are **removed**.
107
-
* Use `new StdioServerTransport()` or `new HttpServerTransport(...)` and pass them to `$server->listen()`.
108
-
* Constructor signatures and interaction patterns have changed.
109
-
128
+
129
+
* `StdioTransportHandler`, `HttpTransportHandler`, `ReactPhpHttpTransportHandler` are **removed**.
130
+
* Use `new StdioServerTransport()` or `new HttpServerTransport(...)` and pass them to `$server->listen()`.
131
+
* Constructor signatures and interaction patterns have changed.
132
+
110
133
5. **`Registry` Cache Methods Renamed:** `saveElementsToCache` is now `saveDiscoveredElementsToCache`, and `clearCache` is now `clearDiscoveredElements`. Their behavior is also changed to only affect discovered elements.
134
+
111
135
6. **Core Component Constructors:** The constructors for `Registry`, `Processor`, `ClientStateManager` (previously `TransportState`), `Discoverer`, `DocBlockParser` have changed. Update any direct instantiations (though typically these are managed internally).
136
+
112
137
7. **Exception Renaming:** `McpException` is now `McpServerException`. Update `catch` blocks accordingly.
138
+
113
139
8. **Default Null Logger:** Logging is effectively disabled by default. Provide a logger via `ServerBuilder->withLogger()` to enable it.
140
+
114
141
9. **Schema Generation:** Automatic string `format` inference (e.g., "date-time") removed from `SchemaGenerator`. String parameters are now plain strings in the schema unless a more advanced format definition mechanism is used in the future.
0 commit comments