io.github.Codeturion/codesurface

编码与调试

by codeturion

为代码库的公共 API 建立索引,并通过精简的 MCP 工具响应对外提供查询能力。

什么是 io.github.Codeturion/codesurface

为代码库的公共 API 建立索引,并通过精简的 MCP 工具响应对外提供查询能力。

README

<!-- mcp-name: io.github.Codeturion/codesurface -->

codesurface

PyPI Version PyPI Downloads MCP Registry GitHub Stars GitHub Last Commit Languages License: PolyForm Noncommercial 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), Go (.go), Java (.java), Python (.py), TypeScript/TSX (.ts, .tsx)

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 — 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

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:

code
[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.

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

<details> <summary>Alternative installation methods</summary>

Using pip install:

bash
pip install codesurface
json
{
  "mcpServers": {
    "codesurface": {
      "command": "codesurface",
      "args": ["--project", "/path/to/your/src"]
    }
  }
}
</details> <details> <summary>Project structure</summary>
code
codesurface/
├── src/codesurface/
│   ├── server.py           # MCP server — 5 tools
│   ├── db.py               # SQLite + FTS5 database layer
│   └── parsers/
│       ├── base.py         # BaseParser ABC
│       ├── csharp.py       # C# parser
│       ├── go.py           # Go parser
│       ├── java.py         # Java parser
│       ├── python_parser.py # Python parser
│       └── typescript.py   # TypeScript/TSX parser
├── pyproject.toml
└── README.md
</details> <details> <summary>Troubleshooting</summary>

"No codebase indexed"

  • Ensure --project points to a directory containing supported source files (.cs, .go, .java, .py, .ts, .tsx)
  • The server indexes at startup — check stderr for the "Indexed N records" message

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
</details>

Contact

fuatcankoseoglu@gmail.com

License

PolyForm Noncommercial 1.0.0

Free to use, fork, modify, and share for any personal or non-commercial purpose. Commercial use requires permission.

常见问题

io.github.Codeturion/codesurface 是什么?

为代码库的公共 API 建立索引,并通过精简的 MCP 工具响应对外提供查询能力。

相关 Skills

前端设计

by anthropics

Universal
热门

面向组件、页面、海报和 Web 应用开发,按鲜明视觉方向生成可直接落地的前端代码与高质感 UI,适合做 landing page、Dashboard 或美化现有界面,避开千篇一律的 AI 审美。

想把页面做得既能上线又有设计感,就用前端设计:组件到整站都能产出,难得的是能避开千篇一律的 AI 味。

编码与调试
未扫描111.8k

网页构建器

by anthropics

Universal
热门

面向复杂 claude.ai HTML artifact 开发,快速初始化 React + Tailwind CSS + shadcn/ui 项目并打包为单文件 HTML,适合需要状态管理、路由或多组件交互的页面。

在 claude.ai 里做复杂网页 Artifact 很省心,多组件、状态和路由都能顺手搭起来,React、Tailwind 与 shadcn/ui 组合效率高、成品也更精致。

编码与调试
未扫描111.8k

网页应用测试

by anthropics

Universal
热门

用 Playwright 为本地 Web 应用编写自动化测试,支持启动开发服务器、校验前端交互、排查 UI 异常、抓取截图与浏览器日志,适合调试动态页面和回归验证。

借助 Playwright 一站式验证本地 Web 应用前端功能,调 UI 时还能同步查看日志和截图,定位问题更快。

编码与调试
未扫描111.8k

相关 MCP Server

GitHub

编辑精选

by GitHub

热门

GitHub 是 MCP 官方参考服务器,让 Claude 直接读写你的代码仓库和 Issues。

这个参考服务器解决了开发者想让 AI 安全访问 GitHub 数据的问题,适合需要自动化代码审查或 Issue 管理的团队。但注意它只是参考实现,生产环境得自己加固安全。

编码与调试
83.1k

by Context7

热门

Context7 是实时拉取最新文档和代码示例的智能助手,让你告别过时资料。

它能解决开发者查找文档时信息滞后的问题,特别适合快速上手新库或跟进更新。不过,依赖外部源可能导致偶尔的数据延迟,建议结合官方文档使用。

编码与调试
51.8k

by tldraw

热门

tldraw 是让 AI 助手直接在无限画布上绘图和协作的 MCP 服务器。

这解决了 AI 只能输出文本、无法视觉化协作的痛点——想象让 Claude 帮你画流程图或白板讨论。最适合需要快速原型设计或头脑风暴的开发者。不过,目前它只是个基础连接器,你得自己搭建画布应用才能发挥全部潜力。

编码与调试
46.2k

评论