Repository files navigation
mcpfs
Expose one or more MCP servers as a read-only filesystem. Mount it locally with Linux FUSE or serve it to a Linux guest over vhost-user virtio-fs. Open resource and skill files with normal Unix tools. Run each mounted tool as a shell command with named options or JSON input.
mcpfs is a developer demo and is not production ready. Only use it with MCP servers you trust. Mounting a server processes its catalog immediately, before you open a file or run a tool. A slow or faulty server can delay startup for every server on the same mount.
Build
From the repository root on Linux, build all three binaries with Rust and Cargo. The TLS backend needs a C compiler, pkg-config, and OpenSSL development headers.
cargo build --workspace --locked --release
The binaries are target/release/mcpfs-fusefs (local mounts), target/release/mcpfs-virtiofs (VM backend), and target/release/mcpfs (guest helper).
Examples
To try mcpfs on a FUSE-capable host, run the single-server demo. It mounts the bundled Python fixture, reads a resource and a skill, invokes a tool, and unmounts on exit.
./examples/fuse-single/run.sh
| Adapter | One MCP server | Multiple MCP servers |
|---|---|---|
| FUSE | fuse-single | fuse-multi |
| QEMU virtio-fs | qemu-single | qemu-multi |
Mount with FUSE
Run these commands from the repository root on Linux. For an unprivileged mount, the user needs access to /dev/fuse and the FUSE 3 fusermount3 helper. The mounted tool scripts use Bash.
mkdir -p /tmp/openai-docs
target/release/mcpfs-fusefs mount https://developers.openai.com/mcp /tmp/openai-docs
The mount runs in the foreground. In another terminal, read the tool's manual, run a search, and unmount it.
ls /tmp/openai-docs/tools
/tmp/openai-docs/tools/list_api_endpoints --help
/tmp/openai-docs/tools/list_api_endpoints
/tmp/openai-docs/tools/search_openai_docs --pretty --query 'Responses API streaming' --limit=1
fusermount3 -u -- /tmp/openai-docs
This example uses the public documentation server. OpenAI Docs MCP
| Server | Arguments after mount |
|---|---|
| Streamable HTTP, including request-scoped SSE | https://host.example/mcp /tmp/mcp |
| Local stdio, including authenticated bridges | stdio:// /tmp/mcp -- program arg1 arg2 |
| Concrete resource from a template or an unlisted URI | https://host.example/mcp /tmp/mcp --resource 'records://team/42' |
For the single-server syntax above, set MCPFS_BEARER_TOKEN in the mounting process's environment for an HTTP bearer token. Have the server's auth client acquire or refresh the token and remount after replacing it. Stdio launches the supplied argv directly.
Recommendation
Use an https:// endpoint whenever you supply a bearer token, whether through MCPFS_BEARER_TOKEN or a named server's --bearer-token-env option. With http://, mcpfs sends the token in the clear.
Mount multiple servers
mkdir -p /tmp/mcp
target/release/mcpfs-fusefs mount /tmp/mcp \
--server docs https://developers.openai.com/mcp \
--server local stdio:// --command /path/to/mcp-server
Repeat --server NAME URI to add a server. Put its --resource URI and --bearer-token-env VAR options before --command. For stdio, --command takes the program and its arguments up to the next --server. In a named mount, HTTP bearer tokens come from each server's explicit --bearer-token-env option.
The example exposes docs/tools/ and the namespaces provided by local/. The mount also provides merged tools/, resources/, and skills/ directories wherever there are entries. Unique names keep their paths. If two servers both have a tool named search, the merged directory exposes tools/docs:search and tools/local:search. Resources collide at the same relative path. Skill directory collisions receive the prefix on the directory, so each skill keeps its own SKILL.md and supporting files. A server named search, tools, resources, or skills gets a ~server- prefix on its top-level directory.
Serve a virtio-fs share
Install the mcpfs binary and Bash inside the Linux guest for executable tool and search scripts. On the host, run the virtio-fs backend with that guest binary's path and a socket in a private runtime directory.
socket="$XDG_RUNTIME_DIR/mcpfs.sock"
target/release/mcpfs-virtiofs \
--guest-helper /usr/local/bin/mcpfs --uid 1000 --gid 1000 \
https://developers.openai.com/mcp "$socket"
Pass the socket to a VMM's vhost-user virtio-fs device. For QEMU, these options add the device with the tag mcpfs to a VM configured with 2 GiB of RAM. Adjust the guest UID, GID, and memory size to fit your VM.
-object memory-backend-memfd,id=mem,size=2G,share=on
-machine memory-backend=mem
-chardev socket,id=mcpfs,path=/path/to/mcpfs.sock
-device vhost-user-fs-pci,chardev=mcpfs,tag=mcpfs
Inside the guest, run mount -t virtiofs -o ro mcpfs /mnt/mcp. The backend uses the same single-server and named-server arguments as the FUSE CLI, with a socket path in place of the mountpoint. The guest UID and GID default to the daemon's effective IDs. A process that can execute the mounted tools can act with the backend's MCP credentials. QEMU vhost-user backends
Each daemon serves one VMM connection with a high-priority queue and a single request queue. Start a new daemon for a new connection. The guest validation used QEMU with shared memory and an externally managed socket.
For a resource whose size is learned on open, guest programs that use sendfile can see the initial zero size until the kernel refreshes its attributes. A direct read, such as dd if=/mnt/mcp/resources/example, fetches the bytes immediately.
Crates
- mcpfs provides the common tool and search commands and the helper binary for guests.
- mcpfs-fusefs adapts the VFS to a local Linux FUSE mount.
- mcpfs-virtiofs adapts the VFS to guest filesystem requests on vhost-user queues.
- mcpfs-vfs owns MCP sessions, the namespace, resource and skill caches, open file handles, and tool result selection.
- mcpfs-ioctl maps the VFS to the Linux tool invocation ABI used by both adapters.
Files and names
For a server advertising foo://a/b/c, a demo skill, and a do_stuff tool:
search
resources/foo/a/b/c
resources/skill/demo/SKILL.md
skills/demo/SKILL.md
skills/demo/references/guide.txt
tools/do_stuff
- Resources use cached bytes on open when available. A text response becomes UTF-8, a blob becomes its decoded bytes, and a multipart reply becomes a JSON array preserving the individual content blocks. An open fd keeps a consistent copy across seeks and partial reads. Until a file is opened, its size comes from the listing, or is zero if the server supplied none.
- Skills use the MCP Skills extension. The driver follows paginated manifests, verifies advertised SHA-256 digests and sizes on open, and enumerates dynamic skills through resources/directory/read where available. Listed skill:// resources are also visible under skills/. An extension-declared skill with another URI scheme lives at skills/~scheme/<scheme>/…. All skill files are ordinary, non-executable data.
- Tools are executable Bash scripts. Open one as text to read its name, description, and schemas in comments above the executable logic. Pass --help to print that information. Invocations write their result to stdout. A tool error, protocol error, or invalid input yields a nonzero exit.
- Names preserve URI scheme, authority, and slash-separated path. Unsafe bytes, a literal percent or tilde, and dot segments use uppercase percent encoding. Empty components use ~empty. Non-hierarchical URIs use ~opaque. Query strings and fragments stay on the final component after ~suffix. If a resource is also a parent (e.g. foo://a/b and foo://a/b/c), its own bytes live at resources/foo/a/b/~value. Overlong components and paths use SHA-256 names. The original URI and tool name are available as xattrs.
- Discovery runs once per server and follows pagination. Each of resources/, skills/, and tools/ appears when it contains an entry. Remount to refresh names. Repeat --resource URI for concrete template instances. Prompts, sampling, interactive elicitation, and interactive OAuth flows have no filesystem mapping.
Discovery reserves space for up to 262,144 projected nodes across all servers in the mount. Each path reserves space for its parent directories and any merged view, so shared prefixes can make the estimate larger than the final inode count. If the catalog exceeds the limit, the mount fails during discovery.
All servers in a mount share a 64 MiB catalog budget. Discovery estimates the size of decoded entries and pagination cursors, and counts filesystem entries, generated tool scripts, and the search index against the same budget. If the catalog exceeds the budget, the mount fails to start. Total process memory can be higher while responses are in flight or temporary data is being built.
Search the catalog
/tmp/mcp/search 'streaming'
/tmp/mcp/search --tools 'OpenAPI'
/tmp/mcp/search --resources --skills 'reference'
search matches a case-insensitive literal substring against names and advertised descriptions. It prints one path relative to the mount root per match. Scope flags can be combined, and the default searches all three namespaces. On a multi-server mount it prints paths from the merged views. Skills resolve to their SKILL.md files. Search reads the catalog snapshot locally, so it can run without making an MCP request. An empty result succeeds with no output.
Tool arguments
Each tool's embedded help is limited to 64 KiB. If detailed help exceeds the limit, --help shows a short usage message. Named options have a separate limit. If their table is too large, pass a JSON object as an argument or on stdin.
These three commands send the same input to the search tool.
tool=/tmp/openai-docs/tools/search_openai_docs
"$tool" --query 'Responses API streaming' --limit=1
printf '%s\n' '{"query":"Responses API streaming","limit":1}' | "$tool"
"$tool" '{"query":"Responses API streaming","limit":1}'
Both --name VALUE and --name=VALUE work. String fields preserve their text, including leading zeroes. Pass numbers, booleans, nulls, arrays, and objects as JSON values. For example, --items '[1,2]' passes an array. Use --name=--literal for a value beginning with two dashes. For a field with no declared type, valid JSON becomes a JSON value and other text becomes a string.
For fields whose types depend on a schema pattern, reference, or conditional branch, pass a JSON object if help gives no named option.
With no arguments, a tool reads a JSON object from stdin. On a terminal it prompts you to enter JSON and press Ctrl-D. For a plain object schema with no declared parameters, such as list_api_endpoints, running the tool on a terminal or with empty stdin sends {}. Piped JSON still passes through. An explicit - always requires JSON on stdin.
A successful call prints structuredContent when present, including an explicit null. Otherwise it prints the content array. When that array contains only one unannotated text block, the script prints the text body verbatim. Tool and RPC errors print their JSON diagnostics.
JSON output defaults to one compact line. Add --pretty to indent it, or --pretty=false to select compact output. Both JSON modes preserve newlines inside strings as JSON escapes and end the document with a newline. Plain text keeps its original line endings.
Use -- before a tool field named help or pretty. For example, --pretty -- --pretty=false indents output while sending {"pretty":false}, and -- --help=topic sends {"help":"topic"}.
Mount cache
Each server keeps up to 256 entries and 16 MiB of resource and skill contents and MIME metadata in memory. Entries live for up to 30 seconds. A resource's shorter ttlMs takes precedence, including zero. Discovery builds each distinct skill file once per server. Its paths under resources/ and skills/ are hard links to the same inode. Repeated manifest declarations must agree on the file's digest and size. Each open file keeps its own snapshot across expiry and invalidation.
The driver updates a resource's modification time when an open observes different bytes. Reads of identical bytes preserve that timestamp. Attribute lookups use the last observed metadata without fetching the resource.
Every tool invocation sends a separate MCP request. A tool call clears its server's cached resource and skill contents when it finishes. When a server supports resource subscriptions, the mount watches up to eight recently read, cacheable URIs per server. A resource update evicts that URI, and a resource list change clears the server's cache. The TTL governs freshness when a resource has no active watch. Remount to refresh names and tool schemas.
Extended attributes
| Attribute | Value |
|---|---|
| user.mcp.uri | Original resource or skill-file URI |
| user.mcp.mime_type | Advertised MIME, updated by a read response when supplied |
| user.mcp.name , user.mcp.description | Advertised tool or resource name and optional description |
| user.mcp.input_schema , user.mcp.output_schema | JSON schemas; output schema when advertised |
| user.mcp.frontmatter , user.mcp.digest | Advertised skill entry metadata and per-file digest, where supplied |
getfattr -d -m '^user\.mcp\.' PATH lists metadata. Linux limits individual xattrs to 64 KiB.
Invocation ABI
Help is embedded in each script as literal data. Bash builtins handle help and split command-line options. The same local mcpfs binary encodes the values as one JSON object and opens the mounted script read-only. The daemon selects the tool by inode. Keep the binary at its original path while mounted.
| ioctl | Linux encoding | Operation |
|---|---|---|
| APPEND | _IOW('M', 0x70, char[4096]) | Append up to 4,092 JSON bytes. The first four bytes are a little-endian length. |
| RUN | _IO('M', 0x71) | Seal the arguments and resolve one invocation. Returns 1 for JSON success, 2 for a tool or RPC error, and 3 for verbatim text encoded as a JSON string. Older daemons return 0 with the status in the result JSON. |
| NEXT | _IOR('M', 0x72, char[4096]) | Read the next framed chunk of compact JSON. A zero length means EOF. |
The kernel copies fixed-size frames between the helper and daemon. Arguments are limited to 8 MiB. Results span as many frames as needed. Independent opens have independent state. Reading or inspecting a script never invokes its tool. mcpfs starts cancelling an MCP resource read or tool call after five seconds without a response. A timed-out tool may already have changed remote state. Streamable HTTP limits each JSON response body and SSE event to 16 MiB.
Tool invocations and resource fetches run independently of the FUSE request dispatcher. Directory listings, metadata, and reads from open files can proceed while an MCP request is pending. The server determines how it handles concurrent requests.
Each virtio-fs connection admits up to eight deferred opens and eight tool calls at once. It supports up to 1,024 open files, 64 MiB of open resource snapshots, and a separate 64 MiB for buffered tool input and output. A resource snapshot counts against the limit for each open handle, even when it shares cached bytes. The guest receives EAGAIN when deferred work slots are full, EMFILE when the open-file limit is reached, and ENOSPC when a byte budget is exhausted. Closing a file releases its snapshot and any unread tool output. Draining tool output also frees its buffer. RUN can return ENOSPC after the remote tool has executed if there is insufficient room to buffer its result.
Tests
The test suite starts its own MCP servers with Python 3. Run the workspace tests and Rust checks from the repository root.
cargo test --workspace --locked
cargo fmt --all -- --check
cargo clippy --workspace --all-targets --locked -- -D warnings
The virtio-fs integration test sends filesystem operations and a tool invocation through shared guest memory and real vhost-user queues. It runs without a VM. Run the live FUSE test separately on a host with /dev/fuse and fusermount3.
cargo test --locked -p mcpfs-fusefs --test linux_mount -- --ignored
License
Copyright (c) 2026 OpenAI. mcpfs is licensed under the Apache License, Version 2.0.