Codesurface

io.github.Codeturion由 GitHub 账号 Codeturion 发布v0.8.0更新于 Oct 24, 2026

Indexes your codebase's public API and serves it via compact MCP tool responses.

概览

AI 生成的概览

为本地代码库的公开 API 建立索引,向 AI 助手提供紧凑的类、方法和签名查询结果。

可以做什么
启动时解析源文件,提取公开的类、方法、属性、字段和事件并建立本地索引。提供五个工具:search 按关键词查找 API,get_signature 获取精确签名,get_class 获取包含全部公开成员的类参考卡片,get_stats 查看索引概览,reindex 执行增量更新。结果包含文件路径和行号,便于助手只读取相关片段而不是整个文件。支持 C#、C++ 头文件、Go、Java、Python 以及 TypeScript/JavaScript。
适用场景
当助手需要反复用 grep 和读取大文件来回答代码库 API 相关问题时,可以减少读取文件消耗的 token。适合使用受支持语言、且助手主要需要类和方法的查询而非实现细节的项目。
运行要求
作为本地 stdio 进程运行,通常通过 uvx 或 pip install 启动,需要 Python 3.10 或更高版本以及 mcp[cli] 包。必须用 --project 指定包含受支持源文件的目录,语言会自动识别。未声明需要账号、API 密钥或网络访问。仅支持桌面端,不提供网页可执行版本。
安装前请注意
该服务器会读取指定项目路径下的源文件并建立本地索引,不会写入你的代码。请只把 --project 指向你愿意被索引的目录,并用 .codesurfaceignore 或 --exclude 排除生成或第三方代码。README 建议在项目的 CLAUDE.md 中加入说明,让助手优先使用这些工具而不是 grep 和整文件读取。

安装

在 SourceWeft 中

  1. 打开 控制台中的 Codesurface,将其添加到工作区。
  2. 为需要使用其工具的对话启用该服务。

Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。

其他 MCP 客户端

参照 仓库 中的启动说明。

README

codesurface

[PyPI Version] [PyPI Downloads] [MCP Registry] [GitHub Stars] [GitHub Last Commit] [Languages] [License: MIT] [Python 3.10+] [Blog Post]

MCP server that indexes your codebase's public API at startup and serves it via compact tool responses, saving tokens vs reading source files.

Parses source files, extracts public classes/methods/properties/fields/events, and serves them through 5 MCP tools. Works with Claude Code, Cursor, Windsurf, or any MCP-compatible AI tool.

Supported languages: C# (.cs), C++ headers (.h, .hpp, .hxx, .h++), Go (.go), Java (.java), Python (.py), TypeScript/JavaScript (.ts, .tsx, .js, .jsx)

Quick Start

Add to your .mcp.json:

json
{  "mcpServers": {    "codesurface": {      "command": "uvx",      "args": ["codesurface", "--project", "/path/to/your/src"]    }  }}

Point --project at any directory containing supported source files (a Unity Assets/Scripts folder, a Spring Boot project, a .NET src/ tree, a Node.js/React project, a Python package, etc.). Languages are auto-detected.

Restart your AI tool and ask: "What methods does MyService have?"

CLAUDE.md Snippet

Add this to your project's CLAUDE.md (or equivalent instructions file). This step is important. Without it, the AI has the tools but won't know when to reach for them.

markdown
## Codebase API Lookup (codesurface MCP)
Use codesurface MCP tools BEFORE Grep, Glob, Read, or Task (subagents) for any class/method/field lookup. This applies to you AND any subagents you spawn.
| Tool | Use when | Example ||------|----------|---------|| `search` | Find APIs by keyword | `search("MergeService")` || `get_signature` | Need exact signature | `get_signature("TryMerge")` || `get_class` | See all members on a class | `get_class("BlastBoardModel")` || `get_stats` | Codebase overview | `get_stats()` |
Every result includes file path + line numbers. Use them for targeted reads:- `File: Service.cs:32` → `Read("Service.cs", offset=32, limit=15)`- `File: Converter.java:504-506` → `Read("Converter.java", offset=504, limit=10)`
Never read a full file when you have a line number. Only fall back to Grep/Read for implementation details (method bodies, control flow).

Tools

ToolPurposeExample
searchFind APIs by keyword"MergeService", "BlastBoard", "GridCoord"
get_signatureExact signature by name or FQN"TryMerge", "CampGame.Services.IMergeService.TryMerge"
get_classFull class reference card with all public members"BlastBoardModel" → all methods/fields/properties
get_statsOverview of indexed codebaseFile count, record counts, namespace breakdown
reindexIncremental index update (mtime-based)Only re-parses changed/new/deleted files. Also runs automatically on query misses

search, get_signature, and get_class accept two optional filters:

  • file_path: scope results to a directory prefix or exact file (e.g. "src/services/" or "src/services/MergeService.ts")
  • include_tests: include test files in results (default false). Detects __tests__/, tests/, test/, *.test.*, *.spec.*, *_test.*, test_*

Tested On

