
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 分