@frontmcp/react/state bridges your application state with MCP. State slices become MCP resources that agents can read, and actions become MCP tools that agents can call.
useStoreResource
The generic hook that works with any state management library.useReduxResource and useValtioResource are thin wrappers around it.
What Gets Registered
Options
Options may be written inline, as above: a new
getState, selectors or actions object on every render does not register anything again — resources and tools are registered again only when name, server, or the set of selector / action names (not their order) changes, and each read or action call uses the functions of the latest render. A new subscribe function re-subscribes to the store, which re-renders nothing. The same holds for useReduxResource and useValtioResource, so any of them can sit in a component that also reads the server (useListTools(), say) without rendering it in a loop.
Live Updates
When the store changes, the main resource’s read function automatically returns fresh state. The hook subscribes to your store and notifies theDynamicRegistry on every change so consumers re-read the latest value.
useReduxResource
A thin wrapper for Redux stores. Automatically bindsgetState, subscribe, and wraps action creators to auto-dispatch.
Options
useValtioResource
A thin wrapper for Valtio proxies. Supports deep path selectors with dot notation.Options
You must pass valtio’s
subscribe function yourself since valtio is an optional peer dependency. Import it from valtio/utils.Provider-Level Store Adapters
Instead of using hooks inside components, you can register stores directly on theFrontMcpProvider via the stores prop. This is useful when you want store registration to happen once at the top level.
reduxStore
Adapter factory for Redux stores. Wraps action creators to auto-dispatch.valtioStore
Adapter factory for Valtio proxies. Supports deep path selectors.createStore
Generic pass-through adapter for any custom store.StoreAdapter Interface
All adapter factories return aStoreAdapter:
StoreAdapter directly without using a factory.