ProjectLanguageFilesRecordsTime
vscodeTypeScript6,61188,2939.3s
PaperJava2,90933,9732.3s
client-goGo2192,7600.4s
langchainPython1,88012,4181.1s
pydanticPython3659,6480.3s
guavaJava8918,3772.4s
immichTypeScript9197,9570.6s
fastapiPython8815,7130.5s
ant-designTypeScript2,9475,4520.9s
difyTypeScript4,9035,0381.9s
crawlee-pythonPython3862,4730.3s
flaskPython63872<0.1s
cobraGo15249<0.1s
ginGo41574<0.1s
Unity game (private)C#1291,0180.1s

Line Numbers for Targeted Reads

Every record includes line_start and line_end (1-indexed). Multi-line declarations span the full signature:

[METHOD] com.google.common.base.Converter.from  Signature: static Converter<A, B> from(Function<...> forward, Function<...> backward)  File: Converter.java:504-506          ← multi-line signature
[METHOD] server.AlbumController.createAlbum  Signature: createAlbum(@Auth() auth: AuthDto, @Body() dto: CreateAlbumDto)  File: album.controller.ts:46          ← single-line

This lets AI agents do targeted reads instead of reading full files:

python
# Instead of reading the entire 600-line file:Read("Converter.java")                     # 600 lines, ~12k tokens
# Read just the method + context:Read("Converter.java", offset=504, limit=10)  # 10 lines, ~200 tokens

Benchmarks

Measured across 5 real-world projects in 5 languages, each using a 10-step cross-cutting research workflow.

[Total Tokens, Cross-Language Comparison]

LanguageProjectFilesRecordsMCPSkilledNaiveMCP vs Skilled
C#Unity game1291,0341,0214,45311,82577% fewer
TypeScriptimmich6948,3441,4514,50014,55068% fewer
Javaguava8918,3771,8514,20026,70056% fewer
Gogin385341,7912,77015,30035% fewer
Pythoncodesurface9407532,00010,40062% fewer

[Hallucination Risk]

Even with follow-up reads for implementation detail, the hybrid MCP + targeted Read approach uses 44% fewer tokens than a skilled Grep+Read agent and 87% fewer than a naive agent:

[Hybrid Workflow]

Per-question breakdown

[Per Question]

See workflow-benchmark.md for the full step-by-step analysis across all languages.

Filtering What Gets Indexed

By default, codesurface skips common vendored, build, and VCS directories: node_modules, vendor, bin, obj, dist, build, target, .git, .venv, __pycache__, and a few dozen others. Git worktrees and submodules are also skipped.

To exclude additional paths:

Project-level (committed): create a .codesurfaceignore file at your project root with one glob per line.

generated/**docs/****/*.pb.go

Per-instance (CLI): pass --exclude with comma-separated globs.

json
{  "command": "uvx",  "args": ["codesurface", "--project", "src", "--exclude", "generated/**,vendor/**"]}

Other indexing flags:

  • --include-submodules: index git submodules (skipped by default)
  • --language <name>: pin to a single parser (e.g. --language cpp) instead of auto-detecting

Multiple Projects

Each --project flag indexes one directory. To index multiple codebases, run separate instances with different server names:

json
{  "mcpServers": {    "codesurface-backend": {      "command": "uvx",      "args": ["codesurface", "--project", "/path/to/backend/src"]    },    "codesurface-frontend": {      "command": "uvx",      "args": ["codesurface", "--project", "/path/to/frontend/src"]    }  }}

Each instance gets its own in-memory index and tools. The AI agent sees both and can query across projects.

Setup Details

Alternative installation methods

Using pip install:

bash
pip install codesurface
json
{  "mcpServers": {    "codesurface": {      "command": "codesurface",      "args": ["--project", "/path/to/your/src"]    }  }}
Project structure
codesurface/├── src/codesurface/│   ├── server.py           # MCP server with 5 tools│   ├── db.py               # SQLite + FTS5 database layer│   ├── filters.py          # PathFilter (default exclusions, .codesurfaceignore, --exclude)│   └── parsers/│       ├── base.py         # BaseParser ABC│       ├── cpp.py          # C++ header parser│       ├── csharp.py       # C# parser│       ├── go.py           # Go parser│       ├── java.py         # Java parser│       ├── python_parser.py # Python parser│       └── typescript.py   # TypeScript/JavaScript parser├── pyproject.toml└── README.md
Troubleshooting

"No codebase indexed"

  • Ensure --project points to a directory containing supported source files (.cs, .h, .hpp, .go, .java, .py, .ts, .tsx, .js, .jsx)
  • The server indexes at startup. Check stderr for [codesurface] scanning N files... and [codesurface] done: lines

Server won't start

  • Check Python version: python --version (needs 3.10+)
  • Check mcp[cli] is installed: pip install mcp[cli]

Stale results after editing source files

  • The index auto-refreshes on query misses. If you add a new class and query it, the server reindexes and retries automatically
  • You can also call reindex() manually to force an incremental update

Contact

[email protected]

License

MIT

来源:README.md,提交 3845446

工具

0
SourceWeft 尚未在沙箱中启动过该软件包,因此其工具未知。

版本历史

1
  1. v0.8.0最新Sep 16, 2026

评分

已满足适用检查项的 50%

该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。

  • 近 30 天内可连通25 分

    请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。

  • 已声明认证方式10 分

    请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。

  • 已列出工具15 分

    请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。

  • 描述必需15 分
  • 图标10 分
  • 文档15 分
  • 许可证10 分