Octofs
Provides code-exploration support for C and C++, including file outlines, ast-grep syntax-tree search, symbol definitions and references, callers/callees, imports, and type hierarchies.
Provides outline support for CSS files, listing declarations with bodies elided.
Provides code-exploration support for Elixir, including outlines, syntax-tree search, symbol lookups, and graph relations such as callers and callees.
Provides code-exploration support for JavaScript, including outlines, ast-grep syntax-tree search, symbol definitions/references, callers/callees, imports, and re-export-aware graph relations.
Provides code-exploration support for Lua, including outlines, syntax-tree search, symbol lookups, and call graph relations, though supertype/subtype extraction is unavailable.
Provides Markdown heading outlines and symbol lookups for headings, but does not support syntax-tree search or graph relations.
Provides code-exploration support for PHP, including outlines, syntax-tree search, symbol definitions/references, callers/callees, imports, and type hierarchies.
Provides code-exploration support for Python, including outlines, syntax-tree search, symbol definitions/references, callers/callees, imports, and re-export-aware graph relations.
Provides code-exploration support for Ruby, including outlines, syntax-tree search, symbol definitions/references, callers/callees, imports, and type hierarchies.
Provides code-exploration support for Rust, including outlines, syntax-tree search, symbol definitions/references, callers/callees, imports, type hierarchies, and re-export-aware graph relations.
Provides code-exploration support for Svelte files by reading their script blocks, including outlines, syntax-tree search, symbol lookups, and graph relations.
Provides code-exploration support for Swift, including outlines, syntax-tree search, symbol definitions/references, callers/callees, imports, and type hierarchies.
Provides code-exploration support for TypeScript, including outlines, ast-grep syntax-tree search, symbol definitions/references, callers/callees, imports, and re-export-aware graph relations.
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
Octofs: MCP Filesystem Server and Code Search
Filesystem MCP server and code navigation for AI assistants: file outlines, ast-grep style search, find references and call graphs, over the Model Context Protocol
Standalone Rust binary that serves filesystem and code-exploration tools over the Model Context Protocol (MCP). Built on rmcp 3.x, tokio, and axum.
Overview · Installation · Quick Start · Filesystem tools · Code exploration · Tools Reference · Docs · Architecture · Changelog · Contributing · Good first issues
MCP Registry: io.github.Muvon/octofs
Overview
Octofs is a single binary that gives an AI assistant two things over MCP: tools to read, search, edit and copy files, run shell commands and reach remote hosts over SSH, and tools to explore code — file outlines, syntax-tree search and a symbol tool that finds definitions, references, callers, callees, imports and type hierarchies. Code-navigation tools often need a separate indexing step, and an index can fall behind files edited by another program. Octofs computes the answers from the files on disk, using an in-memory table that is built on the first query and refreshed from file metadata on every call, so there is no indexing command and no database. Measured on a 12-core Linux box with a release build: a path query repeated in the same process took 3 ms (median) on tokio and 224 ms on the Linux kernel tree; a query stops after 800 ms or 600 parsed files, and a name too common to finish in that time gets a partial answer that a repeated query extends.
Related MCP server: mcp-file-manager
Filesystem tools
With these tools an assistant can work in a project without the user pasting files: it reads and searches the tree, edits files in ways that fail loudly instead of landing on the wrong line, and runs commands. The same file tools work on a remote host when a path is an ssh:// URL.
viewreads a file (whole, a line range, or several ranges) or several files in one call, lists a directory (gitignore-aware, with glob patterns), searches content (literal or regex, with context lines) and returns images up to 5 MB. For clients that report a context epoch, re-viewing a whole file returns only the hunks changed since.text_editcreates files, replaces exact text, deletes a file and undoes the last edits (up to 10 levels per file, kept in memory).batch_editapplies up to 50 insert and replace operations to one file atomically. Targets are line ids of the formN:hh(position plus a two-character content hash); a stale id fails with the current content and where it moved. An operation can copy lines from another file, or from the same file, instead of taking new text.shellruns a command on the local machine. A command still running after about 10 seconds continues in the background and a completion notification arrives when it exits. Reading, searching and listing withcat,grep,find,lsand similar programs run normally, and a numbered file line in the output (grep -n,rg -n,nl -ba,cat -n) comes back asN:hh|content, the line idviewgives.Transport is STDIO or Streamable HTTP. A non-loopback HTTP bind requires a bearer token.
Remote files use SSH/SFTP with your OpenSSH config.
shellalways runs locally. RSA keys are not supported (see Remote Filesystem).
Code exploration
With these tools an assistant can ask what a file declares, where a symbol is defined and used, who calls a function, what implements a type and which files import a file, and get line ids it can pass straight to batch_edit.
Outline.
viewwithflags: "s"lists the declarations of a file or a directory, bodies elided.Syntax-tree search.
viewwithast: truematches an ast-grep pattern such as$OBJ.unwrap()against the syntax tree instead of the text.Symbol lookups. The
symboltool takes arelation:definition(default),references,callers,callees,supertypes,subtypes,imports,imported_by, orpath(how one symbol reaches another).Search with context. In files that have a grammar, plain
viewcontent search labels each match with its enclosing symbol, for example[impl Store › fn flush].
The outline, syntax-tree search, definition and references also work over ssh://. One worked example per relation, how the in-memory table behaves and the full limits are in doc/code-exploration.md.
Supported languages
Rust, Python, JavaScript, TypeScript, Go, Java, C/C++, PHP, Bash, Ruby, Lua, JSON, Swift, Svelte, CSS, Elixir and Markdown. Support is not the same for every feature:
CSS and JSON have an outline but name no symbol for
symbollookups and cannot be syntax-tree searched.Markdown yields its headings for the outline and for
symbollookups, but cannot be syntax-tree searched and contributes nothing to the graph relations (callers,callees,supertypes,subtypes,imports,imported_by,path). JSON contributes nothing to them either.Svelte files are read through their
<script>blocks.Bash and Lua define no extends or implements extraction, so
supertypesandsubtypesfind nothing in them.
Limits
Results from the graph relations come from names and imports, not types: same-name symbols can be confused and dynamic calls missed. A
(guess)mark flags a hop matched by name alone.The graph relations are local only. They do not work over
ssh://, and they always search the whole session workdir;pathonly narrows which definitions ofnamestart the query.Files over 1 MB are skipped for the graph relations and named in a closing note.
viewand the text-levelsymbollookups keep a 5 MB limit.A query parses at most 600 files and runs at most 800 ms. When a name is spelled in more files than that, the answer covers the files examined, and a closing line says to repeat the query to examine the rest.
A name that is spelled in more than 3000 files needs a
pathor anOwner::nameform; without one it is not traced.A list shows at most 100 results, most certain first.
Re-exports are followed for
callers,calleesandpath(Python__init__.pyre-exports andimport *, JavaScript and TypeScriptexport ... from, up to 3 hops), for Rustpub use, for C and C++ headers that include another header, and for Swift@_exported import. Re-exports in the other languages are not followed.A call written with the path of its module or class resolves like an import of that path, with no import line in the calling file: Rust
crate::a::f(),super::f(),self::f()anda::b::f(), Javacom.acme.Util.run(), PHP\App\Models\User::find(), ElixirMyApp.Repo.get(id). A Rust path with a capitalised segment (Type::f()) and a PHP function called by namespace path are not resolved this way.A file that declares a name and also re-exports the same name leads to both, and a call to that name is listed under each.
Rust items inside a brace macro in item position (
cfg_rt! { ... }) count as items of the surrounding module, impl or trait when the macro body parses without errors and holds only items.A call to a name with several definitions in one file (a C function under
#ifdefand#else, for example) leads to each of them, marked(guess).In C and C++, code under preprocessor shapes the parser cannot read can hide a call, so an empty or "No path" answer covers only what the parser recognised.
The
pathrelation searches from both ends one level at a time within the same 600-file and 800 ms budget; a search that was cut says so and repeating the query continues it. "No path ... within depth N" appears only when the search finished.Import resolution does not read manifests (
Cargo.toml, therequirelines ofgo.mod,composer.json,pom.xml) or thepathsaliases oftsconfig.jsonandjsconfig.json; an aliased import counts as external.Ruby calls by a bare name into a required file are missed. In Elixir,
defdelegatecounts as a call.A Go import path with a dotted first segment is matched to a local directory by suffix; a path without a dot is looked up under the directory of each
go.mod, then in the standard library (src/<path>).Files of one directory form a package in Go and Swift; Java and PHP use the declared package or namespace. Calls to names in the same package resolve without an import.
A call on a receiver the tool cannot identify, such as
getRepo().save(), is resolved by name only and shown as(guess).The index holds at most 160 MB of data. If a workdir's index does not fit, graph relations say so and the index is built again after a minute or when another workdir releases memory. Peak resident memory in the benchmark was 280 to 370 MB on the Linux kernel tree, depending on machine load, and 37 MB on tokio; per-repository times and memory are in doc/code-exploration.md.
Installation
Cargo (crates.io)
cargo install octofsHomebrew
brew install muvon/tap/octofsnpm (no Rust toolchain needed)
npx -y @muvon/octofs --versionThe wrapper downloads the matching pre-built binary on first run. MCP config:
{
"mcpServers": {
"octofs": {
"command": "npx",
"args": ["-y", "@muvon/octofs", "mcp"]
}
}
}Pre-built Binaries
Download from GitHub Releases for your platform:
Platform | Target |
Linux (x86_64) |
|
Linux (ARM64) |
|
Windows (x86_64) |
|
Windows (ARM64) |
|
macOS (Intel) |
|
macOS (Apple Silicon) |
|
Each release also ships .mcpb bundles for one-click install in clients that support MCP bundles (e.g. Claude Desktop).
MCP Registry
Published to the MCP Registry as io.github.Muvon/octofs.
From Source
Requires Rust 1.95+.
git clone https://github.com/muvon/octofs
cd octofs
cargo build --release
# Binary at ./target/release/octofsQuick Start
Pair with Octocode
The shared-ID workflow requires the next Octocode release or a build of the updated source. OctoFS’s existing line-ID format is unchanged.
Use Octocode to find definitions, usages, and code relationships, then use OctoFS to read or edit the matching files. Octocode's MCP structural_search emits the same N:hh|content source line IDs that OctoFS accepts for batch_edit, using their shared Octolib utility. You do not need another view just to obtain IDs for lines already returned.
Run both servers against the same checkout. IDs describe that source snapshot: changed targets are verified at edit time, and an error supplies current context rather than guessing where to write. Exact-name lookups return complete small definitions; previews of larger matches name the ranges you can read with OctoFS.
1. Configure Your AI Assistant
The CLI uses a mcp subcommand — your config must pass ["mcp"] as args.
Claude Code (CLI):
claude mcp add octofs -- octofs mcp --path /path/to/your/project
claude mcp add octocode -- octocode mcp --path /path/to/your/projectCodex CLI:
codex mcp add octofs -- octofs mcp --path /path/to/your/project
codex mcp add octocode -- octocode mcp --path /path/to/your/project
codex mcp listThe Octocode registration is optional. Install the servers you use and replace the paths with the same absolute checkout path. See the official Codex MCP documentation.
Cursor (~/.cursor/mcp.json):
{
"mcpServers": {
"octofs": {
"command": "octofs",
"args": ["mcp"]
}
}
}Claude Desktop (~/Library/Application Support/Claude/claude_desktop_config.json on macOS):
{
"mcpServers": {
"octofs": {
"command": "octofs",
"args": ["mcp"]
}
}
}Windsurf (~/.windsurf/mcp.json):
{
"mcpServers": {
"octofs": {
"command": "octofs",
"args": ["mcp"]
}
}
}If Octofs isn't on your
PATH, use the full path to the binary (e.g./usr/local/bin/octofsor./target/release/octofs).
2. Restart Your AI Assistant
The MCP server starts automatically when your AI assistant connects.
3. Try It
Ask your AI assistant to:
"Show me the project structure"
"Read the main.rs file"
"Search for all uses of
unwrap()in the codebase""Create a new file called
test.rs""List what
src/main.rsdeclares""Who calls
flush, two levels up?""Which files import
src/util.rs?"
Configuration
Line Identifiers
Every line is addressed by a composite id N:hh — its 1-indexed position plus a
2-character hex hash (FNV-1a) of its content. Octocode structural-search source output uses the same shared utility and IDs. view renders lines as N:hh|content:
1:a3|fn main() {
2:f1| println!("Hello");
3:0e|}Edit tools take these ids back as targets and verify the hash against the file
before applying anything. A stale id (the file changed since it was viewed) fails
with the current content around the target and where the expected content moved —
so the model retargets from the error instead of re-reading the file. Edit results
are diffs with fresh ids, so edits chain without re-viewing. Removed lines collapse
to their old id range (-12:a3..15:f1 (4 lines)), and a trailing
shift: lines after 40:b2 +3 line says how original line numbers below each edit
moved, so ids the model still holds can be adjusted without a failed call.
This is the single line-id format — there is no mode switch. Plain line numbers
are still accepted where a position alone is safe: view ranges (negative counts
from the end) and the insert anchors 0 (file start) / -1 (append).
Shell Misuse Enforcement
Reading, searching and listing with the shell (cat, grep, rg, find, ls
and similar) run normally. A numbered line of a file in the output (grep -n,
rg -n, nl -ba, cat -n) comes back as N:hh|content, the line id view
gives, when a file named by the command or by the output (path:N:text, or a path
heading line above the numbered lines) holds exactly that text on that line, so it
can go straight into batch_edit. Lines without a number, and numbered text that
is not a file line (clock times, counts, compiler positions), stay as printed.
Octofs rejects only programs that cannot work in the shell: bare sleep (a
sleep inside a loop body is fine) and watch/top/htop. The call fails with
an error explaining what to use instead; nothing executes. Writing files with the
usual programs (sed -i, tee, redirects) runs normally. Edits made with the
shell are not in the undo history of text_edit: undo_edit covers only edits
made with the edit tools.
Other guidance (out-of-bounds ranges, fuzzy-match notices) is appended to successful responses as ⚠️ hints without failing the call.
Transport Modes
STDIO (default)
Standard input/output transport. Works with all MCP clients.
octofs mcpHTTP
Streamable HTTP transport for remote access or multi-client scenarios. Every tool, shell included, is reachable by whoever can connect, so access is gated:
# Loopback, no token: requests carrying a browser Origin header are rejected
octofs mcp --bind 127.0.0.1:12345
# Any other address requires a bearer token; octofs refuses to start without one
OCTOFS_AUTH_TOKEN="$(openssl rand -hex 32)" octofs mcp --bind 0.0.0.0:12345Connect clients to http://localhost:12345/mcp; with a token they send Authorization: Bearer <token>. The server speaks plain HTTP, so put it behind TLS or an SSH tunnel when the token crosses a network. --auth-token <TOKEN> works too, but command-line arguments are visible to other local users.
Working Directory
By default, Octofs operates in the current directory. Specify a different root:
{
"mcpServers": {
"octofs": {
"command": "octofs",
"args": ["mcp", "--path", "/path/to/your/project"]
}
}
}Remote Filesystem (SSH/SFTP)
All path parameters — and --path itself — accept ssh:// or sftp:// URLs:
# Remote session root: relative paths resolve on the remote host
octofs mcp --path ssh://deploy@example.com/var/www/app --ssh-key ~/.ssh/id_ed25519view path="ssh://deploy@example.com/etc/nginx/nginx.conf"Login home —
ssh://host(no path) andssh://host/~/dirresolve against the login user's home, likessh host/scp host:dir.ssh://host/dirstays absolute.OpenSSH config — host aliases are resolved through the local OpenSSH config (including
IncludeandMatch) and honorHostName,User,Port, and a singleProxyJump. Explicit URL values win, so bothssh://dev/pathandssh://user@example.com:2222/pathwork as expected. Multi-hopProxyJumpandProxyCommandrouting are rejected with a clear error.Authentication — uses the host's
IdentityAgent(e.g. 1Password) or$SSH_AUTH_SOCK, then key files —--ssh-keyif given, the host'sIdentityFileentries, then the defaults in~/.ssh(id_ed25519,id_ecdsa). Passphrase-protected key files are not supported directly; use an agent instead.RSA keys are not supported — the Rust
rsacrate has an unfixed timing side-channel (Marvin attack, RUSTSEC-2023-0071), so octofs is built without RSA entirely. Use an ed25519 key instead (ssh-keygen -t ed25519); ecdsa also works. RSA-only setups fail with a clear error naming the key.Host keys — verified against
~/.ssh/known_hostswith the OpenSSHaccept-newpolicy: unknown hosts are recorded on first use, a changed key fails closed.--ssh-timeout SECS— connection timeout (default 30). Connections are pooled per host, kept alive with transport keepalives, and reconnected automatically if they drop.shellstays local — commands always run on the machine where Octofs runs; only file tools (view,text_edit,batch_edit, andsymbolwithdefinition/references) reach remote hosts. The graph relations ofsymbolare local only.
MCP Tools Reference
view — Read files, list directories, search content
File reading: (path is one path, or several joined with |; start/end are line numbers or line ids)
{"path": "src/main.rs"} // whole file
{"path": "src/main.rs", "start": 10, "end": 20} // lines 10–20
{"path": "src/main.rs", "start": 42, "end": 42} // single line
{"path": "src/main.rs", "start": 80} // line 80 → end of file
{"path": "src/main.rs", "start": -20} // last 20 lines
{"path": "src/main.rs", "start": "12:a3", "end": "20:f1"} // line ids from prior output
{"path": "src/main.rs", "ranges": [{"start": 10, "end": 20}, {"start": 80, "end": 95}]} // several spans in one read
{"path": "src/a.rs|src/b.rs"} // several files in one call
{"path": "src/a.rs", "ranges": [{"start": 10, "end": 20}, {"path": "src/b.rs", "start": 80}]} // spans of several filesranges reads several spans in one call. Each span takes the same values as
start/end: a span without start begins at line 1, and one without end runs to
the last line. A span may name its own path to read from another file; without one
it reads the call's path. Spans of one file are sorted, overlapping or adjacent ones
are merged, and each gap shows as [... N lines omitted]. ranges cannot be combined
with start/end or content.
Output renders every line as N:hh|content — the N:hh prefix is the line id
that batch_edit takes as targets. Files with the extension .spill
(saved tool output) are shown as stored, without added ids.
To read several files in one call, join their paths with | (up to 32) or name the
file on each ranges span. Each file comes back as its own section, headed by its path.
The other parameters of the call (start/end, flags, full) apply to every path
of a | list, and a directory in the list is listed. A path that cannot be read is
reported in its section and the others are still returned; the call fails only when
none can be read. An image in the list is named and has to be viewed in a call of its
own. A read that would take the result past the size limit of one tool result is named
instead of returned.
Reuse content and line ids already returned. Read a complete relevant function or block
in one call, combining adjacent windows. If its location is unknown, use content with
enough context to understand the matches, then fetch only missing surrounding code.
Do not re-read overlapping ranges or repeatedly narrow a range just to pick edit targets.
Re-read when the file may have changed, output was truncated, or prior context is unavailable.
Empty files return [empty file, 0 lines] on an initial or forced full read.
Images: a path with a png, jpg/jpeg, gif or webp extension returns the
image itself as an MCP image block (up to 5 MB; the bytes must match the extension).
start/end and content do not apply to it.
Delta views: a whole-file view of a file the session already served returns
only the hunks changed since — the same .../-/+ style as edit results, with
removed lines collapsed to their old id range — or
[unchanged since you last viewed or edited it (compared with the file on disk just now): N lines. Pass full: true to re-read, or view a line range.].
Octofs' own edits keep the cache current, so a re-view after your own batch_edit
costs one line. Ranged views and content search always render exactly what was asked.
full has no effect on ranges or searches; omit start/end/ranges and content search
to force a complete file read. It does not change output limits.
{"path": "src/main.rs", "full": true} // force the complete file (e.g. after context compaction)Directory listing:
{"path": "src/"}
{"path": "src/", "pattern": "*.rs"}
{"path": "src/", "max_depth": 2, "include_hidden": true}A bare listing of a remote directory (ssh://host/path, no pattern/content)
defaults to max_depth: 1 — root entries only — because every subdirectory costs
an SFTP round trip; pass max_depth explicitly to walk deeper. Searches with
pattern or content always walk the whole tree, like rg.
pattern uses the same gitignore-style glob grammar as ripgrep's -g/--glob:
without / it matches filenames at any depth, while a pattern containing /
matches the returned relative path. It supports * within one path component,
** across directories, ?, character classes such as [abc], brace alternatives
such as *.{rs,toml}, and leading ! exclusions. Use | to pass ordered globs in
one MCP string; later globs take precedence:
{"path": ".", "pattern": "**/*.{rs,toml}|!target/**"}
{"path": ".", "content": "unsafe", "pattern": "src/**/*.rs|!src/generated/**"}The glob filters files discovered by Octofs' gitignore-aware traversal. Use
include_hidden: true to include hidden paths; gitignored paths remain excluded.
Patterns are limited to 4096 UTF-8 bytes, 64 |-separated rules, and 16 nested
brace levels. They must be a single line and are validated before traversal.
Escape a literal leading # or ! as \# or \!; otherwise # is rejected
instead of silently acting as a gitignore comment. Empty brace alternatives such
as {,rs} are rejected because ripgrep does not support them.
Content search: (literal by default; set regex: true for a Rust regex, (?i) = case-insensitive)
{"path": "src", "content": "fn main"}
{"path": "src", "content": "unwrap()", "context": 3}
{"path": "src", "content": "(?i)error", "regex": true}
{"path": "docs|scripts|BENCHMARK.md", "content": "update_benchmark.py", "context": 4}For an rg-style search across several roots, path accepts |-separated literal
files and directories when content is set. The roots are not regexes: as with
rg's positional path arguments, each one must exist. A real path containing |
takes precedence over this shorthand. Root lists must be single-line, contain no
duplicates, and are limited to 32 roots and 8192 UTF-8 bytes.
In the default line mode, matches in a file with a grammar are preceded by the
enclosing symbol (e.g. [impl Store › fn flush]), once per symbol change. The
compact modes (c, l, o), inverted searches and files without a grammar
render without them.
Structural outline: (flags: "s" — alone; no content, no start/end/ranges, no other flags)
{"path": "src/main.rs", "flags": "s"}
{"path": "src/", "flags": "s", "pattern": "**/*.rs", "max_depth": 2}Returns the declarations of a file — or of every supported file under a directory,
locally or over ssh:// — with their bodies elided. Each line keeps its N:hh id,
so the outline feeds batch_edit like any other view. Markdown files yield their
headings. A directory outline honours pattern, max_depth and include_hidden.
Supported languages: Rust, Python, JavaScript, TypeScript, Go, Java,
C/C++, PHP, Bash, Ruby, Lua, JSON, Swift, Svelte, CSS, Elixir, Markdown.
AST search: (ast: true — content holds the ast-grep pattern)
{"path": "src", "ast": true, "content": "fn $NAME($$$ARGS)"}
{"path": "src/main.rs", "ast": true, "content": "$OBJ.unwrap()"}Matches the pattern against the syntax tree instead of the text: $NAME matches one
node, $$$ARGS a sequence, $_ any single node. The pattern must be complete, valid
code in the target language — a Python pattern may omit the body together with
the colon (def $F($$$A)); a trailing colon without a body (def $F($$$A):)
matches nothing. It works on a file or a directory, locally or over
ssh://, and honours pattern, max_depth, include_hidden, context and the
c/l flags. It cannot be combined with regex, start/end/ranges or the
s/v/o flags. Zero matches return a diagnostic naming the parsed kind, the
metavariables and the plain-text fallback. CSS, JSON and Markdown files are not
AST-searchable.
Directory listings annotate each file as path<TAB>NL<TAB>~Nt (line count + estimated tokens) so you can budget reads before opening files; binary files show path<TAB>(binary).
symbol — Navigate code from a symbol name
{"name": "handle_*", "path": "src"} // definitions, `*` wildcards allowed
{"name": "flush", "path": "src/main.rs", "relation": "references"}
{"name": "flush", "path": "src", "flags": "c"} // hits per file
{"relation": "callers", "name": "flush", "depth": 2}
{"relation": "imported_by", "path": "src/util.rs"}
{"relation": "path", "name": "main", "to": "flush"}relation picks what comes back:
| Returns |
| The symbol's source, by name, in a file or under a directory ( |
| Every use of the name, grouped by enclosing symbol |
| Functions that call the symbol / functions it calls |
| Types it extends or implements / types that extend or implement it |
| What the file in |
| How |
definition and references work locally or over ssh://, render N:hh|content lines whose
ids feed batch_edit, and honour pattern, max_depth, include_hidden, context (references)
and flags (c counts per file, l lists files). An exact name renders the whole definition
when it is short enough; wildcard matches render a preview with the omitted range. The s, o,
v and r flags are rejected.
The graph relations (callers, callees, supertypes, subtypes, imports, imported_by,
path) are local only. They print one hop per line as path:line kind Owner::name, grouped
under depth N: (depth defaults to 1, path searches to 5, the maximum is 5), and are resolved
by name and imports, not types. Limits, the in-memory index and one worked example per relation:
doc/code-exploration.md.
text_edit — Create, edit, replace text
Create file:
{"command": "create", "path": "src/new.rs", "content": "pub fn new() {}"}Replace string: (old_text must match exactly once)
{
"command": "str_replace",
"path": "src/main.rs",
"old_text": "fn old()",
"new_text": "fn new()"
}Replace ALL occurrences (rename-style edits):
{
"command": "str_replace",
"path": "src/main.rs",
"old_text": "old_name",
"new_text": "new_name",
"replace_all": true
}Several replacements, possibly in several files (edits apply in order, atomically across files; each path defaults to the call's path):
{
"command": "str_replace",
"path": "src/main.rs",
"edits": [
{"old_text": "fn old()", "new_text": "fn new()"},
{"path": "src/lib.rs", "old_text": "old()", "new_text": "new()", "replace_all": true}
]
}Matching is progressive: exact → escaped-literal recovery (double-escaped \n/\t
interpreted when the result matches uniquely) → whitespace-normalized fuzzy with
indentation adjustment → rich diagnostics with the closest candidates and their
line ids. CRLF files are matched in LF space and keep their line endings on write.
Delete file: (recoverable with undo_edit)
{"command": "delete", "path": "src/old.rs"}Undo last edit:
{"command": "undo_edit", "path": "src/main.rs"}Check after the edit: text_edit and batch_edit accept an optional check, a shell command (for example the test that covers the change) that runs after the edit is written and whose output follows the edit result. It needs the shell tool: a client that filters shell out of a session's tools sets experimental.session.shell to false in its client capabilities, and octofs then hides check from the edit tools and rejects it before writing anything. A missing field or any other value keeps check available.
batch_edit — Atomic multi-operation edits
Perform multiple insert/replace operations on a single file atomically.
Give only the new lines. If the first or last line of a replacement repeats the line just
before or after its range, that line is dropped, the edit is applied and a note in the result
says so. A lone closing bracket (}, ], )) or a blank line is kept, since those repeat
legitimately. Content that is nothing but the repeat fails the call.
Each operation has a start. For replace it's the first line of the range as a
line id copied from view output (add end for a range; omit it for a single
line). For insert it's the anchor to insert after — a line id, or the integers
0 (file start) / -1 (after last line). Every id is verified against the file
before anything applies; a stale id fails with the current content so the model
can retarget without a re-view. The result is a diff with fresh ids.
Insert at beginning:
{
"path": "src/main.rs",
"operations": [
{"operation": "insert", "start": 0, "content": "// Header\n"}
]
}Replace lines:
{
"path": "src/main.rs",
"operations": [
{"operation": "replace", "start": "10:4b", "end": "15:c2", "content": "new code here"}
]
}Copy lines from another file:
{
"path": "src/new.rs",
"operations": [
{"operation": "insert", "start": -1, "copy_from": {"path": "src/utils.rs", "start": 10, "end": 25}}
]
}copy_from replaces content in an insert or replace operation; give exactly one of the two. start and end are line ids ("12:a3", verified against the source) or integers (negative counts from the end); end defaults to start. The source can be another file or the edited file. A same-file source is read as it was before the call, so moving lines inside a file is one call: insert the copy and replace the old range with "". If the target file does not exist, it is created (with its folders) only when every operation is a copy_from insert at 0 or -1; any other edit of a missing file fails with "File not found". Copied lines are not checked for duplicates.
shell — Execute commands
Commands start in the foreground and return their output normally when they finish within about 10 seconds:
{"command": "cargo test"}
{"command": "cd foo && cargo build"}If a command is still running at that boundary, the same process continues in
the background. The response returns its PID and linked output resource, and a
completion notification arrives when it exits. There is no background flag
and the command is never killed or restarted during the handoff. Multiple
distinct commands may run concurrently, including from the same working
directory. An exact duplicate command in the same working directory is rejected
while the first copy is still running.
A client that declares the MCP tasks extension (io.modelcontextprotocol/tasks,
SEP-2663) gets the promoted command as a task whose id is the job id. The client
polls tasks/get and receives the same result a foreground call would have
returned (an error result led by the exit code when the command failed);
tasks/cancel stops the command's process group. While the command runs, the
task's status message names its PID and kill command (kill -- -<pid>), the
elapsed time, and its latest output line.
Other clients get the completion as resources/updated for the job resource (on
a subscriptions/listen stream when the client opened one). Claude Code does not
surface that to the model, so octofs also sends it as a Claude Code channel
message (notifications/claude/channel) on pre-2026-07-28 connections — the
exit code and output tail wake the session. Claude Code accepts channel
messages only from servers enabled for the session, in interactive mode, and
only on pre-2026-07-28 connections. Claude Code negotiates 2026-07-28 with stdio
servers by default, so until it declares the tasks extension, opt out of that as
well:
MCP_PROTOCOL_NEGOTIATION=legacy claude --dangerously-load-development-channels server:octofsWithout it, read the job's resource link when you need the result.
On Windows, shutdown cleanup terminates only direct child processes (no Unix process-group semantics); use
taskkill /PID <pid> /Tfor process trees.
Architecture
octofs/
├── src/
│ ├── main.rs # Entry point, STDIO/HTTP server setup, signal handling
│ ├── cli.rs # CLI argument parsing (clap): octofs mcp [OPTIONS]
│ ├── mcp/
│ │ ├── mod.rs # McpToolCall, SessionRoot
│ │ ├── server.rs # OctofsServer (rmcp tool impl), Params structs, per-session state
│ │ ├── request_ctx.rs # Per-request hint queue + stale-file stamps
│ │ └── fs/ # Filesystem tool implementations
│ │ ├── mod.rs # Re-exports
│ │ ├── core.rs # view, text_edit, batch_edit
│ │ ├── file_ops.rs # view_file_spec, create_file_spec
│ │ ├── text_editing.rs # str_replace, batch_edit, undo, per-file locking
│ │ ├── directory.rs # Directory listing + content search
│ │ ├── search.rs # literal/regex matcher, symbol breadcrumbs
│ │ ├── structure.rs # Structural outline mode (flags: "s")
│ │ │ ├── symbols.rs # `symbol` tool: definitions, references, parameter validation
│ │ │ ├── code_index.rs # Per-workdir in-memory code index: name filters, parsed-file cache
│ │ │ ├── graph_scoped.rs # `symbol` graph relations answered on the code index
│ │ │ ├── graph.rs # `symbol` graph relations: parameters, rendering
│ │ ├── ast.rs # AST-pattern search mode (ast: true)
│ │ ├── shell.rs # Command execution, background, process cleanup
│ │ ├── remote.rs # SSH/SFTP path abstraction, SshHandler, SFTP pool
│ │ └── fs_tests.rs # Integration tests (cfg(test))
│ ├── structural/ # Tree-sitter grammars: outline, symbols, AST search
│ │ ├── mod.rs # Outline entry point, extension → language map
│ │ ├── signature_extractor.rs # Signature spans, Markdown headings
│ │ ├── symbols.rs # Definitions, references, symbol breadcrumbs
│ │ ├── graph/ # Code graph: files, symbols, calls, imports, extends, implements (no I/O)
│ │ ├── ast_search.rs # ast-grep pattern search over the grammars
│ │ └── languages/ # One grammar + outline rules per language
│ └── utils/
│ ├── mod.rs # Module re-exports
│ ├── line_hash.rs # Composite line ids (N:hh), FNV-1a hashes, endpoint parsing
│ └── truncation.rs # Token estimation, smart truncationKey design decisions:
rmcp SDK — Official Rust MCP SDK (
rmcp3.x) for protocol handlingTokio — Async runtime; all file I/O uses
tokio::fs, never blockingstd::fsFile locking — Per-file
tokio::sync::Mutexprevents concurrent write conflictsUndo history — Up to 10 snapshots per file, in-memory (lost on restart)
Path resolution — Relative paths resolve against the session workdir; no canonicalization (files may not exist yet)
Stale-write detection — every edit target's
N:hhid is verified against the file at apply time; a stale id fails with the current content instead of editing the wrong lineCode index in memory — code-exploration answers are computed from the files on disk with an in-memory table refreshed from file metadata on every call; nothing is written to disk (see doc/code-exploration.md)
Development
# Build
cargo build --release
# Run tests
cargo test
# Lint (zero warnings policy)
cargo clippy
# Format
cargo fmt
# Run locally
cargo run -- mcpRunning Tests
# All tests
cargo test
# Specific test
cargo test test_view_file
# With output
cargo test -- --nocaptureContributing
We welcome contributions! Please see CONTRIBUTING.md for guidelines.
Quick checklist:
Run
cargo fmtbefore committingEnsure
cargo clippypasses with zero warningsAdd tests for new functionality
Update documentation as needed
Security
See SECURITY.md for security policy and reporting vulnerabilities.
License
Apache-2.0 — See LICENSE
Acknowledgments
rmcp — Official Rust MCP SDK
Model Context Protocol — The protocol specification
Built by Muvon
Star the project on GitHub if Octofs is useful to you.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
Nifty's MCP server — exposes tasks, projects, messages, and files as tools for AI agents.
Persistent file storage for AI agents. Save files over MCP, get a link a human can open.
Agent-native MCP server over the public saagarpatel.dev corpus. Read-only, stateless.
Remote MCP server exposing your Node Command fleet (files, shell, processes, browser) to AI hosts.
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceA powerful filesystem MCP server for AI agents with extensive system access, including filesystem operations, shell execution, Windows tools, reverse engineering, code intelligence, and agent orchestration.1-
- AlicenseNot gradedqualityCmaintenanceAn MCP server that gives AI agents file system access: read, write, search, hash, directory trees — 12 tools, zero dependencies, pure Python stdlib.MIT
- FlicenseAqualityDmaintenanceAn MCP server that exposes filesystem operations — listing directories, reading, writing, and searching files — as tools an LLM can discover and invoke at runtime.4-
- FlicenseNot gradedqualityCmaintenanceUltra-fast, memory-efficient Rust implementation of the Filesystem MCP server with bounded IO, regex search, and optional terminal execution.8-
Appeared in Searches
- A server for accessing or managing a filesystem
- What is a filesystem server and how to find one? A filesystem server implements a protocol like 9P, NFS, or SMB to serve files to clients. Search GitHub for 'filesystem server', look at projects such as pyd-fuse servers, Go-based go-fuse servers, Rust 'fuser' servers, or Python 'mux9p'. The query 'filesystem server' commonly refers to the Model Context Protocol (MCP) filesystem server, an open-source reference implementation (e.g., from the modelcontextprotocol/servers repository) that exposes local files to AI assistants.