Originally published at naditu.com/blog/openai-mcpfs-fuse-filesystem-vs-mcp-code-mode.

Connecting a language model to a realistic Model Context Protocol (MCP) server immediately exposes a context-window tax: loading dozens of full JSON tool schemas up front burns tens of thousands of prompt tokens before the user asks a single question.

Two progressive-disclosure architectures solve that schema tax from opposite ends of the stack:

  1. MCP Code Mode (used in Claude Code and Cloudflare Agents): embeds a JavaScript/TypeScript sandbox inside the agent harness where MCP tools appear as typed async functions.
  2. OpenAI mcpfs: a lightweight Rust FUSE (Filesystem in Userspace) adapter that mounts any MCP server as a live POSIX directory tree (tools/, resources/, and a generated search helper) so any agent with a bash tool can discover and invoke MCP tools using ordinary Unix commands (ls, cat, jq, ./tools/<name>).

Put simply: mcpfs plus a bash tool is Code Mode whose language is bash.

1. What Appears Inside an mcpfs Mount

When mcpfs mounts an MCP server at /mnt/mcp, the directory is not written to disk. Instead, a background mount daemon answers kernel filesystem operations on demand:

  • search: a generated executable script embedding a catalog snapshot that delegates queries (./search --tools invoice) back to mcpfs so the model finds relevant tools before reading any schema.
  • tools/<tool_name>: executable wrapper scripts per tool. Running ./tools/<tool_name> --help discloses that single tool's flags and input schema; running ./tools/<tool_name> --limit 5 --pretty executes tools/call over MCP and prints JSON to stdout.
  • SKILL.md / resources/: live MCP resources read on demand via cat.

2. Why Mount a FUSE Virtual Filesystem Instead of Generating Files on Disk?

Writing static wrapper files to disk creates a stale snapshot the moment an MCP server emits notifications/tools/list_changed or updates a live resource. Mounting a FUSE filesystem tells the Linux VFS (Virtual File System): "Do not read blocks from ext4; forward file operations under this path over /dev/fuse to the registered userspace daemon."

POSIX / Shell Action Kernel VFS / /dev/fuse Operation How mcpfs Responds
ls /mnt/mcp/tools FUSE_READDIR Serves tool names from its in-memory MCP catalog
ls -l / stat FUSE_LOOKUP + FUSE_GETATTR Synthesizes inode metadata and 0555 executable bits
./tools/get_order --help FUSE_OPEN + FUSE_READ Generates CLI usage & schema help for that single tool
./tools/get_order --id 42 Custom FUSE_IOCTL (0x70..0x72) Dispatches live tools/call JSON-RPC to the MCP server and returns stdout bytes

On macOS—where native kernel FUSE is not built into Darwin—running mcpfs inside a Linux container bridges host/VM filesystem boundaries over virtiofs shared memory while keeping /dev/fuse inside the Linux guest kernel.

3. Architectural Comparison: mcpfs vs. In-Process MCP Code Mode

Dimension Upfront MCP Tool Catalog In-Process MCP Code Mode OpenAI mcpfs (FUSE + Shell)
Where It Lives Every MCP client prompt Inside the agent harness runtime OS filesystem mount (FUSE daemon)
Composition Language Separate LLM turn per tool call TypeScript / V8 isolate (async/await) POSIX sh / bash, Unix pipes, jq, awk
Schema Token Cost O(N) upfront on turn 1 O(k) progressive disclosure O(k) progressive disclosure (./search, --help)
Per-Call Overhead Full LLM inference round-trip Sub-millisecond in-process call fork + execve + /dev/fuse ioctl + MCP RPC
Harness Lock-In None Tied to harness implementing Code Mode Zero — works with any agent or CLI that has shell access

4. Why Progressive Tool Discovery Still Needs an Enterprise Ontology

Whether an agent discovers tools through mcpfs shell scripts or TypeScript Code Mode, progressive disclosure solves transport ergonomics—not business semantics. If the underlying MCP server exposes raw ERP tables or generic POST/PATCH endpoints, the model still has to guess undocumented join keys, status integers, fiscal period rules, and write invariants.

Pairing lightweight tool discovery with a governed enterprise ontology ensures every discovered tool reads verified business objects under caller-scoped RBAC and routes every mutation through human-evaluated ERP Action Types.

Read the full breakdown (with interactive Architectural Plate /dev/fuse & ioctl sequence specs and primary-source footnotes) at naditu.com/blog/openai-mcpfs-fuse-filesystem-vs-mcp-code-mode.