Repository avatar
AI Tools
v1.0.0
active

branching-story-mcp

io.github.ouba-studio/branching-story-mcp

Deterministic story-state kernel plus the 2026 AI story continuity benchmark, for MCP clients.

Documentation

branching-story-mcp

A zero-dependency Model Context Protocol server that gives AI agents a deterministic story-state kernel and the verified 2026 Consumer AI Story Continuity Benchmark.

branching-story-mcp exposes Ouba Studio's branching-story-kit story-state kernel and the CC-BY-4.0 2026 Consumer AI Story Continuity Benchmark directly to Claude Desktop, Claude Code, Cursor, Windsurf, Cline, Zed, VS Code, ChatGPT and every other MCP client. Four tools, two resources, zero runtime dependencies — pure Python stdlib (>=3.10) and pure Node ESM (>=18), behaviour-identical down to the trace hash.

uvx branching-story-mcp        # PyPI · no install step, no dependency bloat
npx @ouba-studio/branching-story-mcp   # npm · zero dependencies
deno run -A jsr.io/@ouba-studio/branching-story-mcp/server   # JSR

License: MIT Python Node MCP Dataset branching-story-mcp MCP server


Why this exists

In the 2026 AI Story Apps Benchmark (evaluation date 2026-11-15), a trivial fact planted at turn 2 — "My cat's name is Marmalade." — was silently lost by turn 15 by a major product that stayed perfectly fluent, on-persona and fast the whole time. Four products were right-censored by signup or trial walls before the probe could even be administered.

branching-story-mcp is the deterministic answer: explicit state, one write path, and a memory log you can verify with a hash. An agent that steps a story through this server cannot drift — any divergence between the returned trace_hash and a locally recomputed hash is proof that state was mutated outside the reducer.

The benchmark matrix ships inside the server, so an agent can cite the evidence while it builds the story. Both are first-class MCP objects: tools for the kernel, a resource for the data.


Install

Claude Desktop / Claude Code

{
  "mcpServers": {
    "branching-story-mcp": {
      "command": "uvx",
      "args": ["branching-story-mcp"]
    }
  }
}

Or, if you prefer the Node build:

{
  "mcpServers": {
    "branching-story-mcp": {
      "command": "npx",
      "args": ["-y", "@ouba-studio/branching-story-mcp"]
    }
  }
}

Cursor (.cursor/mcp.json)

{
  "mcpServers": {
    "branching-story-mcp": {
      "command": "uvx",
      "args": ["branching-story-mcp"]
    }
  }
}

Windsurf (~/.codeium/windsurf/mcp_config.json)

{
  "mcpServers": {
    "branching-story-mcp": {
      "command": "uvx",
      "args": ["branching-story-mcp"]
    }
  }
}

Cline / VS Code (.vscode/mcp.json)

{
  "servers": {
    "branching-story-mcp": {
      "type": "stdio",
      "command": "uvx",
      "args": ["branching-story-mcp"]
    }
  }
}

ChatGPT / remote MCP clients

The server is stdio-only and needs no credentials, no network access and no environment variables. Put it behind any stdio-to-HTTP bridge (MCP Inspector, supergateway, or a three-line proxy) and register the resulting Streamable HTTP endpoint with your client. It is read-only: every tool is readOnlyHint: true, destructiveHint: false.

Verify it in ten seconds

printf '%s\n' \
  '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-03-26","capabilities":{},"clientInfo":{"name":"smoke","version":"0"}}}' \
  '{"jsonrpc":"2.0","method":"notifications/initialized"}' \
  '{"jsonrpc":"2.0","id":2,"method":"tools/list"}' \
  | uvx branching-story-mcp

Protocol compliance

JSON-RPC 2.0 over stdio, one JSON message per line, newline-delimited. Nothing is ever written to stdout except responses.

MethodBehaviour
initializeReturns protocolVersion (echoes 2024-11-05 or 2025-03-26), capabilities, serverInfo, instructions
notifications/initializedNotification — no response
ping{}
tools/list4 tools with JSON Schema inputSchema, outputSchema and annotations
tools/call{content:[{type:"text"}], structuredContent, isError}
resources/list2 resources with URI, name, title, description, mimeType
resources/read{contents:[{uri, mimeType, text}]}
resources/templates/list{resourceTemplates: []}
prompts/list{prompts: []} (no prompt capability advertised)
logging/setLevel{}
anything else-32601 Method not found

