Skip to main content

MCP server that indexes a C# codebase's public API at startup and serves it via compact tool responses — saving tokens vs reading source files

Project description

codesurface

PyPI Version PyPI Downloads License: MIT Python 3.10+ Blog Post

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

Parses all .cs 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.

Quick Start

pip install codesurface

Then add to your .mcp.json:

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

Point --project at any directory containing .cs files — a Unity Assets/Scripts folder, a .NET src/ tree, a Godot C# project, etc.

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

Tools

Tool Purpose Example
search Find APIs by keyword "MergeService", "BlastBoard", "GridCoord"
get_signature Exact signature by name or FQN "TryMerge", "CampGame.Services.IMergeService.TryMerge"
get_class Full class reference card — all public members "BlastBoardModel" → all methods/fields/properties
get_stats Overview of indexed codebase File count, record counts, namespace breakdown
reindex Incremental index update (mtime-based) Only re-parses changed/new/deleted files

Benchmarks

Measured against a real Unity game project (129 files, 1,018 API records) across a 10-step cross-cutting research workflow.

Strategy Total Tokens vs MCP
MCP (codesurface) 1,021
Skilled Agent (Grep + partial Read) 4,453 4.4x more
Naive Agent (Grep + full Read) 11,825 11.6x more

Even with follow-up reads for implementation detail, the hybrid MCP + targeted Read approach uses 54% fewer tokens than a skilled Grep+Read agent.

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

Setup Details

Claude Code configuration

Add to <project>/.mcp.json:

Using uv (recommended):

{
  "mcpServers": {
    "codesurface": {
      "command": "uv",
      "args": ["run", "--directory", "/path/to/codesurface", "codesurface", "--project", "/path/to/your/src"]
    }
  }
}

Using pip install:

{
  "mcpServers": {
    "codesurface": {
      "command": "codesurface",
      "args": ["--project", "/path/to/your/src"]
    }
  }
}
CLAUDE.md snippet (recommended)

Add to your project's CLAUDE.md so the AI knows when to use the tools:

## Codebase API Lookup (codesurface MCP)

Use the `codesurface` MCP tools to look up your project's classes, methods, properties, and fields instead of reading source files.

| When | Tool | Example |
|------|------|---------|
| Searching for an API by keyword | `search` | `search("MergeService")` |
| Need exact method signature | `get_signature` | `get_signature("TryMerge")` |
| Want all members on a class | `get_class` | `get_class("BlastBoardModel")` |
| Overview of indexed codebase | `get_stats` | `get_stats()` |
| After creating/deleting C# files | `reindex` | `reindex()` |
Project structure
codesurface/
├── src/codesurface/
│   ├── server.py        # MCP server — 5 tools
│   ├── db.py            # SQLite + FTS5 database layer
│   └── cs_parser.py     # C# public API parser
├── pyproject.toml
└── README.md
Troubleshooting

"No codebase indexed"

  • Ensure --project points to a directory containing .cs files
  • 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 C# files

  • Call reindex() — only re-parses files whose modification time changed, fast even on large codebases

Contact

fuatcankoseoglu@gmail.com

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

codesurface-0.2.0.tar.gz (22.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

codesurface-0.2.0-py3-none-any.whl (17.0 kB view details)

Uploaded Python 3

File details

Details for the file codesurface-0.2.0.tar.gz.

File metadata

  • Download URL: codesurface-0.2.0.tar.gz
  • Upload date:
  • Size: 22.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for codesurface-0.2.0.tar.gz
Algorithm Hash digest
SHA256 43d2abf3ef04071ad8c78ec5059d8d2b32a47ce0d326a242ea033253649b6238
MD5 262a81f08a35325b33f48318812e515e
BLAKE2b-256 1d071776bd946f7d11487f57d017e2161f289c5d412d7d4c2a027728cfbc2b62

See more details on using hashes here.

Provenance

The following attestation bundles were made for codesurface-0.2.0.tar.gz:

Publisher: publish.yml on Codeturion/codesurface

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file codesurface-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: codesurface-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 17.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for codesurface-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 79126b7ab4493b42a8f005cec6f25a9e2ac304179cbc67ea9f4fb4344011a76e
MD5 95ca03287e082a54c0bd9cc971d6a3f6
BLAKE2b-256 70d365c9a8ad56b62295382386809e6f29686c2d5262e27d2f440722f5d5fd71

See more details on using hashes here.

Provenance

The following attestation bundles were made for codesurface-0.2.0-py3-none-any.whl:

Publisher: publish.yml on Codeturion/codesurface

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page