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
{{ message }}
Repository navigation
Commit 9a7fea0
Browse filesBrowse the repository at this point in the historyBrowse files
[Server] Add Psr6SessionStore and Psr6NotificationBus (#635)
They work like their PSR-16 siblings over a PSR-6 cache pool. `Builder::setDiscovery()` also accepts a PSR-6 pool.
The sequence counter of `Psr16NotificationBus` no longer expires, so that its subscribers do not miss the notifications published after a quiet period.
Both notification buses read their backlog with one `getMultiple()` or `getItems()` call, not one call per entry.
Copy file name to clipboardExpand all lines: CHANGELOG.md
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,6 +10,8 @@ All notable changes to `mcp/sdk` will be documented in this file.
10
10
*[BC Break]`DocBlockParser::parseDocBlock()` no longer accepts `null`; pass `ReflectionMethod::getDocComment()` as is
11
11
* Fix tools with an array shape parameter whose keys are nullable or unions (e.g. `array{name: string, nickname: string|null}`) rejecting valid arguments with `-32602`: a `null` inside the shape no longer turns the parameter into `array|null`, and such keys get their own types instead of `object`, including lists and nested shapes (`string[]|null`, `array{x: int}|null`).
12
12
* Fix `array<string|null>` and other generics with a union element getting `items` of type `object`. A `null` inside a generic no longer makes the parameter nullable, and neither does a DocBlock class whose name contains `null`.
13
+
* Fix `Psr16NotificationBus` subscribers missing the notifications published after the bus stayed quiet for longer than its TTL: the sequence counter no longer expires, and a subscriber whose cursor is ahead of a lost counter reads what the bus holds.
14
+
* Add `Psr6SessionStore` and `Psr6NotificationBus`, which work like `Psr16SessionStore` and `Psr16NotificationBus` over a PSR-6 cache pool. `Builder::setDiscovery()` also accepts a PSR-6 pool as `$cache`.
| store sessions, cache discovery or share notifications through a PSR-16 cache |`psr/simple-cache` implementation, e.g. `symfony/cache`|
30
+
| store sessions, cache discovery or share notifications through a PSR-6 or PSR-16 cache |`psr/cache` or`psr/simple-cache` implementation, e.g. `symfony/cache`|
31
31
|[fetch JWT keys from an issuer](../run/authorization.md) with `JwtTokenValidator::fromIssuer()`|`psr/cache` (PSR-6) implementation, e.g. `symfony/cache`|
32
32
33
33
PSR-17 and PSR-18 implementations are found through
Copy file name to clipboardExpand all lines: docs/run/server-builder.md
+3-5Lines changed: 3 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -168,7 +168,7 @@ See [First server](../get-started/first-server.md) for the install command.
168
168
-`$basePath` (string): Base directory for discovery (typically `__DIR__`)
169
169
-`$scanDirs` (array): Directories to recursively scan for `#[McpTool]`, `#[McpResource]`, etc. All subdirectories are included. (default: `['.', 'src']`)
170
170
-`$excludeDirs` (array): Directory names to exclude **within** the scanned directories during recursive scanning
171
-
-`$cache` (CacheInterface|null): Optional PSR-16 cache to store discovered elements for performance
171
+
-`$cache` (CacheInterface|CacheItemPoolInterface|null): Optional PSR-16 cache or PSR-6 pool to store discovered elements for performance
172
172
-`$namePatterns` (array): Optional list of patterns (regexp, glob, or string) for file names (default: `['*.php']`)
173
173
174
174
**Basic Discovery (scans current directory and `src/`):**
@@ -187,10 +187,9 @@ $server = Server::builder()
187
187
```php
188
188
use Mcp\Server;
189
189
use Symfony\Component\Cache\Adapter\FilesystemAdapter;
190
-
use Symfony\Component\Cache\Psr16Cache;
191
190
192
191
// Cache discovered elements to avoid filesystem scanning on every server start
193
-
$cache = new Psr16Cache(new FilesystemAdapter('mcp-discovery'));
192
+
$cache = new FilesystemAdapter('mcp-discovery');
194
193
195
194
$server = Server::builder()
196
195
->setDiscovery(
@@ -274,15 +273,14 @@ use Mcp\Server;
274
273
use Mcp\Server\Session\FileSessionStore;
275
274
use Mcp\Capability\Registry\Container;
276
275
use Symfony\Component\Cache\Adapter\FilesystemAdapter;
0 commit comments