metro-mcp-plugin-zustand
v0.1.0
Published
metro-mcp plugin for debugging Zustand stores (inspect, modify, dispatch via CDP)
Maintainers
Readme
metro-mcp-plugin-zustand
A Metro MCP plugin for inspecting and manipulating Zustand stores in your React Native app during development.
Installation
bun add -D metro-mcp-plugin-zustand
# or
npm install --save-dev metro-mcp-plugin-zustandSetup
1. Register the plugin
Add the plugin to your metro-mcp.config.ts:
import { defineConfig } from 'metro-mcp';
export default defineConfig({
plugins: ['metro-mcp-plugin-zustand'],
});2. Initialize in your app
Call initializeZustandMetroMcp() in your app entry point, passing a map of store names to store objects. Wrap it in a __DEV__ guard so it's never included in production builds.
import { initializeZustandMetroMcp } from 'metro-mcp-plugin-zustand';
import { useBearStore } from './stores/bearStore';
import { useUserStore } from './stores/userStore';
if (__DEV__) {
initializeZustandMetroMcp({
bears: useBearStore,
user: useUserStore,
});
}Note: Pass the store object itself (returned by
create()orcreateStore()), not the hook — e.g.useBearStorewhereconst useBearStore = create(...).
Tools
Once running, the following MCP tools are available:
zustand_list_stores
Lists all store names registered with initializeZustandMetroMcp().
zustand_get_state
Returns the current state of a store as a JSON-serializable object. Functions in state are represented as "[Function]", Sets and Maps are converted to plain objects.
| Parameter | Type | Description |
|-----------|------|-------------|
| storeName | string | Name of the store to inspect |
zustand_set_state
Updates a store's state. By default the provided object is merged (shallow) with the existing state. Set replace: true to fully replace the state instead.
| Parameter | Type | Default | Description |
|-----------|------|---------|-------------|
| storeName | string | — | Name of the store to update |
| state | object | — | State to apply |
| replace | boolean | false | If true, replaces the entire state instead of merging |
Note: Only JSON-serializable values can be set via this tool. Functions and other non-serializable values in your store will not be affected.
zustand_reset_state
Resets a store to the state it had when initializeZustandMetroMcp() was called. For Zustand v4+ stores this uses getInitialState(); for older stores it falls back to the state captured at initialization time.
| Parameter | Type | Description |
|-----------|------|-------------|
| storeName | string | Name of the store to reset |
License
MIT
