
Virtual Filesystem
io.github.lu-zhengda由 GitHub 账号 lu-zhengda 发布v0.2.2更新于 Oct 24, 2026
PostgreSQL-backed virtual filesystem for agents: session isolation, shared stores, POSIX ops, RLS.
概览
一个由 PostgreSQL 支撑的虚拟文件系统,为 AI 助手提供持久、按会话隔离的文件存储,以及 POSIX 风格的读写与搜索工具。
- 可以做什么
- 读取、写入和追加文件,并用 stat 查看元数据或文件是否存在;文件存放在 PostgreSQL 中而非宿主机磁盘。用 ls、mkdir、mv 和 rm 管理目录结构,支持递归删除目录和自动创建父目录。按 glob 模式查找文件,按正则搜索文件内容,由 PostgreSQL trigram 索引支持。列出并使用命名的跨会话存储,在多个智能体之间共享数据或作为长期记忆。
- 适用场景
- 适合需要持久工作区的场景,数据在进程重启、容器回收或重新部署后仍然保留;也适合多个智能体通过命名存储共享文件。还适用于不希望智能体接触宿主机文件系统的沙箱式文件操作。
- 运行要求
- 通过 npm 包以 stdio 在本地运行,需要 Node.js 20 或更高版本,以及带 pg_trgm 扩展的 PostgreSQL 14 或更高版本。必须提供 DATABASE_URL 连接字符串;VFS_AUTO_INIT、VFS_SESSION_ID 和 VFS_ENABLE_RLS 为可选项。启用可选的 RLS 需要执行 SQL 脚本并配置专用数据库角色。
安装
在 SourceWeft 中
- 打开 控制台中的 Virtual Filesystem,将其添加到工作区。
- 为需要使用其工具的对话启用该服务。
Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。
其他 MCP 客户端
参照 仓库 中的启动说明。
README
mcp-virtual-fs
[npm version] [CI] [npm downloads] [License: MIT] [Node.js]
An MCP server that provides AI agents with a persistent, PostgreSQL-backed virtual filesystem. Supports session-isolated file operations, cross-session shared stores, glob/grep search, and Row Level Security — all exposed as standard Model Context Protocol tools.
Works with any MCP client: Claude Desktop, Claude Code, Cursor, Windsurf, Cline, and others.
Features
- Persistent file storage — files are stored in PostgreSQL and survive process restarts, container recycling, and redeployments
- Session isolation — each agent session gets its own namespace automatically, no configuration needed
- Cross-session stores — named persistent stores for sharing data between agents or for long-term agent memory
- 11 POSIX-style tools —
read,write,append,stat,ls,mkdir,rm,mv,glob,grep,stores - Glob and grep search — find files by pattern (
**/*.ts) or search content by regex, powered by PostgreSQL trigram indexes - Row Level Security — optional database-enforced isolation between sessions for multi-tenant deployments
- Zero config — auto-creates tables on first run with
VFS_AUTO_INIT=true
Use Cases
- Agent scratchpad — give LLM agents a persistent workspace to read/write files across tool calls
- Long-term agent memory — store notes, context, and knowledge across sessions using named stores
- Multi-agent collaboration — multiple agents share files through cross-session stores
- Sandboxed file operations — agents interact with a virtual filesystem instead of the host OS
- CI/CD artifact storage — persist build outputs, logs, and reports in a queryable filesystem
Why
Agents work well with filesystems for context management, but coupling storage to the agent runtime means data is lost when pods restart or containers are recycled. This MCP server decouples storage from runtime by moving file operations to PostgreSQL — giving agents persistent, isolated, and searchable file storage without touching the host filesystem.
Prerequisites
- Node.js 20 or later
- PostgreSQL 14 or later (with
pg_trgmextension — included in most distributions)
Quick Start
1. Set up PostgreSQL
2. Configure your MCP client
Add to your MCP client config (e.g., Claude Desktop claude_desktop_config.json or Claude Code .mcp.json):
That's it. VFS_AUTO_INIT=true creates the tables on first run.
3. Use the tools
Tool names are short POSIX-style names:
All tools return structured JSON responses.
Tools
All tools (except stores) accept an optional store parameter for cross-session persistent storage.
Session Management
Sessions are handled automatically — no session ID in tool parameters.
How it works:
Priority: transport sessionId > VFS_SESSION_ID env var > auto-generated UUID.
Resumable sessions
To resume a previous session across process restarts, set a deterministic session ID:
Cross-Session Stores
Named stores persist across sessions. Any session can read/write to a store by passing the store parameter:
Stores are auto-created on first use.
Environment Variables
Manual Database Setup
If you prefer to manage the schema yourself instead of using VFS_AUTO_INIT:
Row Level Security (optional)
RLS provides database-enforced session isolation. Even if application code has a bug that omits a WHERE session_id = clause, PostgreSQL itself prevents cross-session access.
Then configure the MCP server to connect as vfs_app:
Development
Requirements
- Node.js 20+
- Docker (for integration tests — runs PostgreSQL via testcontainers)
Commands
Testing
Tests use testcontainers to spin up real PostgreSQL instances in Docker. No mocks — the integration tests exercise actual SQL queries, trigram indexes, and RLS policies.
Session Cleanup
Ephemeral sessions can be cleaned up periodically:
The ON DELETE CASCADE on vfs_nodes handles file cleanup automatically. Persistent stores (created via the store parameter) are never affected.
License
MIT
来源:README.md,提交 cfc45ed
工具
0版本历史
1- v0.2.2最新Sep 16, 2026
评分
已满足适用检查项的 50%
该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。
- 近 30 天内可连通25 分
请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。
- 已声明认证方式10 分
请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。
- 已列出工具15 分
请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。
- 描述必需15 分
- 图标10 分
- 文档15 分
- 许可证10 分