Skip to content

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

typescript
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?

ts
readonly optional defaults: {
  cacheControl?: CacheDirective;
};

Defined in: packages/core/src/state-sync/types.ts:108

Defaults applied when no policy matches a tool.

cacheControl?

ts
readonly optional cacheControl: CacheDirective;

notificationSink()?

ts
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

ParameterType
notificationResourceNotification

Returns

void | Promise<void>

Example

typescript
stateSync: {
    policies: [...],
    notificationSink: async (notification) => {
        await server.sendNotification(notification);
    },
}

onInvalidation()?

ts
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

ParameterType
eventInvalidationEvent

Returns

void

Example

typescript
stateSync: {
    policies: [...],
    onInvalidation: (event) => {
        console.log(`[StateSync] ${event.causedBy} invalidated ${event.patterns.join(', ')}`);
        metrics.increment('statesync.invalidation', { tool: event.causedBy });
    },
}

policies

ts
readonly policies: readonly SyncPolicy[];

Defined in: packages/core/src/state-sync/types.ts:105

Policy rules, evaluated in declaration order (first match wins).