agent-lsp
agent-lsp is an MCP server that orchestrates real language servers (gopls,
rust-analyzer, tsserver, pyright, jdtls, etc.) into agent-native workflows.
It is not itself a language server — it manages them, keeps a warm index
across sessions, and exposes batch operations, speculative (in-memory) editing,
and multi-step pipelines as MCP tools (65 tools, 30 CI-verified languages).
Use it instead of grep/read loops whenever you need semantic answers about
code: who calls X, what implements an interface, what breaks if I rename Y,
does this edit introduce errors. One blast_radius call replaces 20+ sequential
LSP calls; structured responses use far fewer tokens than grep on large repos.
When to use
- "Find all callers / references of this symbol" → semantic, not text search.
- Renaming a function/type/variable across a whole workspace, safely.
- Before changing/deleting a signature: assess blast radius / impact first.
- Preview an edit's diagnostic delta before writing to disk (speculative).
- Go-to-implementation (type-checked interface satisfaction grep cannot do).
- Detect dead code; verify a change with diagnostics + build + tests.
Skip it for trivial single-file text tweaks where grep/Edit is enough.
Setup
curl -fsSL https://raw.githubusercontent.com/blackwell-systems/agent-lsp/main/install.sh | sh
agent-lsp init # registers the MCP server with your agent
Register as an MCP server in the agent config; tools then appear as
mcp__lsp__<tool>. Language servers (gopls, rust-analyzer, …) must be installed
for the languages you target. GCF token-compact output is on by default; set
AGENT_LSP_OUTPUT_FORMAT=json to revert to JSON.
If LSP is not yet running for a workspace, call mcp__lsp__start_lsp with the
workspace root. Workspace is auto-inferred from file paths; explicit start is
only needed when switching roots.
Key tools
blast_radius — one call: all exported symbols in a file + callers
(test vs non-test partitioned) + reference counts.
go_to_symbol — resolve a dot-notation symbol ("pkg.Func", "Type.Method")
to file/line/column.
find_references, find_callers (incoming/outgoing), type_hierarchy.
inspect_symbol (hover), go_to_implementation, list_symbols.
prepare_rename + rename_symbol (supports dry_run: true) → apply_edit.
preview_edit — speculative single-file edit, returns net_delta (errors
introduced minus resolved) without touching disk.
simulate_chain — speculative sequence of dependent edits; returns
cumulative_delta and safe_to_apply_through_step.
get_diagnostics, suggest_fixes (code actions), format_document.
run_build, run_tests, get_tests_for_file (source→test correlation).
replace_symbol_body — replace a whole function/method by name, no position math.
get_server_capabilities — check which optional tools the server supports.
Core workflows (the 24 bundled skills)
The repo ships per-task skills under skills/<name>/SKILL.md. The high-value ones:
- lsp-impact (read-only):
blast_radius for a file, or go_to_symbol →
find_references → find_callers/type_hierarchy for a symbol. Decide risk:
0 refs = likely dead code; 1–5 files low; 6–20 medium; >20 high (use deprecation path).
- lsp-explore (read-only): hover + implementations + call hierarchy +
references in one pass to understand an unfamiliar symbol.
- lsp-rename: Phase 1 preview —
prepare_rename, find_references,
rename_symbol(dry_run=true); HARD STOP for user [y/n]. Phase 2 execute —
capture diagnostics, rename_symbol, apply_edit, re-check diagnostics.
- lsp-safe-edit: capture BEFORE diagnostics →
preview_edit/simulate_chain
→ apply only if net_delta ≤ 0 → AFTER diagnostics → suggest_fixes if new errors.
- lsp-refactor: end-to-end pipeline = impact → speculative preview → apply →
build verify → run correlated tests, with abort gates at each phase.
- lsp-verify: three layers (diagnostics +
run_build + run_tests), run in
parallel, ranked by severity; build errors and test failures are blocking.
Others: lsp-dead-code, lsp-cross-repo, lsp-extract-function, lsp-fix-all,
lsp-format-code, lsp-generate, lsp-implement, lsp-onboard, lsp-test-correlation,
lsp-understand, lsp-architecture, lsp-concurrency-audit, etc. Pull a specific
skill from skills/<name>/SKILL.md in the source repo when needed.
Gotchas
- Always gate destructive ops. Rename and refactor require a
[y/n] stop
after showing the preview; never apply with net_delta > 0 without confirmation.
- Speculate before disk. Use
preview_edit/simulate_chain to check the
diagnostic delta first; abort if errors are introduced.
run_tests on big repos can blow the context window. It may write to a
file — don't read it whole; grep for ^(FAIL|--- FAIL) or scope tests to the
correlated test files from get_tests_for_file.
- Capability-gate optional tools.
find_callers, type_hierarchy,
go_to_implementation aren't supported by every language server — check
get_server_capabilities and skip (don't fail) when absent.
- Symbol paths use dot notation (
"codec.Encode", "Buffer.Reset").
position_pattern with @@ is an agent-lsp extension; fall back to line/column.
1---2name: agent-lsp3description: "Use when you need semantic code intelligence on a real codebase — find all callers/references, rename a symbol safely across the workspace, assess blast radius/impact before changing a function or type, preview an edit's diagnostics before touching disk, go-to-implementation, detect dead code, or run LSP-diagnostics + build + tests to verify a change. Trigger words: blast radius, find callers, rename symbol, who calls this, impact analysis, safe edit, preview edit, simulate, go to implementation, LSP, language server, gopls/rust-analyzer/tsserver, refactor across files."4version: 1.0.05license: MIT6tags: [lsp, code-intelligence, refactor, rename, references, mcp, diagnostics, dead-code]7source: https://github.com/blackwell-systems/agent-lsp8derived_from: awesomeclaude9prerequisites:10 commands: [agent-lsp]11metadata:12 source: https://skillmd.com/skills/aashutosh396/agent-lsp13---1415# agent-lsp1617`agent-lsp` is an **MCP server** that orchestrates real language servers (gopls,18rust-analyzer, tsserver, pyright, jdtls, etc.) into agent-native workflows.19It is **not** itself a language server — it manages them, keeps a warm index20across sessions, and exposes batch operations, speculative (in-memory) editing,21and multi-step pipelines as MCP tools (65 tools, 30 CI-verified languages).2223Use it instead of grep/read loops whenever you need *semantic* answers about24code: who calls X, what implements an interface, what breaks if I rename Y,25does this edit introduce errors. One `blast_radius` call replaces 20+ sequential26LSP calls; structured responses use far fewer tokens than grep on large repos.2728## When to use2930- "Find all callers / references of this symbol" → semantic, not text search.31- Renaming a function/type/variable across a whole workspace, safely.32- Before changing/deleting a signature: assess blast radius / impact first.33- Preview an edit's diagnostic delta *before* writing to disk (speculative).34- Go-to-implementation (type-checked interface satisfaction grep cannot do).35- Detect dead code; verify a change with diagnostics + build + tests.3637Skip it for trivial single-file text tweaks where grep/Edit is enough.3839## Setup4041```bash42curl -fsSL https://raw.githubusercontent.com/blackwell-systems/agent-lsp/main/install.sh | sh43agent-lsp init # registers the MCP server with your agent44```4546Register as an MCP server in the agent config; tools then appear as47`mcp__lsp__<tool>`. Language servers (gopls, rust-analyzer, …) must be installed48for the languages you target. GCF token-compact output is on by default; set49`AGENT_LSP_OUTPUT_FORMAT=json` to revert to JSON.5051If LSP is not yet running for a workspace, call `mcp__lsp__start_lsp` with the52workspace root. Workspace is auto-inferred from file paths; explicit start is53only needed when switching roots.5455## Key tools5657- `blast_radius` — one call: all exported symbols in a file + callers58 (test vs non-test partitioned) + reference counts.59- `go_to_symbol` — resolve a dot-notation symbol (`"pkg.Func"`, `"Type.Method"`)60 to file/line/column.61- `find_references`, `find_callers` (incoming/outgoing), `type_hierarchy`.62- `inspect_symbol` (hover), `go_to_implementation`, `list_symbols`.63- `prepare_rename` + `rename_symbol` (supports `dry_run: true`) → `apply_edit`.64- `preview_edit` — speculative single-file edit, returns `net_delta` (errors65 introduced minus resolved) without touching disk.66- `simulate_chain` — speculative sequence of dependent edits; returns67 `cumulative_delta` and `safe_to_apply_through_step`.68- `get_diagnostics`, `suggest_fixes` (code actions), `format_document`.69- `run_build`, `run_tests`, `get_tests_for_file` (source→test correlation).70- `replace_symbol_body` — replace a whole function/method by name, no position math.71- `get_server_capabilities` — check which optional tools the server supports.7273## Core workflows (the 24 bundled skills)7475The repo ships per-task skills under `skills/<name>/SKILL.md`. The high-value ones:7677- **lsp-impact** (read-only): `blast_radius` for a file, or `go_to_symbol` →78 `find_references` → `find_callers`/`type_hierarchy` for a symbol. Decide risk:79 0 refs = likely dead code; 1–5 files low; 6–20 medium; >20 high (use deprecation path).80- **lsp-explore** (read-only): hover + implementations + call hierarchy +81 references in one pass to understand an unfamiliar symbol.82- **lsp-rename**: Phase 1 preview — `prepare_rename`, `find_references`,83 `rename_symbol(dry_run=true)`; HARD STOP for user `[y/n]`. Phase 2 execute —84 capture diagnostics, `rename_symbol`, `apply_edit`, re-check diagnostics.85- **lsp-safe-edit**: capture BEFORE diagnostics → `preview_edit`/`simulate_chain`86 → apply only if `net_delta ≤ 0` → AFTER diagnostics → `suggest_fixes` if new errors.87- **lsp-refactor**: end-to-end pipeline = impact → speculative preview → apply →88 build verify → run correlated tests, with abort gates at each phase.89- **lsp-verify**: three layers (diagnostics + `run_build` + `run_tests`), run in90 parallel, ranked by severity; build errors and test failures are blocking.9192Others: lsp-dead-code, lsp-cross-repo, lsp-extract-function, lsp-fix-all,93lsp-format-code, lsp-generate, lsp-implement, lsp-onboard, lsp-test-correlation,94lsp-understand, lsp-architecture, lsp-concurrency-audit, etc. Pull a specific95skill from `skills/<name>/SKILL.md` in the source repo when needed.9697## Gotchas9899- **Always gate destructive ops.** Rename and refactor require a `[y/n]` stop100 after showing the preview; never apply with `net_delta > 0` without confirmation.101- **Speculate before disk.** Use `preview_edit`/`simulate_chain` to check the102 diagnostic delta first; abort if errors are introduced.103- **`run_tests` on big repos can blow the context window.** It may write to a104 file — don't read it whole; grep for `^(FAIL|--- FAIL)` or scope tests to the105 correlated test files from `get_tests_for_file`.106- **Capability-gate optional tools.** `find_callers`, `type_hierarchy`,107 `go_to_implementation` aren't supported by every language server — check108 `get_server_capabilities` and skip (don't fail) when absent.109- **Symbol paths use dot notation** (`"codec.Encode"`, `"Buffer.Reset"`).110 `position_pattern` with `@@` is an agent-lsp extension; fall back to line/column.