Skip to content

feat(magento): add 30-minute in-memory cache for GET requests#519

Open
JonasJesus42 wants to merge 3 commits into
mainfrom
magento-mcp-cache
Open

feat(magento): add 30-minute in-memory cache for GET requests#519
JonasJesus42 wants to merge 3 commits into
mainfrom
magento-mcp-cache

Conversation

@JonasJesus42

@JonasJesus42 JonasJesus42 commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Adds a simple TTL-based in-memory cache (server/lib/cache.ts) for Magento API responses.
  • All magentoFetch GET calls are cached for 30 minutes per store; non-GET requests bypass the cache entirely.
  • Cache key is baseUrl|storeCode|url to ensure isolation between different stores running in the same process.
  • DEBUG=true logs HIT/MISS to console for easy diagnosis.

🤖 Generated with Claude Code


Summary by cubic

Add a 30‑minute in-memory cache for Magento GET requests and switch auth to use the connection’s token (MESH_REQUEST_CONTEXT.token) instead of an apiToken state field. This cuts API calls and simplifies setup per store.

  • New Features

    • Cache all magentoFetch GET requests for 30 minutes per store using key baseUrl|storeCode|url; non‑GET requests bypass cache.
    • DEBUG=true logs cache HIT/MISS.
    • Credentials now read from MESH_REQUEST_CONTEXT.token (raw token; we add the Bearer prefix); MAGENTO_API_TOKEN remains a fallback.
  • Migration

    • Remove apiToken from any stored state; it’s no longer in the config form or state schema.
    • Set the Magento integration token in the connection’s Token field (do not include "Bearer") or define MAGENTO_API_TOKEN in env.
    • Ensure baseUrl is provided (still required).

Written for commit 5a5e6d9. Summary will update on new commits.

Review in cubic

JonasJesus42 and others added 3 commits July 13, 2026 10:23
…rm field

Removes apiToken from the configSchema form and StateSchema — users now
set their Magento integration token in the encrypted Token field of the
HTTP connection. resolveCredentials reads MESH_REQUEST_CONTEXT.authorization
(strips Bearer prefix) with MAGENTO_API_TOKEN env var as a local fallback.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
All magentoFetch GET calls are now cached for 30 minutes per store URL +
path combination. Non-GET requests bypass the cache. Cache key is
baseUrl|storeCode|url to ensure per-store isolation.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The runtime exposes MESH_REQUEST_CONTEXT as RequestContext<TSchema, BindingRegistry>
which has a raw `token` field (no Bearer prefix) instead of `authorization`.
Update MeshRequestContext interface and resolveCredentials to use `token` directly.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.

1 participant