Skip to main content
Glama
SammySnake-d

Fast Context MCP

by SammySnake-d

Fast Context MCP

AI 驱动的语义代码搜索 MCP 工具 — 基于 Windsurf 逆向工程的 SWE-grep 协议。

任何兼容 MCP 的客户端(Claude Code、Claude Desktop、Cursor 等)都可以使用它通过自然语言查询搜索代码库。所有工具都通过 npm 捆绑 — 无需系统级依赖(通过 @vscode/ripgrep 提供 ripgrep,通过 tree-node-cli 提供 tree)。支持 macOS、Windows 和 Linux。

工作原理

You: "where is the authentication logic?"
         │
         ▼
┌─────────────────────────┐
│  Fast Context MCP       │
│  (local MCP server)     │
│                         │
│  1. Maps project → /codebase
│  2. Sends query to Windsurf Devstral API
│  3. AI generates rg/readfile/tree commands
│  4. Executes commands locally (built-in rg)
│  5. Returns results to AI
│  6. Repeats for N rounds
│  7. Returns file paths + line ranges
│     + suggested search keywords
└─────────────────────────┘
         │
         ▼
Found 3 relevant files.
  [1/3] /project/src/auth/handler.py (L10-60)
  [2/3] /project/src/middleware/jwt.py (L1-40)
  [3/3] /project/src/models/user.py (L20-80)

Suggested search keywords:
  authenticate, jwt.*verify, session.*token

Related MCP server: code-rag

前提条件

  • Node.js >= 18

  • Windsurf 账户 — 免费版即可(获取 API 密钥需要)

无需安装 ripgrep — 它已通过 @vscode/ripgrep 捆绑。

安装

方式一:npm(推荐)

# Latest stable release
npm install @sammysnake/fast-context-mcp

# Or beta/next release
npm install @sammysnake/fast-context-mcp@next

方式二:从源码安装

git clone https://github.com/SammySnake-d/fast-context-mcp.git
cd fast-context-mcp
npm install

配置

1. 获取你的 Windsurf/Devin API 密钥

服务器会自动从 Devin CLI/Desktop 或旧版 Windsurf 安装中提取 API 密钥。你也可以在配置后使用 extract_windsurf_key MCP 工具,或手动设置 WINDSURF_API_KEY

桌面端凭据按以下顺序发现:Devin、旧版 Deviv,然后 Windsurf

平台

路径

macOS

~/Library/Application Support/Devin/User/globalStorage/state.vscdb

Windows

%APPDATA%/Devin/User/globalStorage/state.vscdb

Linux

~/.config/Devin/User/globalStorage/state.vscdb

在 WSL/Linux 上,服务器首先检查 ~/.local/share/devin/credentials.toml 中的 Devin CLI 凭据。如果在 WSL 内使用 Windows 提取的密钥返回 403,请在 WSL 内运行 devin login 并重试。

2. 配置 MCP 客户端

Claude Code

~/.claude.jsonmcpServers 下添加:

{
  "fast-context": {
    "command": "npx",
    "args": ["-y", "--prefer-online", "@sammysnake/fast-context-mcp"],
    "env": {
      "WINDSURF_API_KEY": "sk-ws-01-xxxxx"
    }
  }
}

对于 beta/next 版本:

{
  "fast-context": {
    "command": "npx",
    "args": ["-y", "--prefer-online", "@sammysnake/fast-context-mcp@next"],
    "env": {
      "WINDSURF_API_KEY": "sk-ws-01-xxxxx"
    }
  }
}

Claude Desktop

claude_desktop_config.jsonmcpServers 下添加:

{
  "fast-context": {
    "command": "npx",
    "args": ["-y", "--prefer-online", "@sammysnake/fast-context-mcp"],
    "env": {
      "WINDSURF_API_KEY": "sk-ws-01-xxxxx"
    }
  }
}

对于 beta/next 版本:

{
  "fast-context": {
    "command": "npx",
    "args": ["-y", "--prefer-online", "@sammysnake/fast-context-mcp@next"],
    "env": {
      "WINDSURF_API_KEY": "sk-ws-01-xxxxx"
    }
  }
}

