Skip to main content

Stratum MCP server for Claude Code — structured execution, typed contracts, postcondition enforcement

Project description

stratum-mcp

Stratum MCP server for Claude Code. Structured execution, typed contracts, postcondition enforcement — no sub-LLM calls.

Install

pip install stratum-mcp
stratum-mcp install

install configures Claude Code in one command: writes .claude/mcp.json, appends the execution model block to CLAUDE.md, installs skills to ~/.claude/skills/, and registers session hooks to ~/.stratum/hooks/. Restart Claude Code and it's active.

IR Spec (v0.3)

Stratum specs are YAML files with typed contracts, step definitions, and postcondition ensures:

version: "0.3"

contracts:
  ReviewResult:
    clean:    {type: boolean}
    summary:  {type: string}
    findings: {type: array}

flows:
  my_flow:
    steps:
      - id: implement
        agent: claude
        intent: "Build the feature"
        output_contract: ReviewResult
        ensure:
          - "result.clean == True"
        retries: 3

Step types

Type Purpose
inline Single agent step with intent + ensures (default)
function Named function reference
flow Sub-flow invocation
decompose Agent decomposes work into a TaskGraph
parallel_dispatch Fan-out tasks from a TaskGraph with concurrency control

Parallel dispatch (v0.3)

- id: execute
  type: parallel_dispatch
  source: "$.steps.decompose.output.tasks"
  max_concurrent: 3
  isolation: worktree    # worktree | branch | none
  require: all           # all | any | N
  merge: sequential_apply
  intent_template: "Implement {task.description}"
  • isolation: worktree — git worktree per task (write isolation)
  • isolation: none — shared working directory (read-only tasks)
  • require — how many tasks must pass: all, any, or integer N

Skills

Skill What it structures
/stratum-onboard Read a new codebase cold and write project-specific MEMORY.md
/stratum-plan Design a feature and present it for review — no implementation until approved
/stratum-feature Feature build: read existing patterns → design → implement → tests pass
/stratum-review Three-pass code review: security → logic → performance → consolidate
/stratum-debug Debug: read test → read code → check env → hypotheses → confirm/rule out → fix
/stratum-refactor File split: analyze → design modules → plan extraction order → extract one at a time
/stratum-migrate Find bare LLM calls and rewrite as @infer + @contract
/stratum-test Write a test suite for existing untested code
/stratum-speckit Spec-kit lifecycle: spec.md → plan.md → tasks/ → .stratum.yaml → execute

MCP Tools

