Skip to content

Commit 82ea3c2

Browse files
committed
refactor: update method names in ServerBuilder for consistency
- Change withCache() to setCache() in ServerBuilder - Update example and documentation to reflect method name changes - Ensure consistency across caching implementation in examples and documentation
1 parent edf57da commit 82ea3c2

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

docs/discovery-caching.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ use Symfony\Component\Cache\Adapter\ArrayAdapter;
2020
use Symfony\Component\Cache\Psr16Cache;
2121

2222
$server = Server::make()
23-
->withServerInfo('My Server', '1.0.0')
24-
->withDiscovery(__DIR__, ['.'])
25-
->withCache(new Psr16Cache(new ArrayAdapter())) // Enable caching
23+
->setServerInfo('My Server', '1.0.0')
24+
->setDiscovery(__DIR__, ['.'])
25+
->setCache(new Psr16Cache(new ArrayAdapter())) // Enable caching
2626
->build();
2727
```
2828

@@ -69,8 +69,8 @@ $cache = DoctrineProvider::wrap(new ArrayCache());
6969
$cache = new Psr16Cache(new ArrayAdapter());
7070

7171
$server = Server::make()
72-
->withDiscovery(__DIR__, ['.'])
73-
->withCache($cache)
72+
->setDiscovery(__DIR__, ['.'])
73+
->setCache($cache)
7474
->build();
7575
```
7676

@@ -81,8 +81,8 @@ $server = Server::make()
8181
$cache = new Psr16Cache(new FilesystemAdapter('mcp-discovery', 0, '/var/cache'));
8282

8383
$server = Server::make()
84-
->withDiscovery(__DIR__, ['.'])
85-
->withCache($cache)
84+
->setDiscovery(__DIR__, ['.'])
85+
->setCache($cache)
8686
->build();
8787
```
8888

examples/10-cached-discovery-stdio/server.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,6 @@
2323
->setServerInfo('Cached Discovery Calculator', '1.0.0', 'Calculator with cached discovery for better performance.')
2424
->setDiscovery(__DIR__, ['.'])
2525
->setLogger(logger())
26-
->withCache(new Psr16Cache(new ArrayAdapter()))
26+
->setCache(new Psr16Cache(new ArrayAdapter()))
2727
->build()
2828
->connect(new StdioTransport());

src/Server/ServerBuilder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ public function setDiscovery(
209209
/**
210210
* Enables discovery caching with the provided cache implementation.
211211
*/
212-
public function withCache(CacheInterface $cache): self
212+
public function setCache(CacheInterface $cache): self
213213
{
214214
$this->cache = $cache;
215215

0 commit comments

Comments
 (0)