Skip to main content
Glama
Relace MCP Server

Relace MCP Server

by possible055

非官方 Relace MCP 服务器

PyPI Python 3.11+ License: MIT 100% AI-Generated OpenSSF Scorecard

非官方 — 个人项目,与 Relace 无关联。

AI 构建 — 完全在 AI 辅助下开发(Antigravity、Codex、Cursor、Github Copilot、Windsurf)。

MCP 服务器,提供 AI 驱动的代码编辑和智能代码库探索工具。

无此工具

使用 agentic_search + fast_apply

手动 grep,容易遗漏相关文件

自然语言提问,获取精确位置

编辑导致其他地方导入错误

追踪导入和调用链

全量重写消耗大量 tokens

描述变更,无需行号

行号错误导致代码损坏

10,000+ tokens/秒合并

功能特性

  • 快速应用 (Fast Apply) — 通过 Relace API 以 10,000+ tokens/秒的速度应用代码编辑

  • 智能搜索 (Agentic Search) — 基于自然语言查询的智能代码库探索

  • 智能检索 (Agentic Retrieval) — 混合语义提示 + 实时代码探索,支持陈旧提示和显式云端维护(通过 MCP_SEARCH_RETRIEVAL=1 启用;使用 MCP_RETRIEVAL_BACKEND 选择后端)

  • 云端搜索 (Cloud Search) — 对云端同步仓库进行语义代码搜索

Related MCP server: code-context

快速开始

先决条件: uv、git、ripgrep(推荐)

使用 relace 后端(默认):从 Relace 控制台 获取 API 密钥,然后添加到您的 MCP 客户端:

~/.cursor/mcp.json

{
  "mcpServers": {
    "relace": {
      "command": "uv",
      "args": ["tool", "run", "relace-mcp"],
      "env": {
        "RELACE_API_KEY": "rlc-your-api-key",
        "MCP_BASE_DIR": "/absolute/path/to/your/project"
      }
    }
  }
}
claude mcp add relace \
  --env RELACE_API_KEY=rlc-your-api-key \
  --env MCP_BASE_DIR=/absolute/path/to/your/project \
  -- uv tool run relace-mcp

~/.codeium/windsurf/mcp_config.json

{
  "mcpServers": {
    "relace": {
      "command": "uv",
      "args": ["tool", "run", "relace-mcp"],
      "env": {
        "RELACE_API_KEY": "rlc-your-api-key",
        "MCP_BASE_DIR": "/absolute/path/to/your/project"
      }
    }
  }
}

.vscode/mcp.json

{
  "mcp": {
    "servers": {
      "relace": {
        "type": "stdio",
        "command": "uv",
        "args": ["tool", "run", "relace-mcp"],
        "env": {
          "RELACE_API_KEY": "rlc-your-api-key",
          "MCP_BASE_DIR": "${workspaceFolder}"
        }
      }
    }
  }
}

~/.codex/config.toml

[mcp_servers.relace]
command = "uv"
args = ["tool", "run", "relace-mcp"]

[mcp_servers.relace.env]
RELACE_API_KEY = "rlc-your-api-key"
MCP_BASE_DIR = "/absolute/path/to/your/project"

配置

变量

必需

描述

RELACE_API_KEY

✅*

来自 Relace 控制台 的 API 密钥;Relace 提供商和云端工具必需

MCP_SEARCH_RETRIEVAL

❌

设置为 1 以注册 agentic_retrieval 工具

MCP_RETRIEVAL_BACKEND

❌

语义检索后端:relace(默认)、codanna、chunkhound 或 none

MCP_RETRIEVAL_HINT_POLICY

❌

检索提示策略:prefer-stale(默认)或 strict

MCP_BACKGROUND_INDEX_MONITOR

❌

本地索引定期刷新监控(可选);需要固定的 MCP_BASE_DIR 和本地后端

MCP_BACKGROUND_INDEX_INTERVAL_SECONDS

❌

本地索引定期监控间隔(秒,默认:300)

MCP_BACKGROUND_INDEX_INITIAL_DELAY_SECONDS

❌

首次定期本地索引检查前的初始延迟(秒,默认:30)

MCP_SEARCH_TURN_STATUS_MODE

❌

轮次状态用户消息策略:always(默认)、final-only 或 off

SEARCH_BASH_TOOLS

❌

在搜索运行期间启用 bash:1(开启,默认)、0(关闭)