Unknown tools and malformed arguments return -32602; semantic failures (a broken story graph) return isError: true with a structured payload so the agent can repair its input.


Tools

1. validate_story_graph

Validate a branching-story-kit scene graph before an agent writes a single line of prose.

Input

{
  "story": {
    "id": "midnight-bookshop",
    "startScene": "arrival",
    "initialState": { "spark": 1, "trust": 1, "item": "cardamom tea" },
    "scenes": {
      "arrival": {
        "title": "Rain on Bellweather Lane",
        "body": "Julian slides a warm mug of {{item}} across the counter.",
        "choices": [
          { "label": "Hold his gaze", "next": "stacks", "effects": { "spark": 2 } },
          { "label": "Ask about the folio", "next": "folio", "requires": { "trust": 3 } }
        ]
      },
      "stacks": { "title": "Between the Stacks", "body": "…", "ending": true }
    }
  }
}

start is accepted as a legacy alias for startScene. scenes, startScene and initialState may also be passed as top-level arguments instead of a story object.

Output — valid, error_count, warning_count, errors[], warnings[], issues{}, stats{}.

Issue codeSeverityMeaning
SCHEMA_MISSING_SCENES, SCHEMA_MISSING_START, SCHEMA_START_NOT_FOUNDerrorgraph is not runnable
MISSING_TARGETerrora choice links to a scene that does not exist
INVALID_GUARDerrorrequires is not an object of numbers
SCHEMA_INVALID_SCENE, SCENE_INVALID_CHOICES, SCHEMA_CHOICE_NO_TARGET, SCHEMA_INVALID_EFFECTS, SCENE_INVALID_ENDINGerrormalformed scene or choice
UNREACHABLE_SCENEwarningscene cannot be reached from startScene
DEAD_ENDwarningnon-ending scene with no choices
LOOP_TRAPwarningreachable cycle with no exit to an ending
INVALID_GUARD_UNKNOWN_KEYwarningguard reads a state key nothing declares or writes
SCENE_MISSING_TITLE, SCENE_MISSING_BODYwarningincomplete authoring

2. step_story_state

Run the deterministic reducer for one or more player choices.

Input

{
  "story": { "…": "as above" },
  "choices": [0, "Open the folio"],
  "state": { "trust": 2 },
  "remember": ["My cat's name is Marmalade."]
}

choices entries may be integer indexes, case-insensitive labels, or {index} / {label} objects. state overrides initialState; memory seeds a prior memory log.

Output — final_scene, final_state, turns, history[], steps[] (each with guards_evaluated, fired_guards, unmet_guards, effects_applied, state, memory), available_choices[] for the scene the reader landed on, stopped_reason, and trace_hash + verification{}.

Effects. Scalar numbers add (relationship meters are cumulative); strings, booleans, arrays and nulls assign; explicit operators give full control:

{
  "effects": {
    "trust": 2,
    "item": "amber ledger",
    "clues": { "op": "append", "value": "folio mentioned at the counter" },
    "curse": { "op": "delete" }
  }
}

Guards. A choice is visible only when every requires key is at least its minimum:

{ "requires": { "trust": 3 } }

Unmet choices are filtered out of available_choices (never rendered as a greyed-out option — that would leak the existence of the state variable), and a step that requests one is recorded with status: "guard_blocked" and leaves state untouched.

Determinism. trace_hash is sha256(canonical_json(payload)), where canonical_json means sorted keys, no whitespace, and integral floats written as integers. Python and Node produce the same hash for the same inputs:

{
  "verification": {
    "algorithm": "sha256",
    "canonicalization": "JSON with sorted keys, no whitespace, integral floats as integers",
    "hash": "2eeba186fb99…",
    "note": "Recompute sha256 over the canonical JSON of `payload`; a mismatch means the
             story state was mutated outside this reducer (silent state drift)."
  }
}

3. query_ai_story_benchmark

