Virtual Filesystem

v0.2.2
io.github.lu-zhengda/virtual-fs Checked 2 days ago Published 9 months ago

PostgreSQL-backed virtual filesystem for agents: session isolation, shared stores, POSIX ops, RLS.

These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.

read

Read the contents of a file. Returns the file content and size in bytes. Errors: ENOENT if the file does not exist, EISDIR if the path is a directory.

ParameterTypeDescription
path *stringAbsolute path to the file (e.g. /src/index.ts)
storestringNamed persistent store for cross-session access. Sessions are ephemeral (one per MCP connection); named stores persist indefinitely. Omit to use the session's own namespace.

write

Write content to a file, creating it if it doesn't exist. Parent directories are created automatically (mkdir -p). Overwrites existing file content entirely. Errors: EISDIR if the path is an existing directory, EINVAL if writing to root.

ParameterTypeDescription
content *stringFull content to write (max 10 MB per call)
path *stringAbsolute path to the file (e.g. /notes/todo.md)
storestringNamed persistent store for cross-session access. Sessions are ephemeral (one per MCP connection); named stores persist indefinitely. Omit to use the session's own namespace.

append

Append content to the end of a file. Creates the file if it doesn't exist. Parent directories are created automatically. Useful for logs or incrementally building files. The 10 MB limit is per call — total file size is not capped. Errors: EISDIR if the path is an existing directory, EINVAL if appending to root.

ParameterTypeDescription
content *stringContent to append (max 10 MB per call)
path *stringAbsolute path to the file to append to
storestringNamed persistent store for cross-session access. Sessions are ephemeral (one per MCP connection); named stores persist indefinitely. Omit to use the session's own namespace.

stat

Check whether a path exists and get metadata about it. Returns exists (boolean), and if it exists: type (file or directory), size (bytes, for files), or children count (for directories). Never errors — returns {exists: false} for missing paths.

ParameterTypeDescription
path *stringAbsolute path to check
storestringNamed persistent store for cross-session access. Sessions are ephemeral (one per MCP connection); named stores persist indefinitely. Omit to use the session's own namespace.

ls

List the contents of a directory. Returns an array of entries, each with a name and type (file or directory). Entries are sorted with directories first, then alphabetically. Errors: ENOENT if the directory does not exist, ENOTDIR if the path is a file.

ParameterTypeDescription
path *stringAbsolute path to the directory to list (e.g. / or /src)
storestringNamed persistent store for cross-session access. Sessions are ephemeral (one per MCP connection); named stores persist indefinitely. Omit to use the session's own namespace.

mkdir

Create a directory and any missing parent directories (mkdir -p behavior). Idempotent — succeeds even if the directory already exists. Returns whether the directory already existed. Errors: EEXIST if a file (not directory) already exists at the path.

ParameterTypeDescription
path *stringAbsolute path of the directory to create (e.g. /src/utils)
storestringNamed persistent store for cross-session access. Sessions are ephemeral (one per MCP connection); named stores persist indefinitely. Omit to use the session's own namespace.

rm

Remove a file or directory. Directories are removed recursively including all descendants. This operation is non-recoverable — there is no undo or trash. Returns the total number of nodes deleted. Errors: ENOENT if the path does not exist, EINVAL if attempting to remove root.

ParameterTypeDescription
path *stringAbsolute path to remove
storestringNamed persistent store for cross-session access. Sessions are ephemeral (one per MCP connection); named stores persist indefinitely. Omit to use the session's own namespace.

mv

Move or rename a file or directory. Moves all descendants when moving a directory. Parent directories at the destination are created automatically. Errors: ENOENT if source doesn't exist, EEXIST if destination already exists, EINVAL if moving root or moving a directory into itself.

ParameterTypeDescription
destination *stringAbsolute path of the new location
source *stringAbsolute path of the file or directory to move
storestringNamed persistent store for cross-session access. Sessions are ephemeral (one per MCP connection); named stores persist indefinitely. Omit to use the session's own namespace.

glob

Find files matching a glob pattern. Supports wildcards (*.ts), recursive matching (**/*.md), and brace expansion ({py,json}). Returns an array of matching file paths. Only matches files, not directories.

ParameterTypeDescription
pattern *stringGlob pattern (e.g. **/*.ts, /src/**/*.{js,ts})
storestringNamed persistent store for cross-session access. Sessions are ephemeral (one per MCP connection); named stores persist indefinitely. Omit to use the session's own namespace.

grep

Search file contents using a regular expression. Returns matching lines with file path and line number. Optimized for fast content search across all files. Optionally filter which files to search with a path glob.

ParameterTypeDescription
pattern *stringRegular expression pattern to search for (e.g. TODO|FIXME)
path_filterstringGlob pattern to limit which files are searched (e.g. /src/**)
storestringNamed persistent store for cross-session access. Sessions are ephemeral (one per MCP connection); named stores persist indefinitely. Omit to use the session's own namespace.

stores

List all named persistent stores. Stores are cross-session namespaces for long-term data that persists indefinitely. Returns an array of store names.