Surgical Context MCP
What it does
Local Tree-sitter code graph: surgical edit context for AI agents instead of full-file reads.
- Connects パソコンで動く
- Account or key No key needed
- Category 開発者ツール
インストール
使っているAIアプリを選んで、設定をコピーしてください。
チェック 3/3 合格 · あなたのパソコンで動きます
まず:どの AI を使っていますか?
使っているアプリを選ぶと、下に手順が表示されます。
Claude につなげますが、先に準備が必要です
先にパソコンへ Python (uv) を入れてください(1 回だけ) · パソコン版 Claude アプリ(Windows または Mac)のみ。Web やスマホでは使えません
パソコン版 Claude アプリの設定ファイルを開く
SettingsDeveloperEdit Config
この設定を貼り付けて保存
{ "mcpServers": { "surgical-context": { "command": "uvx", "args": [ "surgical-context-mcp" ] } } }Claude を終了してもう一度開く
試してみる
Surgical Context MCP を使って、私に何ができるか教えて、1 つやってみせて✓ Claude が Surgical Context MCP を使っていると言うか、回答に Surgical Context MCP のツール名が出れば接続成功です
メニュー名は 2026年11月11日 に Anthropic のヘルプページで確認 · アプリのバージョンにより画面が少し違うことがあります
ChatGPT はまだ Surgical Context MCP につなげません
Surgical Context MCP はパソコンに入れて使うものですが、ChatGPT は Web 上で動くサーバーにしかつなげません
代わりにできること
A · Surgical Context MCP につなげるアプリを使う
- 先にパソコンへ Python (uv) を入れてください(1 回だけ) · パソコン版 Claude アプリ(Windows または Mac)のみ。Web やスマホでは使えません
- 先にパソコンへ Python (uv) を入れてください(1 回だけ)
- 先にパソコンへ Python (uv) を入れてください(1 回だけ)
- 先にパソコンへ Python (uv) を入れてください(1 回だけ)
B · 開発者ツール の中で ChatGPT につなげる別のサーバー
同じカテゴリでよく使われているものから、キーなしでアドレスだけでつなげるものを選びました
- Sentry✓ ChatGPT
- Compiler Explorer✓ ChatGPT
- GitDiagram✓ ChatGPT
Claude Code につなげますが、先に準備が必要です
先にパソコンへ Python (uv) を入れてください(1 回だけ)
ターミナルを開く
Mac:Command+スペースで Terminal と入力 · Windows:PowerShell を開く
このコマンドを貼り付けて Enter
claude mcp add --scope user surgical-context -- uvx surgical-context-mcpClaude Code で /mcp と入力
Surgical Context MCP が一覧にあり、接続済みと表示されれば OK です
試してみる
Surgical Context MCP を使って、私に何ができるか教えて、1 つやってみせて✓ Claude Code が Surgical Context MCP を使っていると言うか、回答に Surgical Context MCP のツール名が出れば接続成功です
メニュー名は 2026年11月11日 に Anthropic のヘルプページで確認 · アプリのバージョンにより画面が少し違うことがあります
Cursor につなげますが、先に準備が必要です
先にパソコンへ Python (uv) を入れてください(1 回だけ)
Cursor の AI チャットを Agent モードで開く
試してみる
Surgical Context MCP を使って、私に何ができるか教えて、1 つやってみせて✓ Cursor が Surgical Context MCP を使っていると言うか、回答に Surgical Context MCP のツール名が出れば接続成功です
メニュー名は 2026年11月11日 に Cursor のヘルプページで確認 · アプリのバージョンにより画面が少し違うことがあります
VS Code につなげますが、先に準備が必要です
先にパソコンへ Python (uv) を入れてください(1 回だけ)
VS Code の AI チャットを Agent モードで開く
試してみる
Surgical Context MCP を使って、私に何ができるか教えて、1 つやってみせて✓ VS Code が Surgical Context MCP を使っていると言うか、回答に Surgical Context MCP のツール名が出れば接続成功です
メニュー名は 2026年11月11日 に VS Code のヘルプページで確認 · アプリのバージョンにより画面が少し違うことがあります
Windsurf、Zed、Gemini CLI など MCP を使える他のアプリは追加方法がそれぞれ違います。アプリ一覧で確認してください
JSON 設定は下の「開発者向け」にあります
開発者向け:ターミナルのコマンドと JSON 設定
パソコンにインストール
Claude Code
claude mcp add --scope user surgical-context -- uvx surgical-context-mcpClaude Desktop (claude_desktop_config.json)
{
"mcpServers": {
"surgical-context": {
"command": "uvx",
"args": [
"surgical-context-mcp"
]
}
}
}Cursor (~/.cursor/mcp.json)
{
"mcpServers": {
"surgical-context": {
"command": "uvx",
"args": [
"surgical-context-mcp"
]
}
}
}VS Code (mcp.json)
{
"servers": {
"surgical-context": {
"type": "stdio",
"command": "uvx",
"args": [
"surgical-context-mcp"
]
}
}
}この設定は、作者のレジストリ登録情報から作成しています。READMEと違う場合は、READMEに従ってください。
ひと目でわかる
使えるアプリ
このサーバーのつなぎ方と、各アプリの公式ドキュメントに基づきます。2026年11月10日に確認。
パソコン上で動かせるアプリ
ClaudeGooseLM StudioMsty StudioCherry StudioCursorVS Code + GitHub CopilotVisual StudioWindsurf (Devin Desktop)ZedKiroClineContinueJetBrains AI AssistantClaude CodeCodex CLIGemini CLIOpenCodenodecodeWarpLibreChatRaycast
できること
パソコンで動くサーバーです。インストールすると、ツール一覧がAIアプリに表示されます。
基本チェックi
誰でも見られる情報をチェックしており、コードは読んでいません。当てはまらない項目は数に入れていません。 · 2026年11月12日にチェック
- ✓ 合格
作者とリポジトリが一致
レジストリ名は、リポジトリを所有するGitHubアカウント erayerturk で確認済みです
- ✓ 合格
今もメンテナンスされている
コードの最終更新:11 日前
- ✓ 合格
ライセンスがある
MITを使用
- – 対象外
エンドポイントが応答する
これはパソコンで動くため、インターネット上のエンドポイントはありません
- – 対象外
OAuthでサインイン
パソコンで動き、代わりにローカルの設定を使います
- … 未チェック
ツールの説明に隠れた指示がない
パソコンで動くサーバーです。ツール一覧を読み取れるのは、インターネット上のエンドポイントがある場合だけです
話し合い
質問、コツの共有、使えないことの報告ができます。「役に立った」の多い順です。
ユーザーレビュー
まだレビューはありません
開発者ツールのほかのサーバーとの比較i
- このカテゴリのほかの5800件のうち83%よりスターが多い
- このカテゴリのほかの5800件のうち67%より最近レジストリに公開
- 基本チェックの結果が、このカテゴリのほかの5800件のうち100%と同じかそれ以上
レジストリでこのカテゴリにある有効なすべてのサーバーと比較しています。スターは、公開者がリポジトリの所有者である場合だけ数えます。
よくある質問
Surgical Context MCPは安全ですか?
当てはまる基本チェック3項目のうち3項目に合格しました。コードは読んでいません。キーやトークンを追加する前に、サーバーがどんなアクセスを求めているかを確認し、必要な権限だけを持つキーを使ってください。
どんなキーやコードが必要ですか?
レジストリには必須のキーは載っていません。ただし、最初に使うときにサインインを求めるサーバーもあります。
パソコンで動きますか、それともクラウドですか?
あなたのパソコンで動きます。必要なときにAIアプリが起動し、データは作者のサーバーを通りません(サーバー自体がオンラインサービスを呼び出す場合を除きます)。
今もメンテナンスされていますか?
GitHubリポジトリの最終更新は11 日前、最新バージョン(0.1.0)がレジストリに届いたのは11 日前です。
どのアプリで使えますか?
Claude Desktop、Claude Code、Cursor、VS CodeなどのMCP対応アプリで使えます。パソコンにPython (uv)も必要です。
代わりに使えるものは?
同じカテゴリには:REA, GitHub, Serena MCP: the IDE for your agent
同じカテゴリのほかの候補
同じカテゴリで、ほかの作者が作ったサーバー。スターの多い順。
カードの見方:↓ 週あたりのダウンロードi★ GitHubスターi3つの柱:レビュー · チェック · 利用状況i更新=最新バージョンをレジストリに公開した日i
GitHub
Connect AI assistants to GitHub - manage repos, issues, PRs, and workflows through natural language.
Serena MCP: the IDE for your agent
A powerful toolkit for coding, providing semantic retrieval and editing capabilities.
作者のREADME
READMEを開く
作者のリポジトリから書かれたとおりにコピーしたものです。PopNx MCPは内容を確認・推奨していません。HTML、画像、スクリプトは取り除いています。リンクはこのサイトの外へ移動します。
surgical-context-mcp — Surgical AST Code Context & Knowledge Graph for AI Coding Agents
Stop feeding 3,000-line files into your LLM context window.
surgical-context-mcpis a zero-LLM-cost, embedded SQLite + Tree-sitter Code Knowledge Graph and MCP Server that gives AI coding agents (Claude Code, Cursor, Windsurf, Cline, Claude Desktop) the exact surgical context they need to edit, refactor, and navigate codebases safely — cutting token consumption by 70–95% without sacrificing code quality.
Real run on this repo: editing a function in a 1,264-line file costs ~3.7k tokens instead of ~13.3k (−72%) — and you still get the skeleton, callers and helpers.
⚡ Quick Start (30 seconds)
# 1. Install (or: pipx install / pip install surgical-context-mcp)
uv tool install surgical-context-mcp
2. Register with Claude Code
claude mcp add code-graph -- code-graph serve
3. Index your project + install the token-saving guard hook
code-graph install-hooks /path/to/your/project
That's it — your agent now calls get_edit_context instead of reading whole files. Using Cursor, Windsurf, Cline or Claude Desktop? See Step 1. Also listed on the official MCP Registry as io.github.erayerturk/surgical-context-mcp.
Table of Contents
- Quick Start (30 seconds)
- Why Use
surgical-context-mcp? - How Much Does It Save & When Should You Use It?
- Supported Languages & Ecosystem Resolvers
- How It Works (Architecture)
- Installation
- How to Use (Step-by-Step Setup Guide)
- Real Output Examples
- MCP Tools Reference
- CLI Reference
- Recommended
CLAUDE.md/.cursorrulesConfiguration
Why Use surgical-context-mcp?
The 3 Core Problems with AI Coding Agents Today
- Full-File Reads Burn Hundreds of Thousands of Tokens: When you ask an AI agent (or when it spawns subagents) to fix a bug or add a feature, its default instinct is to run
Grepand thenReadentire 1,500–3,000 line files into the context window. Because every subsequent tool call re-sends the entire conversation history (cache reads), a single large file read early in a session compounds into 100k–300k wasted tokens. - Narrow Line-Range Reads Cause Hallucinations & Code Duplication: If you force an agent to read only
lines 240–260of a file to save tokens, the agent becomes blind to:
- Class attributes,
self.xfields,@onready/@exportvariables, constants, andstruct/interfacedefinitions at the top of the file. - Helper functions that already exist in the same file (causing the LLM to write duplicate code).
- How callers actually pass arguments to the function (
±5lines around call sites). - The file's coding style (indentation, typing conventions, error handling idioms).
- Pure Static AST Graphs Miss Dynamic Dispatch & Scene/Template Wiring: Standard call graphs only see static
foo()calls. If a function is invoked viagetattr(obj, "foo")in Python,call("foo")or a.tscnsignal connection in Godot,SendMessage("foo")in Unity/C#, or referenced in a.vue/.html/.protofile, a naive graph reports *"0 callers — safe to delete"*, breaking production code.
How surgical-context-mcp Solves All Three
- `get_edit_context(symbol)` — One Call Before Any Edit: Instead of reading a 2,500-line file, the agent makes one MCP call (
get_edit_context) and receives a strictly budgeted (≤ 4,000tokens) surgical package containing:
- Target Function Full Body (with exact line numbers for
Edit) - File Skeleton (all imports,
interface/struct/enumblocks, class fields, constants — without other function bodies) - Used Members & Direct Callees (definitions of class fields used by the target function + full bodies of short same-file helpers
≤ 25lines) - Direct Callers (`d=1`, `±5` Line Windows) (exact call-site context without dumping 200-line caller functions)
- Other Function Signatures in the File (so the agent reuses existing helpers instead of duplicating them)
- Style Hints & Coverage Warnings (flags dynamic string calls,
.tscnconnections, templates, and protocol references)
- `check_rename_or_delete(symbol)` — One Call Before Any Refactor: Checks AST callers (
exact/scoped), inheritance overrides across parent/child classes,.tscn/template connections, signalemit/connectsites, and workspace-wide dynamic string references. - Cross-Language Contracts (`shares_contract`) — Server ↔ Client ↔ Config in One Call:
- Protocol Opcodes (`contract::opcode::0xCC`): Automatically links hex opcode constants across languages (e.g., Go
OpSGMOnline = 0xCCand GDScript/TypeScriptconst S_GM_ONLINE = 0xCC), so querying either constant shows both server senders and client packet handlers together. - Config & Schema Keys (`contract::config:: `): Automatically links Go struct
json:"max_chars_per_ip"field tags, frontend/panel schema strings ('multi_guard.max_chars_per_ip'), andseed/*.jsonconfig entries ("max_chars_per_ip": 2) into a single shared contract node. - Data, Seed & Translation (`i18n`) Graph (`check_translations`): Indexes
seed/*.json,shared/maps/*.json,locales/*.json, and.pofiles alongside code. Linkstr("...")andnoticeT(..., "n.x")calls to locale definitions and audits missing keys, accidental raw non-key literals,%d/%s/{}placeholder count mismatches, and unused locale keys. - Automated Test Discovery (`tests_for`) & Git Diff Blast Radius (`get_diff_impact`):
tests_for(symbol)identifies every test exercising a symbol and returns the exact runnable CLI command (go test ./pkg -run '^TestFoo$',godot --headless --path client -s tests/...,pytest ... -k ...).get_diff_impact(base_ref="HEAD")parsesgit diffhunks, maps changed lines to modified AST symbols, and reports their callers, affected cross-language contracts, and runnable test commands in one call — built for code-review subagents (final-reviewer).- Concept Search & Engine Lifecycle Noise Suppression:
- Indexes inline/preceding comments and docstrings (
doc_comment) so searching by concept (e.g."attack stat") findsKOAP(// attack power stat bonus). - Recognizes engine-invoked virtual callbacks (
_ready,_draw,_process,_physics_process,_input,Awake,Update) and suppresses false text-match noise warnings when AST upstream is empty. - Direct Token Savings Telemetry (`get_token_savings`): Every MCP/CLI query records its returned token count vs. the raw token size of touched files in SQLite (
usage_telemetry), answering *"How many tokens didcode-graphsave?"* with direct measurements instead of estimates. - Zero LLM Indexing Cost & Sub-Second Speed: Built on native C Tree-sitter grammars and embedded SQLite (
WALmode). Indexes ~600 files in `< 0.6` seconds using0API tokens, and automatically refreshes modified files (mtime+SHA-1) on every query. - Enforced via Claude Code `PreToolUse` Hook: Includes a built-in hook guard (
code-graph install-hooks) that blocks unbounded `Read` calls on files `> 300` lines and returns the file's AST symbol table (Lstart-end: signature), ensuring both main agents and subagents stay on the surgical path.
How Much Does It Save & When Should You Use It?
1. Token & Cost Economics (Single-Turn vs. Multi-Turn Compounding Savings)
In agentic coding tools (Claude Code, Cursor, Cline), every tool call re-sends the entire conversation history up to that point. When an agent reads a 2,500-line file (~22,000 tokens) on Turn 2 of a 12-turn coding task, those 22,000 tokens are billed on Turn 2, Turn 3, Turn 4 ... all the way to Turn 12 (22,000 × 10 = 220,000 cumulative context tokens).
By replacing full-file reads with get_edit_context (~2,500–3,500 tokens), surgical-context-mcp prevents context bloat from compounding across turns.
Benchmark Across Common Developer Tasks
*(Measured on a 593-file multi-language repository: 2,607-line Godot client controller + Go backend + JS web dashboard)*
| Developer Scenario | Standard Agent (Read + Grep) | With surgical-context-mcp | Direct Token Savings | 10-Turn Compounded Savings |
|---|---|---|---|---|
| 1. Initial Repo Orientation ("How is this codebase structured?") | ~18,500 tokens (multiple ls, Glob, Read calls) | `~650` tokens (GRAPH_REPORT.md / get_architecture_map) | 96% fewer tokens | ~178,000 tokens saved |
2. Modifying a Function in a Large File (2,607 lines) | ~22,400 tokens (reads whole target file + 1 caller file) | `~2,900` tokens (get_edit_context returns skeleton + body + callers) | 87% fewer tokens | ~195,000 tokens saved |
| 3. Tracing an End-to-End Request / Event Flow (Client -> Packet -> Server Handler) | ~31,000 tokens (grepping strings and reading 4–6 files) | `~1,200` tokens (find_flow + get_symbol_impact) | 96% fewer tokens | ~298,000 tokens saved |
| 4. Safe Refactoring / Dead-Code Deletion ("Can I delete or rename this method?") | ~14,000 tokens (grepping & reading candidate files; still misses dynamic refs) | `~450` tokens (check_rename_or_delete checks AST + overrides + .tscn + dynamic strings) | 97% fewer tokens | ~135,000 tokens saved |
| 5. Multi-Subagent Parallel Execution (Spawning 2–3 subagents for backend/frontend) | 200,000–350,000 tokens (each subagent independently reads huge files) | `35,000–60,000` tokens (PreToolUse hook blocks >300L reads in all subagents) | 80–85% fewer tokens | Prevents rate-limits & context compaction |
2. When Does surgical-context-mcp Provide the Biggest Gains?
High-Impact Scenarios (80%–97% Savings & Higher Code Accuracy)
- Large or Monolithic Source Files (`300` to `5,000+` lines): Game controllers (
main.gd,PlayerController.cs), large backend services (`s