statescope
v0.2.0
Published
App-side SDK: register your Zustand stores & TanStack QueryClient and expose their live state to AI agents over statescope-mcp (dev-only).
Maintainers
Readme
statescope
App-side SDK for statescope-mcp — expose your running app's state stores (Zustand, Redux, XState, …) and TanStack Query cache to AI coding agents over MCP, so they read exact runtime state instead of guessing it from code. Dev-only.
pnpm add -D statescopeimport {
registerZustandStore,
registerTanStackQueryClient,
startDevBridge,
} from "statescope";
registerZustandStore("cart", useCartStore);
registerTanStackQueryClient("queryClient", queryClient);
startDevBridge();Other state libraries are thin adapters over the same serializer:
import { registerReduxStore, registerXStateActor, registerStateSource } from "statescope";
registerReduxStore("redux", store); // store.getState()
registerXStateActor("machine", actor); // actor.getSnapshot()
registerStateSource("ui", { type: "valtio", read: () => snapshot(uiProxy) }); // anything elseGuard it so it tree-shakes out of production (Vite):
if (import.meta.env.DEV) void import("./statescope-setup");- Dev-only: no-ops in production builds;
startDevBridge()throws if reached in prod. - Shape-preserving redaction: secrets are hidden but their type/length/presence survive, and never leave the browser.
- Serialization of functions,
Date,Map/Set,RegExp,BigInt,Error, and cycles, with depth/size/count caps.
Pair with statescope-mcp. Full docs in the repo README. Reads need no token; writes (patch_state / restore_snapshot, Zustand) are token-gated.
License
MIT