SEARCH_LSP_TOOLS

❌

启用 LSP 辅助搜索:1(开启)、0(关闭,默认)

MCP_BASE_DIR

❌

项目根目录覆盖(通过 MCP Roots → Git → 工作区存储 → CWD 自动检测)

MCP_LOGGING

❌

文件日志记录:off(默认)、safe、full

MCP_DOTENV_PATH

❌

用于集中配置的 .env 文件路径

* 如果满足以下两者,则可选:(1) APPLY_PROVIDER 和 SEARCH_PROVIDER 为非 Relace 提供商,且 (2) MCP_RETRIEVAL_BACKEND 为 codanna、chunkhound 或 none。

有关 .env 使用、编码设置、自定义 LLM 提供商等更多信息,请参阅 docs/advanced.md。

工具

始终可用:fast_apply、agentic_search。agentic_retrieval 需要 MCP_SEARCH_RETRIEVAL=1。云端工具仅在 MCP_RETRIEVAL_BACKEND=relace 时可用。index_status 适用于 relace、codanna 和 chunkhound,在 MCP_RETRIEVAL_BACKEND=none 时隐藏。

使用 MCP 原生发现界面:list_tools() 获取工具,list_resources() 获取资源。

有关详细参数,请参阅 docs/tools.md。

语言支持

LSP 工具使用您系统上安装的外部语言服务器。

语言

语言服务器

安装命令

Python

basedpyright

(已捆绑)

TypeScript/JS

typescript-language-server

npm i -g typescript-language-server typescript

Go

gopls

go install golang.org/x/tools/gopls@latest

Rust

rust-analyzer

rustup component add rust-analyzer

仪表盘

用于监控操作的实时终端 UI。

pip install relace-mcp[tools]
relogs

有关详细用法,请参阅 docs/dashboard.md。

基准测试

使用 Loc-Bench 代码定位数据集评估 agentic_search 性能。

git clone https://github.com/possible055/relace-mcp.git
cd relace-mcp
uv sync --extra benchmark

# Build dataset from Hugging Face
uv run --extra benchmark python -m benchmark.cli.build_locbench --output artifacts/data/raw/locbench_v1.jsonl

# Run evaluation
uv run --extra benchmark python -m benchmark.cli.run --dataset artifacts/data/raw/locbench_v1.jsonl --limit 20

所有基准测试产物均写入 benchmark/.data/ 下。

有关网格搜索、分析工具和指标解读,请参阅 docs/benchmark.md。

平台支持

平台

状态

备注

Linux

✅ 完全支持

主要开发平台

macOS

✅ 完全支持

所有功能可用

Windows

⚠️ 部分支持

bash 工具不可用;使用 WSL 以获得完整功能

故障排除

错误或消息

解决方案

RELACE_API_KEY is required ...

使用 Relace 提供商或云端工具时设置 RELACE_API_KEY

NEEDS_MORE_CONTEXT

在目标块附近包含 1-3 个唯一的锚点行

INVALID_PATH

验证路径是否存在且位于 MCP_BASE_DIR 或允许的额外路径内

FILE_TOO_LARGE

文件超过 10MB;将更改拆分为更小的文件或编辑

ENCODING_ERROR

为非 UTF-8 项目显式设置 RELACE_DEFAULT_ENCODING

AUTH_ERROR

验证 API 密钥和提供商配置

RATE_LIMIT

稍后重试或减少请求量

NETWORK_ERROR / TIMEOUT_ERROR

检查网络访问并重试

APPLY_NOOP

添加更具体的锚点或具体的行,以便合并能产生差异

MARKER_LEAKAGE

确保占位符标记仅用作占位符,而非预期的字面输出

TRUNCATION_DETECTED

拆分大型删除密集型编辑或使用显式的删除指令

BLAST_RADIUS_EXCEEDED

将更改拆分为更小、更局部的编辑

开发

git clone https://github.com/possible055/relace-mcp.git
cd relace-mcp
uv sync --extra dev --extra benchmark
uv run pytest
uv run --extra dev --extra benchmark pytest benchmark/tests -q

许可证

MIT

Available Tools

7 tools
cloud_clearA
Destructive

Delete cloud repository and local sync state. IRREVERSIBLE.

Removes all indexed data from Relace Cloud. Use cloud_list to find repo IDs.

Inputs: confirm, repo_id. Returns: object

cloud_listA
Read-onlyIdempotent

[ADMIN] List all repositories in your Relace Cloud account.

Use to find repo_id for cloud_clear. Not needed for normal search/sync workflow. Returns repository IDs, names, and indexing status.

Inputs: no named parameters. Returns: object

cloud_syncA
Idempotent

Upload or refresh codebase to Relace Cloud for semantic search.

Check index_status() first—skip this if cloud freshness is already 'fresh'. Syncs git-tracked files to enable cloud_search. Incremental by default.

Advanced (Relace-specific): force=True Re-upload all files; use after large refactors. force=True+mirror=True Delete cloud files absent locally; use after branch switch.

Returns: {sync_mode (str), files_created (int), files_updated (int), files_deleted (int), files_unchanged (int), warnings (list[str]), repo_id (str), repo_head (str)}. Check warnings[] for truncation or suppressed deletes. Fails if not in a git repo or RELACE_API_KEY is not set.

Inputs: force, mirror. Returns: object

fast_applyA
Destructive

Edit or create a file using intelligent merging.

For new files: writes content directly. For existing files: merges edit_snippet with current content using anchor lines. Anchor lines are verbatim lines copied from the existing file that help locate the exact edit target. Include 1-2 unique lines adjacent to the change. Truncation markers are recommended for larger scoped edits but not required. Markdown files keep fenced code blocks verbatim; outer fence stripping is skipped for .md/.mdx targets.

On error, the response includes a code field:

  • NEEDS_MORE_CONTEXT: merge model could not locate the target - add 1-2 unique anchor lines from immediately around the edit location.

  • APPLY_NOOP: merge returned an identical file even though the snippet contained explicit remove directives or concrete new lines not present in the original.

  • BLAST_RADIUS_EXCEEDED: edit scope too large - split into smaller edits.

  • MARKER_LEAKAGE: placeholder marker text leaked into merged output (treated as literal text).

  • TRUNCATION_DETECTED: merged output shrank drastically and no explicit remove directive was provided.

On success: {status: "ok", diff: str | None (unified diff, None for new files or no-op)}.

Do NOT use this tool to delete files or clear file contents. Use a dedicated file management tool for those operations.

Inputs: path (required), edit_snippet (required), instruction. Returns: object

index_statusA
Read-onlyIdempotent

Inspect the single active indexing backend in read-only mode.

Use this before retrieval when you need to know whether the active backend is fresh and whether semantic hints are usable. Returns active_backend, a single backend status object with freshness and hints_usable, and background_monitor (state, reason). This tool never refreshes indexes; if active_backend is relace and backend.status.needs_sync is true, run cloud_sync().

Inputs: no named parameters. Returns: trace_id, active_backend, base_dir, base_dir_source, +3 more

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A4.3/5.0

    Scored across 7 tools

    Disambiguation5/5

    Each tool has a clearly distinct purpose with descriptions that explicitly differentiate similar tools (e.g., agentic_search vs cloud_search based on query type). There is no functional overlap.

    Naming Consistency3/5

    Cloud operations use a consistent 'cloud_' prefix, but 'agentic_search', 'fast_apply', and 'index_status' break the pattern. Mix of verb_noun and adjective_noun styles reduces predictability.

    Tool Count5/5

    Seven tools is well-scoped for a code search and editing server. Each tool addresses a specific need without redundancy or excessive complexity.

    Completeness3/5

    Covers search (local and cloud) and file editing, but lacks tools for reading full file content, deleting files, or managing local files beyond edits. Users may need to rely on external tools for basic operations.

    Maintenance

    ActivityInactive
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      F
      maintenance
      Provides AI-powered code intelligence for any codebase using local LLMs and vector search, enabling semantic code search, pattern analysis, and context-optimized code generation with 90% token savings.
      2
      MIT
    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables AI coding assistants to automatically scan, store, and query API endpoints from codebases, providing instant lookup and semantic search to reduce context switching and token consumption.
      1
      MIT
    • A
      license
      Not graded
      quality
      Not graded
      maintenance
      Make any LLM a codebase expert instantly. Provides deep code intelligence through semantic search, architecture mapping, security analysis, and smart context that fits perfectly in token windows.
      MIT
    • A
      license
      Not graded
      quality
      C
      maintenance
      Provides structured, token-efficient code context for AI assistants by indexing codebases with AST-level analysis, supporting 17+ languages, enabling semantic search, call-site tracking, and PR attribution.
      70 PyPI
      52
      MIT