Skip to content

Conversation

@xentixar
Copy link
Contributor

This PR implements the API improvement suggested by CodeWithKyrian in PR #39.

Changes

  • Integrate cache into setDiscovery(): Add cache as 4th parameter to setDiscovery() method
  • Rename property: Change cache to discoveryCache for clarity
  • Remove separate method: Remove the standalone setCache() method
  • Update example: Update the cached discovery example to use the new API

Benefits

  • Cleaner API: Cache is now clearly associated with discovery operations
  • More intuitive: Users don't need to call two separate methods
  • Self-documenting: The API makes it obvious that the cache is for discovery

Before

Server::make()
    ->setDiscovery(__DIR__, ['.'])
    ->setCache(new Psr16Cache(new ArrayAdapter()))
    ->build();

After

Server::make()
    ->setDiscovery(__DIR__, ['.'], [], new Psr16Cache(new ArrayAdapter()))
    ->build();

This addresses the feedback from the original discovery caching PR to make the API more ergonomic and intuitive.

- Add cache as 4th parameter to setDiscovery()
- Rename $cache to $discoveryCache for clarity
- Remove separate setCache() method
- Update example to use new API
- Update examples to use cache parameter in setDiscovery() method
- Remove references to separate setCache() method calls
@chr-hertel chr-hertel merged commit 7d599f4 into modelcontextprotocol:main Sep 25, 2025
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants