Skip to content

Remove MCP client tool-list caching layer#235

Merged
pushpak1300 merged 2 commits into
mainfrom
remove-client-tool-list-cache
Jun 3, 2026
Merged

Remove MCP client tool-list caching layer#235
pushpak1300 merged 2 commits into
mainfrom
remove-client-tool-list-cache

Conversation

@pushpak1300

@pushpak1300 pushpak1300 commented Jun 3, 2026

Copy link
Copy Markdown
Member

The MCP client shipped a built-in tool-list cache. It fought the package's thin, app-owns-storage philosophy and added a per-user cache-scoping footgun. It also kept getting more awkward as the OAuth work landed: the API for configuring it grew weirder the more cases it tried to cover. In practice most apps don't need to cache the tools list at all, and the ones that do already have a cache they trust. So this hands caching back to the application. The package just gives you a correct tools list, and you store it however you like.

Before, you configured caching through the package:

Mcp::registerClient('github', fn () => Client::web($url), cacheTtl: 3600, scope: fn () => auth()->id());
$tools = Mcp::client('github')->tools();   // RegisteredClient wrapper, cached for you
Mcp::client('github')->flushCache();

After, registration is just a name and a factory, and the tools list is a plain value you can cache directly:

Mcp::registerClient('github', fn () => Client::web($url));

// no cache: just fetch
$tools = Mcp::client('github')->tools();

// app-owned cache: the tools list is plain data, so cache it as-is under your own key
$tools = Cache::remember('mcp:github:tools', 3600, fn () => Mcp::client('github')->tools());

@pushpak1300 pushpak1300 force-pushed the remove-client-tool-list-cache branch from 095027c to 2a9a56f Compare June 3, 2026 09:47
@pushpak1300 pushpak1300 marked this pull request as ready for review June 3, 2026 09:52
@pushpak1300 pushpak1300 requested a review from WendellAdriel June 3, 2026 09:55
Comment thread src/Client/Primitives/Tool.php

@WendellAdriel WendellAdriel left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🔥

@pushpak1300 pushpak1300 merged commit 34f6bc5 into main Jun 3, 2026
25 checks passed
@pushpak1300 pushpak1300 deleted the remove-client-tool-list-cache branch June 3, 2026 12:18
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.

2 participants