Query the verified Nov 15, 2026 10-Platform Consumer AI Story Continuity Benchmark (doi:10.7910/DVN/YEBHQR, CC-BY-4.0).

Input

{ "platform": "Character.AI", "status": "fail" }

Both filters are optional and combinable. platform accepts names or aliases ("talkie", "ai-dungeon", "chai"…); status accepts pass, fail, right_censored, untestable, plus the aggregate tested.

Output — benchmark{} (protocol, summary, DOIs, explorer URL), results[], count, filters{}, warnings[], and citation{apa, bibtex, doi, license, explorer_url}.

4. detect_state_drift

Check a transcript against a planted fact and classify the session with the five-mode silent state drift taxonomy from State Drift in Consumer LLM Interactive Fiction.

Input

{
  "fact": { "key": "cat_name", "expected_value": "Marmalade", "planted_turn": 2 },
  "transcript": [
    "It is raining again.",
    "My cat's name is Marmalade.",
    "Of course. Marmalade hates the rain.",
    "What is my cat's name?"
  ],
  "probe_turn": 4,
  "min_gap": 2
}

transcript entries may be plain strings or {turn, speaker, text} objects. fact.wrong_values[] supplies contradiction candidates; fact.aliases[] supplies accepted spellings; fact.contradiction_mode may be wrong_values (default) or key_mention_without_value.

Verdicts

VerdictModepassedMeaning
PASSF0truerecalled at or after the probe, no contradiction
F4_TRANSIENT_DEGRADATIONF4truestalled (empty turn, missing turn, repeated reply) then recovered
F1_CONTRADICTIONF1falsea later turn asserts a different value
F1_OMISSIONF1falseprobe reached, fact never recalled
F2_SESSION_NON_PERSISTENCEF2falseempty assistant turns after planting
F3_GATING_CENSORINGF3nulltranscript stops before the probe — unknown, not failed
F5_PLATFORM_DELISTINGF5nulldelisting prevented the session (delisted: true)
FACT_NOT_PLANTED—nullexpected value never appears in the transcript
EMPTY_TRANSCRIPT—nullno turns supplied

Output includes per_turn[] (at_or_before_planting / recalled / contradicted / omitted / empty), evidence{recall_turns, contradiction_turns, empty_turns, stall_detected, probe_reached}, the full taxonomy[] and the taxonomy citation.


Resources

URIMIME typeContents
ouba://benchmark/2026-10-platform-matrixapplication/jsonFull CC-BY-4.0 matrix for all 10 platforms, plus citation{} and benchmark{} metadata
ouba://schema/story-graph-v1application/schema+jsonCanonical JSON Schema (draft 2020-12) for branching-story-kit story graphs

The benchmark, in one table

Evaluation date 2026-11-15. $0 spent, email-only identity, no CAPTCHA solving, no OAuth linkage, no payment card, PG-13 content. Fact planted at turn 2, probed at turn 15.

PlatformCategoryStatusTurnsTurn-15 recallTTFS (s)Latency (s)Signup gateMode
OubaReader-first AI fictionPASS20Pass (verbatim)157No—
TalkieCompanion chatbotPASS20Pass173No—
AI DungeonOpen sandboxPASS7†Pass (verbatim)708NoF4
Character.AICompanion chatbotFAIL20Fail213YesF1
Janitor AICompanion chatbotright-censored0Not reached45—YesF2
TalefyReader-first AI fictionright-censored0Not reached7—YesF3
JoylandCompanion chatbotright-censored0Not reached——YesF3
NovelAIAI writing toolright-censored0Not reached——YesF3
ChaiCompanion chatbotuntestable—Not tested———F5
GalateaPre-written serialuntestable—Not tested——Yes (paid)F3

† A transient free-queue stall at turn 7, not a hard paywall — the session resumed and passed the turn-15 probe verbatim.

Derived measures: 10 products evaluated · 4 reached the turn-15 probe · 3 recalled the fact (30% unconditional, 75% conditional) · 4 right-censored · 2 untestable · median time to first story 19 s (range 7–70 s) · mean reply latency 5.3 s · 0 ad interruptions across every completed turn · 3 products with no signup gate before reading.

