Interface: StateSyncConfig
Defined in: packages/core/src/state-sync/types.ts:103
State Sync configuration.
Policies are evaluated in declaration order (first match wins). Defaults apply when no policy matches a tool.
Example
const stateSync: StateSyncConfig = {
defaults: { cacheControl: 'no-store' },
policies: [
{ match: 'sprints.update', invalidates: ['sprints.*'] },
{ match: 'tasks.update', invalidates: ['tasks.*', 'sprints.*'] },
{ match: 'countries.*', cacheControl: 'immutable' },
],
};
registry.attachToServer(server, { stateSync });Properties
defaults?
readonly optional defaults: {
cacheControl?: CacheDirective;
};Defined in: packages/core/src/state-sync/types.ts:108
Defaults applied when no policy matches a tool.
cacheControl?
readonly optional cacheControl: CacheDirective;notificationSink()?
readonly optional notificationSink: (notification) => void | Promise<void>;Defined in: packages/core/src/state-sync/types.ts:148
Protocol-level notification sink for MCP resource change events.
When provided, causal invalidation also emits notifications/resources/updated MCP protocol messages in addition to the in-band XML signal.
Parameters
| Parameter | Type |
|---|---|
notification | ResourceNotification |
Returns
void | Promise<void>
Example
stateSync: {
policies: [...],
notificationSink: async (notification) => {
await server.sendNotification(notification);
},
}onInvalidation()?
readonly optional onInvalidation: (event) => void;Defined in: packages/core/src/state-sync/types.ts:129
Observability hook invoked after each causal invalidation event.
Use this to log, trace, or count invalidation events without coupling the state-sync engine to a specific observability backend.
Parameters
| Parameter | Type |
|---|---|
event | InvalidationEvent |
Returns
void
Example
stateSync: {
policies: [...],
onInvalidation: (event) => {
console.log(`[StateSync] ${event.causedBy} invalidated ${event.patterns.join(', ')}`);
metrics.increment('statesync.invalidation', { tool: event.causedBy });
},
}policies
readonly policies: readonly SyncPolicy[];Defined in: packages/core/src/state-sync/types.ts:105
Policy rules, evaluated in declaration order (first match wins).