-
Notifications
You must be signed in to change notification settings - Fork 13
feat: add common cache service #199
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds a common cache service at the server level to enable centralized cache configuration across all clients. The cache service can be disabled for hosted installations via the CACHE_ENABLED environment variable and supports configurable TTL through CACHE_TTL.
Key changes:
- Created a new
CacheServiceclass that wrapsNodeCachewith environment-based configuration - Updated the
Clientinterface to accept an optional cache parameter in theconfiguremethod - Migrated Bugsnag client from managing its own cache instance to using the shared cache service
Reviewed Changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/common/cache.ts | New cache service implementation with environment-based configuration |
| src/common/types.ts | Updated Client interface to accept optional cache parameter |
| src/common/server.ts | Added cache service instantiation and accessor method |
| src/common/client-registry.ts | Updated to pass cache service to client configure methods |
| src/bugsnag/client.ts | Refactored to use shared cache service instead of local instance |
| src/tests/unit/bugsnag/client.test.ts | Updated tests to pass cache parameter and verify cache integration |
| src/zephyr/client.ts | Added cache parameter to configure signature |
| src/reflect/client.ts | Added cache parameter to configure signature |
| src/qmetry/client.ts | Added cache parameter to configure signature |
| src/pactflow/client.ts | Added cache parameter to configure signature and reformatted error messages |
| src/api-hub/client.ts | Added cache parameter to configure signature |
| src/common/transport-http.ts | Fixed comment describing POST message handling |
| src/index.ts | Removed empty line |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Co-authored-by: Copilot <[email protected]>
src/common/client-registry.ts
Outdated
| } | ||
| } | ||
| if (await entry.configure(server, config)) { | ||
| if (await entry.configure(server, config, server.getCache())) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given it's in the server, shall we just let clients get the cache from there rather than pass it explicitly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah yeh that makes sense
Goal
Adds common cache service at the top level, allowing it to be configured for the whole server and used by all clients.
Design
In order to allow configuring cache service for the whole mcp server. For a hosted install this will be disabled.
Changeset
Moving cache from bugsnag client to the server level
Testing
Makes no changes to client functionality