Vfs 标志

Vfs

社区
TrNgTien

Reduce AI agent token usage by 98% via Virtual Function Signatures. MCP server for Cursor & Claude Desktop. Supports Go, TypeScript, Python, Rust, Java, Swift, Kotlin, C# and more.

发布者TrNgTien
代码仓库vfs
语言C
复刻数
26
星标数
143
可用工具
0
传输类型stdio, streamable-http
分类
许可协议MIT
链接
  • 将工具接入 AI 工作流

    Vfs 提供 MCP 功能,可供兼容的 AI 客户端和智能体使用。

  • 0 个可用工具

    浏览下方可调用的操作;如果服务器提供了名称和描述,也会一并显示。

  • 可直接复制的配置

    使用安装配置片段,在您首选的 MCP 客户端中配置此服务器。

  • 开源社区热度

    关联的代码仓库有 143 个 Star 和 26 个 Fork。

vfs

Extract exported function signatures with bodies stripped -- cutting 60-70% of the tokens your AI agent reads on every code search.

CI Release License: MIT

Install • Quick Start • Commands • Setup for AI Tools • Supported Languages • Security & Privacy


vfs parses source files via AST and tree-sitter and returns only exported signatures -- a compact "table of contents" of any codebase. One command (or one MCP call) replaces grep-and-read-everything with exact file:line pointers. Single Go binary, zero network access, works with any AI tool.

What VFS Does

Instead ofvfs returns
grep -r "HandleLogin" . → 345 lines of matches21 signature lines
Reading 7,979 lines to find one functionauth.go:23: func HandleLogin(w http.ResponseWriter, r *http.Request)
~48,757 tokens of context~570 tokens

How Savings Work

vfs measures bytes of source that reach the model, estimated as bytes / 4. Bodies are stripped at parse time, so a function that costs 50 lines of context costs one line. The savings are real but the absolute token numbers are approximate -- vfs ships no tokenizer.

On this repository (vfs bench --self, pattern "Extract"):

Read all filesgrepvfs
Output size190.5 KB47.5 KB2.2 KB
Lines7,97934521
Est. tokens48,75712,154570
  • 98.8% fewer tokens vs reading all files (48,757 → 570)
  • 95.3% fewer tokens vs grep (12,154 → 570)

These are reductions in context tokens, not in your bill -- but for a tool your agent runs on every search, they add up fast.

Installation

Pre-built binary (Linux -- nothing else needed)

bash
# x86_64
curl -L https://github.com/TrNgTien/vfs/releases/latest/download/vfs-linux-amd64.tar.gz | tar xz
sudo mv vfs /usr/local/bin/

# ARM64
curl -L https://github.com/TrNgTien/vfs/releases/latest/download/vfs-linux-arm64.tar.gz | tar xz
sudo mv vfs /usr/local/bin/

Build from source (macOS / Linux / Windows)

Requires Go 1.24+ and a C compiler (tree-sitter C bindings):

OSCommand
macOSxcode-select --install
Linux (Debian/Ubuntu)sudo apt install build-essential
Linux (Fedora/RHEL)sudo yum groupinstall "Development Tools"
WindowsInstall TDM-GCC (easiest) or MSYS2 + MinGW-w64
bash
git clone https://github.com/TrNgTien/vfs.git && cd vfs
go install ./cmd/vfs

vfs: command not found after install? Add Go's bin to PATH: export PATH="$PATH:$(go env GOPATH)/bin" (macOS/Linux) or add %USERPROFILE%\go\bin to PATH (Windows).

Docker (any OS)

bash
docker build -t vfs-mcp .
docker run --rm -v $(pwd):/workspace -p 8080:8080 -p 3000:3000 vfs-mcp

# Custom ports via environment variables
docker run --rm -v $(pwd):/workspace -e VFS_PORT=9090 -e VFS_DASHBOARD_PORT=4000 -p 9090:9090 -p 4000:4000 vfs-mcp

Verify Installation

bash
vfs . -f HandleLogin   # Should show signatures, not an error
vfs bench --self       # Should show the savings table

Quick Start

bash
# Find a function by name (case-insensitive)
vfs . -f HandleLogin

