Skip to content

@johnhenry/mcp-query-tanstack

Terminal window
npm install @johnhenry/mcp-query-tanstack

Peer-depends on @johnhenry/mcp-query and @tanstack/react-query.

mcp-query already maintains its own reactive cache. If you also use TanStack Query, you don’t want two caches disagreeing, and you don’t want TanStack refetching data the MCP client already has fresh.

This package bridges them: queryOptions and mutationOptions factories that read through to mcp-query’s cache, including protocol push and optimistic updates, without triggering extra network round-trips. TanStack becomes a view over the MCP client’s state rather than a second source of truth.

import { queryOptions, mutationOptions } from '@johnhenry/mcp-query-tanstack';

Cache keys derive from mcp-query’s own key scheme, so tag-based invalidation on the MCP side propagates into TanStack. Server-initiated listChanged notifications invalidate the right keys without a poll.

One known gap: tag-wide invalidateQueries needs a post-construction cache-listener hook that isn’t in place yet — tracked at mcp-query#24.

@johnhenry/a2a-query-tanstack is the same bridge for the A2A client, published from its own repository at johnhenry/a2a-query-tanstack.