如果省略 WINDSURF_API_KEY,服务器会自动从你的本地 Windsurf 安装中自动发现它。

环境变量

变量

默认值

描述

WINDSURF_API_KEY

(自动发现)

Windsurf API 密钥

FC_MAX_TURNS

3

每次查询的搜索轮数(越多越深入,但更慢)

FC_MAX_COMMANDS

8

每轮最大并行命令数

FC_TIMEOUT_MS

30000

流式请求的连接超时时间(毫秒)

FC_HIDE_EXTRACT_WINDSURF_KEY_TOOL

false

设为 1trueyeson 时,从 MCP 工具中隐藏 extract_windsurf_key

FC_RESULT_MAX_LINES

50

每条命令输出的最大行数(截断)

FC_LINE_MAX_CHARS

250

每行输出的最大字符数(截断)

FC_CACHE_DISABLED

(未设置)

使用 1trueyeson 禁用内存结果缓存

FC_CACHE_TTL_MS

300000

结果缓存 TTL;<=0 表示禁用缓存

FC_CACHE_MAX_ENTRIES

200

内存缓存的最大条目数

FC_ALLOW_INSECURE_TLS

(未设置)

仅在受信任的企业代理要求禁用 TLS 验证时设为 1

WS_MODEL

MODEL_SWE_1_6_FAST

Windsurf 模型名称

WS_APP_VER

1.48.2

Windsurf 应用版本(协议元数据)

WS_LS_VER

1.9544.35

Windsurf 语言服务器版本(协议元数据)

可用模型

可以通过设置 WS_MODEL 来更改模型(参见上面的环境变量)。

Available Models

默认值:MODEL_SWE_1_6_FAST — 速度最快、grep 关键词最丰富、定位粒度最细。

MCP 工具

具有可调参数的 AI 驱动语义代码搜索。

参数

类型

必填

默认值

描述

query

string

自然语言搜索查询

project_path

string

cwd

项目根的绝对路径

tree_depth

integer

3

仓库映射的目录树深度(1-6)。越高上下文越多,但载荷越大。如果树超过 250KB,会自动回退到较低深度。大型 monorepo(>5000 个文件)使用 1-2,大多数项目使用 3,小型项目使用 4-6。

max_turns

integer

3

搜索轮数(1-5)。越多搜索越深入,但速度越慢。简单查找使用 1-2,大多数查询使用 3,复杂分析使用 4-5。

max_results

integer

10

返回的最大文件数(1-30)。越小越聚焦,越大探索范围越广。

exclude_paths

string[]

[]

从仓库映射和搜索上下文中排除的目录/文件模式。

返回值:

  1. 相关文件及其行范围

  2. 建议的搜索关键词(AI 搜索过程中使用的 rg 模式)

  3. 诊断元数据[config] 行显示实际使用的 tree_depth、树大小以及是否发生了回退)

示例输出:

Found 3 relevant files.

  [1/3] /project/src/auth/handler.py (L10-60, L120-180)
  [2/3] /project/src/middleware/jwt.py (L1-40)
  [3/3] /project/src/models/user.py (L20-80)

grep keywords: authenticate, jwt.*verify, session.*token

[config] tree_depth=3, tree_size=12.5KB, max_turns=3

错误输出包含特定状态提示:

Error: Request failed: HTTP 403

[hint] 403 Forbidden: Authentication failed. The API key may be expired or revoked.
Try re-extracting with extract_windsurf_key, or set a fresh WINDSURF_API_KEY env var.
If you are running inside WSL, run `devin login` inside WSL so `~/.local/share/devin/credentials.toml` exists.
Error: Request failed: HTTP 413

[diagnostic] tree_depth_used=3, tree_size=280.0KB (auto fell back from requested depth)
[hint] If the error is payload-related, try a lower tree_depth value.

extract_windsurf_key

从本地安装中提取 Windsurf API 密钥。无参数。