# List all signatures in a directory or file
vfs ./internal ./pkg
vfs server.go

# Show token savings after output
vfs . -f auth --stats

# Start the MCP server + dashboard (detached)
vfs up
# Check / stop it
vfs status
vfs down

Then open the dashboard at http://localhost:3000 for usage stats over time.

How It Works

  Without vfs:                                    With vfs:

  Agent  --grep "HandleLogin"-->  shell          Agent  --vfs search-->  vfs (AST)
    ^                                |             ^                          |
    |        345 lines of matches    |             |   2 sigs, ~570 tokens     |
    +--------------------------------+             +--- file:line + signature -+

Four properties make the savings work:

  1. AST parsing - understands structure, not just text. Finds class User, type User struct, func (u *User) Login, not just string matches.
  2. Bodies stripped - you get the signature, not the 50 lines underneath it.
  3. Case-insensitive filter - one search finds fare, Fare, and FARE.
  4. Token accounting - every invocation is measured and reported (--stats, vfs stats, dashboard).

The companion rule in this repo (.cursor/rules/vfs-agent-search.mdc) teaches agents when to use vfs (locate/understand/modify) vs grep (debug, string literals, callers) -- see Setup for AI Tools.

Commands

Search

bash
vfs .                        # All exported signatures (recursive)
vfs ./src ./lib              # Multiple directories
vfs handler.go               # Single file
vfs . -f auth                # Case-insensitive filter
vfs . -f auth --stats        # + token savings report
vfs . -f auth --no-record    # Skip history logging

Benchmarks

bash
vfs bench --self                            # Self-test on vfs source
vfs bench -f HandleLogin /path/to/project    # Benchmark any project
vfs bench -f Login /path --show-output       # Show actual grep/vfs output

Statistics

bash
vfs stats                   # Lifetime token savings
vfs stats --json            # JSON export for dashboards/CI
vfs stats --reset           # Clear all history

MCP Server

bash
vfs mcp                     # stdio transport (default, editor integration)
vfs mcp --http :8080        # HTTP transport (Docker / remote)
vfs serve                   # MCP + dashboard, foreground
vfs serve --port 9090 --dashboard-port 4000   # custom ports
vfs up                      # Same, detached (background)
vfs status                  # Is it running? show endpoints
vfs down                    # Stop the detached server
vfs dashboard               # Dashboard UI only

MCP tools exposed: search, extract, list_languages.

Global Flags

FlagDescription
-f, --filterCase-insensitive substring filter on signature names
--statsPrint token savings (raw vs vfs) to stderr
--no-recordSkip logging this invocation to ~/.vfs/history.jsonl
--versionShow version, commit, and build date

Examples

"Where is the login handler?"

# Without vfs: grep + read
grep -r "HandleLogin" .            # 345 lines of matches
cat auth.go                        # then read the whole file

# With vfs
vfs . -f login
  → internal/handlers/auth.go:23:   func HandleLogin(w http.ResponseWriter, r *http.Request)
  → internal/services/auth.go:10:   func ValidateToken(token string) (*Claims, error)
  → internal/middleware/jwt.go:45:  func RequireLogin(next http.Handler) http.Handler

Multi-language project:

vfs . -f user
  → internal/services/user.go:42:     func CreateUser(name string, email string) (*User, error)
  → src/hooks/useUser.ts:8:           export function useUser(id: string): UserState
  → app/models/user.py:15:            class User(BaseModel)
  → src/api/UserService.java:22:      public class UserService
  → contracts/UserRegistry.sol:10:    contract UserRegistry is Ownable { ... }

When grep IS the right tool -- vfs finds definitions, not bodies, callers, or config keys:

grep "INVALID_API_KEY" ./internal/     # string literal inside a function body
grep "database_url" ./*.yaml           # non-code file
grep "CalculateFare" ./internal/       # who CALLS it (vfs finds the definition)

Setup for AI Tools

Two steps -- both required:

  1. Connect vfs -- make it reachable from the agent (MCP preferred, CLI fallback).
  2. Add an agent rule -- tell the agent it should call vfs before grep. Without the rule, the agent ignores vfs even when installed.

Step 1: Connect vfs

MethodHow it worksBest for
MCP (recommended)Agent calls search / extract / list_languages directlyEditors with MCP support (most modern AI tools)
CLIAgent runs vfs <path> -f <pattern> via shellTerminal tools, scripts, sandboxed-free environments

Stdio config (Cursor, Claude Code, Claude Desktop, Antigravity, Windsurf, Cline):

json
{
  "mcpServers": {
    "vfs": {
      "command": "vfs",
      "args": ["mcp"]
    }
  }
}

Claude Code (preferred): claude mcp add vfs -- vfs mcp -- registers in ~/.claude.json.

Continue:

json
{
  "experimental": {
    "modelContextProtocolServers": [
      { "transport": { "type": "stdio", "command": "vfs", "args": ["mcp"] } }
    ]
  }
}

Zed:

json
{
  "context_servers": {
    "vfs": { "command": { "path": "vfs", "args": ["mcp"] } }
  }
}

HTTP config (Docker, remote, or tools that prefer HTTP):

bash
vfs up        # MCP on :8080, dashboard on :3000
vfs up --port 9090
json
{
  "mcpServers": { "vfs": { "url": "http://localhost:8080/mcp" } }
}

Step 2: Add an agent rule (required)

Installing vfs is not enough -- agents don't know it exists. This repo ships a production-ready rule at .cursor/rules/vfs-agent-search.mdc, and a one-command installer to put it into your tool:

bash
./scripts/install-rules.sh                   # auto-detect your AI tool
./scripts/install-rules.sh --agent cursor    # install for one tool
./scripts/install-rules.sh --agent all       # every tool
./scripts/install-rules.sh --project ../myapp --agent claude   # another project
./scripts/install-rules.sh --list            # supported tools + paths

Same via Make: make rules or make rules RULES_ARGS="--agent windsurf --project ../myapp".

The installer is idempotent and safe: plain-markdown tools (Claude Code, Cline, Aider, Antigravity) get the rule appended under a ## vfs: heading -- your existing config is never overwritten -- while frontmatter tools (Cursor, Windsurf, Continue, OpenCode) get a verbatim copy.

ToolRule fileNotes
Cursor.cursor/rules/vfs.mdcCopy of .mdc (frontmatter kept)
Claude CodeCLAUDE.mdAppended, frontmatter stripped
AntigravityGEMINI.mdAppended, frontmatter stripped; also reads AGENTS.md
Windsurf.windsurf/rules/vfs.mdCopy of .mdc
Cline / Roo Code.clinerulesAppended, frontmatter stripped
Continue.continue/rules/vfs.mdCopy of .mdc
Aider.aider.conventions.mdAppended, frontmatter stripped
OpenCode.opencode/rules/vfs.mdcCopy of .mdc

Without the rule, this is what happens:

You: "Where is the login handler?"

❌ No rule:   Agent greps + reads → 345 lines → 12,000+ tokens
✅ With rule: Agent calls vfs → reads 23 lines → ~570 tokens

Supported Languages

LanguageExtensionsParser
Go.gogo/ast
JavaScript.js, .mjs, .cjs, .jsxtree-sitter
TypeScript.ts, .mts, .cts, .tsxtree-sitter
Python.pytree-sitter
Rust.rstree-sitter
Java.javatree-sitter
C#.cstree-sitter
Dart.darttree-sitter
Kotlin.kt, .ktstree-sitter
Swift.swifttree-sitter
Ruby.rbtree-sitter
Solidity.soltree-sitter
HCL / Terraform.tf, .hcltree-sitter
DockerfileDockerfile, Dockerfile.*line-based
Protobuf.protoline-based
SQL.sqlline-based
YAML.yml, .yamlline-based

Security & Privacy

vfs is local-only and offline.

PropertyDetail
Zero network accessAll parsing is local. No outbound connections, ever
No secrets exposureDoes not read or store API keys, credentials, or environment variables
No data collectionNo telemetry, no analytics, no tracking
No code storageSource is parsed in memory and discarded. Only ~/.vfs/history.jsonl (scan statistics) is written

Configuration

There is no config file -- vfs is zero-config. The only state it keeps is scan history for stats and the dashboard:

FilePurpose
~/.vfs/history.jsonlOne line per invocation (paths, filter, bytes, tokens saved)
~/.vfs/vfs.stateRunning server PID + endpoints (used by up/down/status)

Clear it anytime with vfs stats --reset.

Contributing

Contributions welcome! See CONTRIBUTING.md for guidelines. When you add a language, update the supported-languages tables in AGENTS.md and README.md.

Releases are automated via .github/workflows/release.yml -- see scripts/release.sh.

Used By

Using vfs in your project or company? Submit a PR to be listed here.

LogoNameWebsiteUse CaseBlog
(img url)(Company/Project Name)Website(Use Case Description)Read

How to Add Your Use Case

  1. Fork this repo and create a branch: usecase/<your-company-or-project>
  2. Add one row to the table above (logo, name, website, one-line use case, optional blog).
  3. Open a pull request titled usecase: add <Company/Project>.

No proprietary details needed -- a high-level description is fine.

License

MIT

安装

TypingMind
{
  "mcpServers": {
    "vfs": {
      "command": "vfs",
      "args": [
        "mcp"
      ]
    }
  }
}

将 Vfs MCP 与多个 AI 模型配合使用

TypingMind 在工作区级别连接 MCP 工具,因此连接 Vfs 后,您就可以在 TypingMind 中搭配不同的 AI 模型使用,无需为每个模型单独设置。 您可以在自己的设备上本地运行 MCP,也可以通过 URL 连接远程 MCP 服务器。

方式 1:使用本地连接器

如果 MCP 服务器需要访问您电脑上的本地文件、应用或私有资源,请选择此方式。

1

打开 MCP 设置

在 TypingMind 中,依次前往“设置”、“高级设置”和“模型上下文协议”,然后选择“设置连接器”。

  1. 在您的浏览器中打开 TypingMind。
  2. 点击“设置”图标。
  3. 进入“高级设置”。
  4. 打开“模型上下文协议”部分。
  5. 点击“设置连接器”,然后选择“此设备”。
TypingMind MCP 连接器设置界面,已选择“此设备”
2

运行连接器命令

选择“此设备”,从 TypingMind 复制命令并在终端中运行。使用 MCP 时,请保持该进程运行。

  1. 复制 TypingMind 显示的设置命令。
  2. 在 macOS 上打开“终端”,或在 Windows 上打开 Windows Terminal。
  3. 粘贴并运行命令。
  4. 如果终端询问您是否继续,请确认安装软件包。
  5. 使用 MCP 工具时,请保持终端窗口及其中的进程运行。
3

将 Vfs 添加为服务器

当连接器状态为“就绪”时,点击“编辑服务器”,然后粘贴 MCP 服务器配置。

  1. 等待连接器状态显示为“就绪”。
  2. 点击“编辑服务器”。
  3. 粘贴 Vfs MCP 服务器配置。
  4. 保存服务器列表。
  5. 如需确认连接器是否仍处于就绪状态,请刷新。
TypingMind MCP 设置界面,显示正在运行的服务器和“编辑服务器”按钮
{
  "mcpServers": {
    "vfs": {
      "command": "npx",
      "args": [
        "-y",
        "<mcp-server-package>"
      ]
    }
  }
}
4

在不同模型中使用同一连接

保存服务器列表,打开“插件”,启用 Vfs MCP 工具,然后在 TypingMind 中选择任意受支持的 AI 模型,即可在聊天中使用这些工具,或将其分配给智能体。

  1. 在 TypingMind 中打开“插件”页面。
  2. 启用 Vfs MCP 工具。
  3. 开始聊天并选择您想使用的 AI 模型。
  4. 在聊天中使用 MCP 工具,或将其分配给 AI 智能体。
  5. 根据需要随时切换到其他 AI 模型,无需重新连接 MCP。
在 TypingMind 聊天中使用已启用的 MCP 工具和选定的 AI 模型
您能使用 Vfs 帮我完成这项任务吗?
Vfs
当然。我已阅读。
以下是我使用 Vfs 得到的结果。

方式 2:添加 MCP 服务器 URL

如果 Vfs 已托管在远程服务器上,或您的团队希望让多个用户共用一个连接器,请选择此方式。

1

打开 MCP 连接器

在 TypingMind 中,前往“插件”,打开“MCP 连接器”,然后选择“添加 URL”。

  1. 在您的浏览器中打开 TypingMind。
  2. 进入“插件”。
  3. 打开“MCP 连接器”。
  4. 点击“添加 URL”。
TypingMind 的“添加自定义 MCP 服务器 URL”表单
2

粘贴服务器 URL

在“服务器 URL”字段中输入 提供商提供的 MCP 服务器 URL。根据服务器要求,添加连接名称、描述、图标、自定义 HTTP 请求头或 OAuth 客户端设置。

  1. 将 提供商提供的 MCP 服务器 URL 粘贴到“服务器 URL”字段中。
  2. 为 Vfs 输入连接名称。
  3. 您可以添加描述和图标,以便更容易识别此连接。
  4. 如果服务器需要身份验证,请添加自定义 HTTP 请求头或 OAuth 客户端信息。
3

创建连接

点击“创建连接”,然后返回插件列表,确认新的 MCP 连接显示为“有效”。

  1. 点击“创建连接”。
  2. 返回 MCP 连接器列表。
  3. 确认 Vfs 连接显示为“有效”。
  4. 如果连接未立即出现,请刷新插件列表。
4

切换模型,无需重新连接

使用您偏好的模型开始聊天,在“插件”中启用 Vfs 工具,并根据需要随时切换到其他模型。该 MCP 连接在 TypingMind 工作区中仍然可用。

  1. 在 TypingMind 中开始新聊天。
  2. 选择您想使用的 AI 模型。
  3. 在“插件”中启用 Vfs 工具。
  4. 需要时,请让模型使用该工具。
  5. 切换到其他 AI 模型,继续使用同一个 MCP 连接。
在 TypingMind 聊天中使用已启用的 MCP 工具和选定的 AI 模型
您能使用 Vfs 帮我完成这项任务吗?
Vfs
当然。我已阅读。
以下是我使用 Vfs 得到的结果。

常见问题

Vfs MCP 服务器有什么用途?

Vfs 是一个 MCP 服务器,可让兼容的 AI 客户端连接外部工具并获取上下文。在 TypingMind 中,只需添加一次此 MCP 服务器,即可在您的 AI 工作区中使用其工具。

可以在 TypingMind 中让多个 AI 模型使用 Vfs MCP 吗?

可以。TypingMind 在工作区层面连接 MCP 工具,因此您可以让 Claude、ChatGPT、Gemini 等不同 AI 模型,或您在 TypingMind 中配置的其他模型使用 Vfs,而无需为每个模型单独配置 MCP 服务器。

为什么在 TypingMind 中使用 Vfs MCP?

TypingMind 将多个 AI 模型、提示词、插件、AI 智能体、API 密钥和 MCP 工具整合到同一个工作区中,是优秀的大语言模型聊天前端之一。连接 Vfs 后,您可以在偏好的不同模型中使用其 MCP 工具,同时在 TypingMind 中井然有序地管理聊天工作流程。

如何将 Vfs MCP 连接到 TypingMind?

您可以通过本地 MCP 连接器,或添加远程 MCP 服务器 URL,在 TypingMind 中连接 Vfs。当服务器需要访问您设备上的文件、应用或私有资源时,请使用本地连接器;当 MCP 服务器托管在远程时,请使用服务器 URL。

Vfs MCP 在 TypingMind 中提供哪些工具?

Vfs 提供 MCP 功能,您可以在 TypingMind 的插件页面启用这些功能,然后在聊天中使用,或将其分配给 AI 智能体。

使用 Vfs MCP 需要向 TypingMind 提供我的 API 密钥吗?

不需要。TypingMind 采用本地优先的设计,让您自行掌控模型提供商、API 密钥、提示词和 MCP 配置。如果 Vfs 需要身份验证,请在创建连接时,为该 MCP 服务器添加所需的请求头、OAuth 设置或本地配置。

相关 MCP 服务器

查看全部

立即创建您自己的 AI 工作区

订阅我们的电子简报,获取新功能和后续赠奖活动的通知 👇