Tool What it does
stratum_validate Validate a .stratum.yaml spec
stratum_plan Validate + create execution state + return first step
stratum_resume Resume an existing flow from its current step
stratum_step_done Report step result; check postconditions; return next step or completion
stratum_parallel_done Report batch results for a parallel_dispatch step
stratum_skip_step Skip a step (policy: skip mode)
stratum_gate_resolve Resolve a gate step (approve/revise/kill)
stratum_audit Return per-step trace (attempts, duration) for any flow
stratum_check_timeouts Check for timed-out steps in a flow
stratum_iteration_start Start an iteration loop on a step
stratum_iteration_report Report iteration result (clean/dirty/max_reached)
stratum_iteration_abort Abort an iteration loop
stratum_commit Checkpoint flow state with a label
stratum_revert Revert flow state to a labeled checkpoint
stratum_compile_speckit Compile tasks/*.md into a .stratum.yaml spec
stratum_draft_pipeline Generate a pipeline spec from a description
stratum_list_workflows List all active and completed flows

Building on Stratum

Stratum exposes four stable integration points for apps and tooling:

1. MCP tools (Claude Code agents)

The primary control plane — stratum_plan, stratum_step_done, stratum_audit. Used by agents running inside Claude Code.

2. Query CLI (read-side, any process)

stratum-mcp query flows              # → JSON array of FlowSummary
stratum-mcp query flow <id>          # → JSON FlowState
stratum-mcp query gates              # → JSON array of pending gates

Exit 0, JSON to stdout. Use from shell scripts, background services, or UI backends.

3. Gate CLI (write-side, any process)

stratum-mcp gate approve <flow_id> <step_id> [--note "..."] [--resolved-by agent]
stratum-mcp gate reject  <flow_id> <step_id> [--note "..."]
stratum-mcp gate revise  <flow_id> <step_id> [--note "..."]

Exit codes: 0 success · 1 error (JSON on stdout) · 2 conflict (already resolved).

4. Storage schemas (contracts/)

Versioned JSON schemas for the flow state and audit record formats. Stable across internal refactors.

stratum-mcp/contracts/
  flow-state.v1.schema.json
  query-flows.v1.schema.json
  query-gates.v1.schema.json
  gate-mutation.v1.schema.json
  audit-record.v1.schema.json

5. Migration CLI

stratum-mcp migrate flow.stratum.yaml                # preview diff, prompt to apply
stratum-mcp migrate flow.stratum.yaml --dry-run      # diff only, no write
stratum-mcp migrate flow.stratum.yaml --yes          # apply without prompt
stratum-mcp migrate flow.stratum.yaml --to 0.3       # pin target version
stratum-mcp migrate flow.stratum.yaml --output new.yaml --force
stratum-mcp migrate flow.stratum.yaml --backup       # save flow.stratum.yaml.bak alongside

Upgrades a spec across IR versions. Today the only registered transform is 0.2 → 0.3 (a pure version-string bump, since v0.3 is a backward-compatible superset of v0.2). The framework is extensible — future versions add a Transform entry in stratum_mcp/migrate.py::TRANSFORMS and get chained automatically.

Formatting is preserved via ruamel.yaml round-trip with source-derived indent detection; comments, blank lines, and the spec's original indentation survive the migration.

Exit codes: 0 success/no-op, 1 validation or I/O failure, 2 user declined, 3 unknown version or no transform path.

Hooks

stratum-mcp install registers three Claude Code hooks in ~/.stratum/hooks/:

Hook Trigger Purpose
stratum-session-start.sh SessionStart Initialize Stratum state for the session
stratum-session-stop.sh Stop Clean up and persist session state
stratum-post-tool-failure.sh PostToolUseFailure Log tool failures for debugging

How It Works

Claude writes .stratum.yaml specs internally — you never see them. You see plain English narration. The MCP server enforces postconditions on every step; if a step's output fails a check, Claude fixes it and retries before reporting success.

Full documentation: stratum-in-claude-code.md

Tutorial: claude-code-tutorial.md

License

Apache 2.0

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

stratum_mcp-0.2.29.tar.gz (186.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

stratum_mcp-0.2.29-py3-none-any.whl (107.5 kB view details)

Uploaded Python 3

File details

Details for the file stratum_mcp-0.2.29.tar.gz.

File metadata

  • Download URL: stratum_mcp-0.2.29.tar.gz
  • Upload date:
  • Size: 186.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for stratum_mcp-0.2.29.tar.gz
Algorithm Hash digest
SHA256 84dc58cbe1ec3e99e2875480d005586d98b8eb6cd6305724a9fd62a642babfaa
MD5 fc51a812dfeaf7e252ca1e4c5dc812d6
BLAKE2b-256 361949517b29c180682d5843df2abffbc8d89ed763e00558506f80fe97776545

See more details on using hashes here.

Provenance

The following attestation bundles were made for stratum_mcp-0.2.29.tar.gz:

Publisher: publish.yml on regression-io/stratum

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file stratum_mcp-0.2.29-py3-none-any.whl.

File metadata

  • Download URL: stratum_mcp-0.2.29-py3-none-any.whl
  • Upload date:
  • Size: 107.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for stratum_mcp-0.2.29-py3-none-any.whl
Algorithm Hash digest
SHA256 1af9d9859f05f40bf27ce986cb8c6d5b4d5215381c3f1a4fe1296df6ad86ecc4
MD5 5fc37a7dedd747fca4f863dbf899cd53
BLAKE2b-256 a845e2320dde47d6952b6c8cd9064d6182fbe065ad188cd8891abe111f21cb73

See more details on using hashes here.

Provenance

The following attestation bundles were made for stratum_mcp-0.2.29-py3-none-any.whl:

Publisher: publish.yml on regression-io/stratum

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page