Skip to content

State Store

Use this page when an external process needs to read the optional ./.mdp/store directory written by --state-store or --state-store-dir.

Scope

The state store is a node-local diagnostic snapshot.

  • It is not a replication channel between MDP servers.
  • It does not restore client sessions after restart.
  • It is a replace-by-snapshot interface, not an append-only event log.

Directory Lifecycle

When enabled, the server creates the store directory on startup and writes four JSON files:

  • snapshot.json
  • clients.json
  • routes.json
  • services.json

Each file is rewritten as a complete JSON document whenever the relevant node-local state changes.

Consumer Guidance

  • Prefer snapshot.json when you need one coherent read of server metadata, services, clients, and routes together.
  • Use clients.json, routes.json, or services.json only when you intentionally want a narrower view.
  • Re-open and re-read files on each observation. The server replaces files with fresh snapshots instead of mutating them in place.
  • If you need change notifications, watch the store directory or poll snapshot.json.updatedAt. Do not depend on a long-lived file descriptor staying current.
  • Ignore unknown fields. This is an MVP diagnostic contract and future versions may add new fields.

Shared Conventions

  • All timestamps are ISO 8601 UTC strings produced by Date.prototype.toISOString().
  • Every JSON file contains one complete object or array. There are no partial-line or append semantics.
  • snapshot.json is the canonical aggregate view. The split files are convenience projections and are not written as one cross-file transaction.

snapshot.json

Type:

ts
interface MdpFilesystemStateSnapshot {
  scope: 'node-local'
  updatedAt: string
  server: {
    serverId: string
    clusterId: string
    clusterMode: 'standalone' | 'auto' | 'proxy-required'
    cwd: string
    storeDir: string
    pid: number
    startedAt: string
  }
  services: MdpFilesystemStateServicesSnapshot
  clients: ListedClient[]
  routes: IndexedPathDescriptor[]
}

Field meanings:

FieldMeaning
scopeAlways node-local. The snapshot only describes the current server process view.
updatedAtTime when this aggregate snapshot was written.
server.serverIdCurrent node identity exposed by /mdp/meta.
server.clusterIdLogical cluster identity configured for this node.
server.clusterModeStartup mode: standalone, auto, or proxy-required.
server.cwdStartup working directory used to resolve relative paths.
server.storeDirAbsolute store directory path for this node.
server.pidCurrent server process id.
server.startedAtTime when this state store instance started.
servicesSame payload as services.json.
clientsSame payload as clients.json.
routesSame payload as routes.json.

clients.json

Type:

ts
interface ClientConnectionDescriptor {
  mode: 'ws' | 'http-loop'
  secure: boolean
  authSource: 'none' | 'message' | 'transport' | 'transport+message'
}

type PathDescriptor =
  | EndpointPathDescriptor
  | SkillPathDescriptor
  | PromptPathDescriptor

interface ListedClient {
  id: string
  name: string
  description?: string
  version?: string
  platform?: string
  metadata?: JsonObject
  paths: PathDescriptor[]
  status: 'online'
  connectedAt: string
  lastSeenAt: string
  connection: ClientConnectionDescriptor
}

This file is the current listClients view for the local node.

Important fields:

FieldMeaning
id / nameClient identity as registered with the server.
description / version / platform / metadataOptional descriptor metadata supplied by the client.
pathsFull registered catalog for that client.
statusCurrently always online for listed entries.
connectedAtTime when this transport session was created.
lastSeenAtLast client activity time seen by this node.
connection.modews or http-loop.
connection.secureWhether the transport is currently over a secure channel.
connection.authSourceWhere the active auth context came from.

Path descriptor variants:

VariantRequired fieldsOptional fields
endpointtype, path, methoddescription, inputSchema, outputSchema, contentType
prompttype, pathdescription, inputSchema, outputSchema
skilltype, pathdescription, contentType

For the matching bridge-tool contract, see listClients.

routes.json

Type:

ts
type IndexedPathDescriptor = PathDescriptor & {
  clientId: string
  clientName: string
}

This file is the current indexed route table for the local node. It is equivalent to the local listPaths view with full depth.

Additional fields beyond PathDescriptor:

FieldMeaning
clientIdClient id that currently owns this descriptor.
clientNameHuman-readable client name for the same descriptor.

For the matching bridge-tool contract, see listPaths.

services.json

Type:

ts
interface MdpFilesystemStateServicesSnapshot {
  transport: {
    status: 'starting' | 'listening' | 'stopped'
    endpoints?: {
      ws: string
      httpLoop: string
      auth: string
      meta: string
      cluster: string
    }
  }
  mcpBridge: {
    status: 'starting' | 'connected' | 'stopped'
  }
  cluster: {
    status: 'disabled' | 'starting' | 'running' | 'stopped'
    state?: ClusterManagerState
  }
  upstreamProxy: {
    status: 'inactive' | 'connecting' | 'following' | 'stopped'
    leaderId?: string
    leaderUrl?: string
    term?: number
  }
}

services.json is the narrow service-status view for external supervision.

transport

FieldMeaning
statusstarting before bind, listening after bind, stopped after shutdown.
endpoints.wsWebSocket endpoint for MDP clients.
endpoints.httpLoopHTTP loop connect base path.
endpoints.authAuth bootstrap endpoint.
endpoints.metaMetadata probe endpoint.
endpoints.clusterCluster control WebSocket endpoint.

mcpBridge

FieldMeaning
statusstarting before MCP bridge connect, connected after connect, stopped after shutdown.

cluster

FieldMeaning
statusdisabled in standalone mode, starting before cluster startup settles, running while active, stopped after shutdown.
stateCurrent node-local cluster state when clustering is active.

cluster.state has the same shape as the cluster block returned by GET /mdp/meta:

ts
interface ClusterManagerState {
  id: string
  membershipMode: 'dynamic' | 'static'
  membershipFingerprint: string
  role: 'leader' | 'follower' | 'candidate'
  term: number
  leaderId?: string
  leaderUrl?: string
  leaseDurationMs: number
  knownMemberCount: number
  reachableMemberCount: number
  quorumSize: number
  hasQuorum: boolean
}

upstreamProxy

FieldMeaning
statusinactive, connecting, following, or stopped.
leaderIdCurrent upstream leader id when known.
leaderUrlCurrent upstream leader websocket URL when known.
termCluster term associated with the upstream leader view.
NeedRead this
One coherent snapshot for dashboards or sidecarssnapshot.json
Registered clients onlyclients.json
Flattened route inventoryroutes.json
Transport / bridge / cluster / upstream healthservices.json

Non-Goals

  • No incremental diff stream
  • No historical retention
  • No cluster-wide merged registry
  • No restart recovery

Model Drive Protocol