The single failure is the instructive one: Character.AI sustained 20 turns at ~3 s/reply, fully on-persona, and simply did not have the fact. Nothing in the product's observable behaviour announced the loss — the operational definition of silent state drift, and the reason it requires an external probe rather than a self-report.

Explore the matrix: https://www.ouba.art/tools/benchmark-explorer


Identifiers & citation

ArtifactIdentifier
This softwaregithub.com/ouba-studio/branching-story-mcp · PyPI · JSR · npm @ouba-studio/branching-story-mcp
Primary dataset (CC-BY-4.0)doi:10.7910/DVN/YEBHQR — Harvard Dataverse
Preprint (Zenodo)doi:10.5281/zenodo.24549412
Preprint (Figshare)doi:10.6084/m9.figshare.35126743
Preprint (SSRN)doi:10.17613/rmr3y-hgk56
Core enginebranching-story-kit · PyPI · JSR
Benchmark explorerhttps://www.ouba.art/tools/benchmark-explorer
WikidataQ140090475

APA 7

Ouba Studio. (2026). Interactive Fiction & AI Story Apps Benchmark Dataset (2026) [Data set]. Harvard Dataverse. https://doi.org/10.7910/DVN/YEBHQR

BibTeX

@dataset{ouba_studio_2026_ai_story_benchmark,
  author    = {{Ouba Studio}},
  title     = {Interactive Fiction \& AI Story Apps Benchmark Dataset (2026)},
  year      = {2026},
  publisher = {Harvard Dataverse},
  doi       = {10.7910/DVN/YEBHQR},
  url       = {https://doi.org/10.7910/DVN/YEBHQR},
  license   = {CC-BY-4.0},
  note      = {10-platform consumer AI story continuity benchmark; evaluation date 2026-11-15}
}

@software{ouba_studio_2026_branching_story_mcp,
  author  = {{Ouba Studio}},
  title   = {branching-story-mcp: A zero-dependency Model Context Protocol server for
             deterministic story state and the 2026 Consumer AI Story Continuity Benchmark},
  year    = {2026},
  version = {1.0.0},
  license = {MIT},
  url     = {https://github.com/ouba-studio/branching-story-mcp}
}

Repository layout

branching-story-mcp/
├── branching_story_mcp/          # Python package (stdlib only, >=3.10)
│   ├── __init__.py
│   ├── kernel.py                 # validator, reducer, drift detector, JSON schema
│   ├── benchmark_data.py         # verified CC-BY-4.0 matrix + citation builders
│   └── server.py                 # JSON-RPC 2.0 over stdio
├── js/                           # behaviour-identical ESM mirror (>=18)
│   ├── server.mjs
│   ├── kernel.mjs
│   ├── benchmark.mjs
│   └── index.d.ts
├── schema/story-graph-v1.schema.json
├── data/benchmark-2026-10-platform-matrix.json
├── examples/midnight-bookshop.json
├── tests/test_mcp_server.py      # real stdio handshake + all tools/resources
├── tests/test_js_server.mjs      # same suite against the Node build
├── server.json                   # official MCP Registry manifest
├── smithery.yaml · glama.json · jsr.json · package.json · pyproject.toml
└── LICENSE · CITATION.cff · CHANGELOG.md

Development

# Python
pip install -e . && python -m unittest discover -s tests -v
python -m build                      # wheel + sdist into dist/

# Node
npm test                             # node --test tests/test_js_server.mjs
node js/server.mjs                   # then paste JSON-RPC lines

Both suites drive a real child process over stdio: initialize → notifications/initialized → tools/list → all four tools/call → resources/list → resources/read → ping, plus the error paths.

License

MIT © 2026 Ouba Studio. The bundled benchmark data (benchmark_data.py, js/benchmark.mjs, data/benchmark-2026-10-platform-matrix.json and the ouba://benchmark/2026-10-platform-matrix resource) is CC-BY-4.0, Ouba Studio (2026), doi:10.7910/DVN/YEBHQR.


Ouba — free reader-first interactive fiction on web, iOS and Android · 2026 AI Story Apps Benchmark · Benchmark Explorer · branching-story-kit · team@ouba.art

PYPI
branching-story-mcp
Install Command
pip install branching-story-mcp
Runtime: uvx