PluginBench
MCP Server
Active
MIT

mdflow — Context OS for AI Coding Agents MCP Server

io.github.yubinbin32-ops/mdflow

Context OS for AI coding agents: task-scoped AST slices, verified mutations, and rollback with compact receipts.

What is the mdflow — Context OS for AI Coding Agents MCP server?

ContextOS is an open-source execution layer between an AI coding agent and your repository that returns focused source slices, runs commands outside the conversation, and brings back compact verification receipts. It reduces context waste by replacing whole-file reads with precise symbol or line-range slices and keeping build logs on disk instead of in the conversation.

ContextOS optimizes token usage for AI coding agents by providing task-scoped AST context, verified code mutations with rollback capability, and persistent project state. It measures 76–99% reduction in output tokens for common workflows like reading a single function from a large file or reviewing build results, making it ideal for long-running coding tasks where context efficiency matters.

How to install mdflow — Context OS for AI Coding Agents

Copy-paste configuration for popular MCP clients.

transport: stdio
Config generated by PluginBench — verify against the source before use.
Environment / auth
  • MDFLOW_PROJECT_ROOT

    Absolute path of the mounted project directory containing .mdflow.

~/Library/Application Support/Claude/claude_desktop_config.json
{
  "mcpServers": {
    "mdflow": {
      "command": "docker",
      "args": [
        "run",
        "-i",
        "--rm",
        "ghcr.io/yubinbin32-ops/mdflow:0.3.7"
      ],
      "env": {
        "MDFLOW_PROJECT_ROOT": "<YOUR_MDFLOW_PROJECT_ROOT>"
      }
    }
  }
}

Tools & capabilities

Tools this server exposes to the agent.

  • contextos — Main MCP tool that supports inspect (read symbols or line ranges with source locations), change (apply edits with verification and optional auto-rollback), and batched operations. Returns compact receipts instead of replaying logs.

Use cases

  • Extract and inspect a single function or symbol from a large file without loading the entire file
  • Apply code changes with automatic verification via npm test or custom commands, with rollback on failure
  • Batch multiple file reads and test runs in a pipeline to reduce back-and-forth turns
  • Reuse project state and architecture graphs across multiple coding sessions stored in .contextos/
  • Review build failures with actionable error details instead of pasting entire noisy logs into the conversation

mdflow — Context OS for AI Coding Agents MCP server FAQ

What is ContextOS?

ContextOS is an execution layer for AI coding agents that returns focused code slices (via AST), runs verification commands outside the conversation, and persists project state. It reduces context waste by replacing whole-file reads with precise symbol slices and keeping logs on disk.

Is ContextOS free?

Yes, ContextOS is open-source under the MIT license.

How do I install it in Cursor or Claude?

For Cursor (Codex), clone the repository, run npm ci && npm run plugin:build, then register it with codex plugin marketplace add and codex plugin add contextos@contextos-development. For other MCP hosts like Claude, add the stdio server to your MCP configuration pointing to contextos-mcp.mjs and provide the ContextOS skill.

What are the measured token savings?

Benchmarks show 76–99% reduction in output tokens for common tasks: reading one symbol from a 43k-token file returns 280 tokens (99.35% less), and a 1k-line build log returns 83 tokens (99.41% less). The server itself adds ~2,504 tokens of overhead.

Does ContextOS require an API key or cloud account?

No. The core MCP server runs locally and needs no cloud account or model API key. Cloud collaboration and the optional Micro executor are experimental features.

What does 'verified mutation' mean?

ContextOS applies code edits and runs verification commands (like npm test) in a single batch, returning a compact receipt with the result. If verification fails and autoRevert is enabled, changes are automatically rolled back.

README (reference)

Source of truth, from the repository.

<div align="center"> <img src="assets/logo.png" width="80" alt="ContextOS logo" /> <h1>ContextOS</h1> <p><strong>Give your coding agent the code it needs. Keep noisy logs out of the conversation.</strong></p>

GitHub release GitHub stars Node.js 22+ MIT license

<p>Current Version: <span id="contextos-version">2.7.1</span> · Local MCP runtime · AST slices · Verification receipts · Persistent project state</p>

Get started · See the measurements · Releases · 中文

</div>

ContextOS is an open-source execution layer between an AI coding agent and your repository. It returns focused source slices, runs commands outside the conversation, and brings back compact verification receipts with actionable failure details. Project state stays in .contextos/ so later work can reuse it.

Measured on two files from this repository: 1,459 → 336 and 43,031 → 280 returned tokens when replacing whole-file reads with a symbol slice. These are output-context measurements, not model billing or total-task savings. Method, controls, and raw results →

ContextOS workflow and architecture map demo

Why use it?

Common source of context wasteWhat ContextOS does
Loading a large file to change one functionReads a symbol or precise line range, with source locations
Re-reading unchanged codeReturns an unchanged receipt instead of replaying the body
Pasting successful build logs into a chatKeeps logs on disk; returns the command, exit code, and receipt
Losing the failure detail in a noisy test runReturns failure evidence alongside the verification result
Several file reads and tests across separate turnsBatches work in a pipeline; combines edits and verification
Reconstructing project state in a later sessionPersists session state and a Block/Chain/Link architecture graph

