Skip to main content
Glama
pandaGaume

mcp-history

by pandaGaume

mcp-history

History slots for an mcp-broker: one contract, history.v1, for recording and reading back SCADA values, addressed by UNS id, with pluggable stores.

MCP client ──> mcp-broker ──> slot "history" (HistoryBehavior)
                                  │  one broker decision per UNS id, audited
                                  └──> IHistoryStore: memory today; SQLite, DuckDB, MySQL next

The contract has two forms that say the same thing:

  • IHistoryStore, the TypeScript interface a backend implements;

  • the history.* MCP tools, which HistoryBehavior derives from any implementation.

HistorySlotStore reaches a slot back as an IHistoryStore, and the conformance suite runs unchanged on both forms.

Design and decisions: docs/brief_history_slot.md (French).

Use

import { DirectTransport } from "@cyanmycelium/mcp-broker-provider";
import { McpServerBuilder } from "@cyanmycelium/mcp-core";
import { HistoryBehavior, MemoryHistoryStore, buildHistoryDeclaration } from "@cyanmycelium/mcp-history";
import { BrokerAccessGuard } from "@cyanmycelium/mcp-uns";

const transport = new DirectTransport("ws://localhost:3000/provider/history", { secret });
const server = new McpServerBuilder()
    .withName("history")
    .withTransport(transport)
    .register(new HistoryBehavior(new MemoryHistoryStore(), new BrokerAccessGuard(transport.broker)))
    .build();
await server.start();
await transport.broker.declare(buildHistoryDeclaration({ version: "1", namespace: "uns://site1" }));

UNS ids and broker-decided access come from mcp-uns. new HistoryBehavior(store, guard, { payload: "structured" }) sends each result once, as structuredContent: with format: "columns", reads are 4 to 7 times smaller. On a bench without broker policy, pass its openGuard() instead of BrokerAccessGuard: everything is allowed and nothing is audited.

Related MCP server: witness

Tools

tool

broker capability, checked per id

history.capabilities

none

history.browse

history.read (ids you may not read are left out)

history.read_raw, history.read_processed, history.read_at_time

history.read (format: "columns" on the first two: parallel arrays, epoch ms)

history.append

history.record, outcome reported

history.delete_range

history.admin, outcome reported

Packages

package

what

@cyanmycelium/mcp-history

the contract, MemoryHistoryStore, HistoryBehavior, HistorySlotStore, the declaration, and the conformance suite under /conformance

@cyanmycelium/mcp-history-sqlite

SqliteHistoryStore: one local file, aggregated in SQL

Writing a store

Implement IHistoryStore, then prove it:

import { describeHistoryStoreConformance } from "@cyanmycelium/mcp-history/conformance";

describeHistoryStoreConformance("SqliteHistoryStore", () => new SqliteHistoryStore({ path: ":memory:" }));

The suite pins the shared semantics: time axis, idempotent append, [start, end) ranges, paging, every aggregate, at-time reads, browse by whole UNS segments, delete, request validation. computeBuckets and valueAtTime in the contract are the reference implementations; a backend that computes natively must give the same results.

Develop

npm install
npm run typecheck
npm test
npm run build

Tests run against the sources. tests/broker.test.ts starts a real broker with @cyanmycelium/mcp-broker/testing; it needs no network beyond 127.0.0.1.

License

Apache-2.0.

Related MCP Connectors

Related MCP Servers

  • A
    license
    Not graded
    quality
    D
    maintenance
    MCP server for temporal state queries and cryptographic audit trails. Query historical entity state at any point in time, generate Merkle proofs of past state, and anchor contract snapshots for immutable provenance.
    MIT
  • A
    license
    Not graded
    quality
    A
    maintenance
    Enables agents to query a dated, provenance-backed history distilled from any text stream, turning raw records into observations, bi-temporal facets, and narratives over MCP.
    10
    MIT
  • A
    license
    Not graded
    quality
    B
    maintenance
    Enables AI agents to store, search, and resolve shared memories with full provenance, conflict detection, and an audit trail across MCP-compatible clients.
    MIT