在 MCP 服务器启动时设置 FC_HIDE_EXTRACT_WINDSURF_KEY_TOOL=1,可从 tools/list 中隐藏此工具。这不会禁用 fast_context_search 的内部 API 密钥自动发现。

项目结构

fast-context-mcp/
├── package.json
├── src/
│   ├── server.mjs        # MCP server entry point
│   ├── core.mjs          # Auth, message building, streaming, search loop
│   ├── executor.mjs      # Tool executor: rg, readfile, tree, ls, glob
│   ├── extract-key.mjs   # Windsurf API Key extraction (SQLite)
│   ├── path-safety.mjs   # Project-root confinement for model-selected paths
│   ├── response-repair.mjs # Malformed response repair and evidence salvage
│   ├── shared.mjs        # Repository map, answer parser, prompt builder
│   ├── cache.mjs         # In-memory search-result cache
│   └── protobuf.mjs      # Protobuf encoder/decoder + Connect-RPC frames
├── test/                 # Unit and MCP stdio integration tests
├── README.md
└── LICENSE

搜索工作原理

  1. 项目目录映射到虚拟 /codebase 路径

  2. 按请求的深度生成目录树(默认 L=3),如果树超过 250KB,自动回退到较低深度

  3. 查询 + 目录树通过 Connect-RPC/Protobuf 发送给 Windsurf 的 Devstral 模型

  4. Devstral 生成工具命令(ripgrep、文件读取、tree、ls、glob)

  5. 命令在本地并行执行(每轮最多 FC_MAX_COMMANDS 条)

  6. 结果发送回 Devstral 进行下一轮

  7. 经过 max_turns 轮后,Devstral 返回文件路径 + 行范围

  8. 搜索过程中使用的所有 rg 模式被收集为建议关键词

  9. 附加诊断元数据,帮助调用方 AI 调整参数

技术细节

  • 协议:基于 HTTP/1.1 的 Connect-RPC,Protobuf 编码,gzip 压缩

  • 模型:Devstral(MODEL_SWE_1_6_FAST,可配置)

  • 本地工具rg(通过 @vscode/ripgrep 捆绑)、readfile(Node.js fs)、tree(tree-node-cli)、ls(Node.js fs)、glob(Node.js fs)

  • 认证:API 密钥 → JWT(每个会话自动获取)

  • 运行时:Node.js >= 18(ESM)

依赖

用途

@modelcontextprotocol/sdk

MCP 服务器框架

@vscode/ripgrep

捆绑的 ripgrep 二进制文件(跨平台)

tree-node-cli

跨平台目录树(替代系统 tree

sql.js

无需原生构建步骤即可读取 Devin/Windsurf 的本地 SQLite 数据库

zod (^3.25.76)

模式验证;避免某些 npm 镜像提供的不完整 3.25.0 tarball

友情链接

许可证

MIT

Install Server
A
license - permissive license
A
quality
A
maintenance

Maintenance

Maintainers
3dResponse time
8wRelease cycle
4Releases (12mo)
Commit activity
Issues opened vs closed

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Servers

  • A
    license
    A
    quality
    D
    maintenance
    Enables AI-driven semantic code search using Windsurf's reverse-engineered SWE-grep protocol to query local codebases with natural language. It executes local search tools like ripgrep and tree-node-cli to return relevant file paths and line ranges to MCP-compatible clients.
    2
    227
    MIT
  • F
    license
    Not graded
    quality
    C
    maintenance
    A semantic code search MCP server that enables natural language queries against your codebase, supporting features like related file discovery and context expansion, all running locally.
    2
  • A
    license
    Not graded
    quality
    A
    maintenance
    Semantic code search MCP server that reduces token usage by ~95% by returning top relevant code chunks instead of full files.
    9
    MIT

View all related MCP servers

Related MCP Connectors

  • Search your AI chat history (ChatGPT, Claude, Codex) from any MCP client. Remote, private, read-only

  • An MCP server that gives your AI access to the source code and docs of all public github repos

  • Driflyte MCP server which lets AI assistants query topic-specific knowledge from web and GitHub.

View all MCP Connectors

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/SammySnake-d/fast-context-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server