The default MCP surface exposes one contextos tool. Codex can load it as a plugin; other MCP hosts can run the same local server. Optional desktop apps show the architecture as a Metro Map. Micro is an optional external executor; the benchmark and core workflow need no model API key.

Measured results

Five fresh-workspace runs, o200k_base tokenizer, medians. The table measures response text only.

ScenarioNative output tokensContextOS output tokensChange
Large repository file → one symbol43,03128099.35% less
Smaller repository file → one symbol1,45933676.97% less
Repeated unchanged symbol read1653678.18% less
Synthetic successful build, 1,000 log lines14,0038399.41% less
Synthetic failed build, 1,000 log lines14,01615098.93% less
Efficient native slice of the same large-file symbol165280115 more
Tiny file66660 more

Use it where the saved context outweighs the setup. The measured compact tool definition, server instructions, and skill add about 2,504 tokens when loaded together. Exact native slices can be cheaper on a first read; trivial edits should skip the full exploration lifecycle. Synthetic log results show compression under controlled noise, not typical project performance. Provider usage, reasoning tokens, cache discounts, and task completion quality require a separate agent A/B study.

The compact tool definition uses 1,056 tokens versus 2,922 for the seven-tool compatibility surface. Full evaluation, fixed costs, and remaining opportunities.

Get started

Requires Node.js 22+. Source installation is the reproducible route for this release.

git clone https://github.com/yubinbin32-ops/ContextOS.git
cd ContextOS
npm ci
npm run plugin:build

Codex plugin

With a Codex CLI that supports plugins, register the marketplace shipped in this repository:

codex plugin marketplace add .
codex plugin add contextos@contextos-development
npm run plugin:install
npm run plugin:install:check

Start a new chat to load the updated server and skill. The check validates the registered version and installed files against this build; copying a newer bundle into an old cache is insufficient.

Other MCP hosts

Add this stdio server to your host's MCP configuration, replacing the absolute path:

{
  "mcpServers": {
    "contextos": {
      "command": "node",
      "args": ["/absolute/path/ContextOS/plugins/contextos/server/contextos-mcp.mjs"]
    }
  }
}

Give your agent the ContextOS skill, or ask it to follow the setup guide. Host configuration formats differ; the guide covers Cursor, Claude, Antigravity, and OpenCode adapters.

A small example

These are MCP calls made by your agent, using an absolute projectRoot:

contextos({
  action: "inspect",
  args: { path: "src/cart.ts", symbol: "calculateTotal" },
  projectRoot: "/absolute/path/to/project"
})

contextos({
  action: "change",
  args: {
    edits: [{ path: "src/cart.ts", target: "price * quantity", replacement: "price * quantity - discount" }],
    verify: ["npm test"],
    autoRevert: true
  },
  projectRoot: "/absolute/path/to/project"
})

For larger tasks, the skill routes exploration, precise inspection, verification, and edits through the pipeline. Files remain editable with ordinary tools. Successful receipts avoid replaying logs; explicit ranges and recovery reads provide detail when needed.

What's new in 2.7.1?

  • Batched inspections honor explicit symbols and line ranges without an undocumented opt-in.
  • Non-contiguous code slices preserve each range's original source line numbers.
  • Installation refreshes Codex's registered version, checks actual file contents, and preserves inactive historical caches.
  • A read-only install check rejects stale registrations or bundles.
  • Plugin builds and installs include parser WASM and grammars, preserving Python method hashes and call information outside the source checkout.
  • A public benchmark includes efficient native controls, negative results, fixed overhead, and quality assertions.

Release notes · Latest release

Local state, desktop, and optional services

Local mode stores project state in the workspace. The core server needs no cloud account. Cloud collaboration is experimental; Micro calls an external model only when configured and invoked. Choose these features when your workflow needs them.

Desktop downloads and their supported platforms are listed per release. The 2.7.1 measurements cover the MCP runtime on macOS arm64; they do not establish Windows desktop performance or cloud/Micro savings.

Reproduce and contribute

npm test
npm run plugin:verify
npm run dist:smoke
npm run acceptance:real
npm run benchmark:context -- --runs 5 --output .contextos/benchmarks/my-run.json

Share your benchmark with the repository size, task, host, tokenizer, and baseline. Reports where ContextOS costs more are useful too.

If focused reads and compact receipts help your coding workflow, star ContextOS to follow its progress. Report a bug or contribute an improvement.

Contributing · Security · MIT license

Related MCP servers

Powered exoskeleton for AI coding: auto-governs context via MCP to cut 90%+ context waste.

View repository →
AIAI-First Scraper logo

Three MCP tools: fetch_page, fetch_pages_batch, search_web. Ad-free Markdown for AI agents.

2
Python
MIT
View repository →
RERepo Memory logo

Repo Memory

Maintained

Shared, git-tracked working memory for AI agents on the same codebase.

1
Python
MIT
View repository →

Double-entry bookkeeping MCP server — import bank CSVs, categorize, reconcile, tax reports.

0
TypeScript
MIT
View repository →

Multi-database MCP server for PostgreSQL, MySQL, and ClickHouse

6
Python
MIT
View repository →

Korean public official asset disclosure data (공직자 재산공개) - search and retrieve assets

View repository →