Agent Lsp

io.github.blackwell-systems由 GitHub 帳號 blackwell-systems 發布v0.24.2更新於 Nov 4, 2026

Language servers as 66 code-intelligence tools for AI agents, CI-verified on 32 languages.

已驗證STDIO僅桌面知識與記憶開發者工具

概覽

AI 產生的概覽

協調本機語言伺服器,為 AI 助理提供 66 個程式碼智慧工具:導覽、參照、影響分析、安全編輯與診斷。

可以做什麼
  • 程式碼導覽:跳至定義、宣告、實作或符號,依名稱尋找符號,檢視檔案結構,以及滑鼠停留資訊、簽章說明、補全與行內提示
  • 影響分析:尋找參照與呼叫者,產生區分測試與非測試呼叫者的影響範圍報告,跨儲存庫參照,以及依 git diff 判斷變更風險等級
  • 安全編輯:套用編輯、取代或刪除符號、格式化檔案或片段,並可在記憶體模擬工作階段中預覽變更後再寫入磁碟
  • 品質檢查:診斷訊息、程式碼動作與快速修正、伺服器指令、符號文件與原始碼,以及靜態找出相關測試檔
  • 引導式工作流程:24 個多步驟技能以 MCP 提示形式提供,可選的階段強制機制會阻擋順序錯誤的工具呼叫
適用情境
適合助理在真實程式碼庫上工作、需要型別感知的導覽、重構與影響分析,而非反覆 grep 與讀檔的情境,尤其是大型或多語言儲存庫以及跨儲存庫重構。
執行需求
以本機程序方式執行(npm 套件或單一 Go 二進位檔),僅限桌面端。每種使用的語言都需自行安裝對應的語言伺服器並加入 PATH,例如 gopls、pyright、typescript-language-server、rust-analyzer 或 clangd。未宣告需要帳號或 API 金鑰;可選的 HTTP 模式使用 bearer 權杖。
安裝前請注意
多個工具會寫入磁碟:apply_edit、apply 為真的 commit_session、符號取代與刪除,以及重構指令。模擬工作階段與預覽是較安全的路徑。安裝腳本與 init 指令會修改 MCP 用戶端設定與指示檔,技能安裝還會附加內容到既有指示檔。可選的 HTTP 傳輸依賴必須保密的 bearer 權杖。

安裝

在 SourceWeft 中

  1. 開啟 儀表板中的 Agent Lsp,將其新增到工作區。
  2. 為需要使用其工具的對話啟用該服務。

Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。

其他 MCP 客戶端

參照 儲存庫 中的啟動說明。

README

English · 简体中文 · Русский · हिन्दी · العربية

[agent-lsp]

[CI Coverage] [Languages] [mcp-assert: passing] [Agent Skills] [downloads]
[LSP 3.17] [License] [Awesome MCP Servers] [Blackwell Systems]

Code intelligence infrastructure for AI agents. 66 tools, 32 CI-verified languages, 24 agent workflows. Single Go binary.

bash
curl -fsSL https://raw.githubusercontent.com/blackwell-systems/agent-lsp/main/install.sh | sh && agent-lsp init

What is it?

agent-lsp is an MCP server that orchestrates existing LSP servers (gopls, rust-analyzer, jdtls, etc.) into agent-native workflows.

Not an LSP server — it's an orchestration layer that manages language servers and exposes batch operations, speculative editing, and multi-step workflows via MCP tools.

Architecture:

  • Language servers (gopls, rust-analyzer, etc.) → provide code intelligence
  • agent-lsp (MCP server) → orchestrates workflows, maintains warm runtime
  • AI agents → consume via MCP protocol

Why agent-lsp?

Persistent warm runtime
Language servers stay indexed across agent sessions. First session: indexes workspace (~10s for typical projects). Subsequent sessions: instant. No cold-start penalty on each request.

Batch operations
blast_radius → one call returns all exports + all callers (test vs non-test partitioned). Without orchestration: 20+ sequential LSP calls.

Speculative editing
simulate_edit → preview changes in memory, check diagnostic delta, apply or discard. Test edits before touching disk. safe_apply_edit writes only an edit it could verify: if the preview timed out or the server was still indexing, nothing is written.

Workflow orchestration
24 skills that chain LSP operations into complete pipelines:

  • /lsp-refactor → impact analysis → preview → apply → verify build → run tests
  • /lsp-safe-edit → preview → diagnostic diff → apply if safe
  • /lsp-verify → LSP diagnostics → build → test suite

Multi-language, single session
One agent-lsp process routes .go to gopls, .ts to tsserver, .py to pyright. No reconfiguration between projects. Session persists across files and repositories. Workspace-wide queries (find_symbol, get_server_capabilities) ask every running language server, not just the default one. start_lsp can also connect to a language server that is already running (e.g. gopls -listen) and reuse its warm index.

[!TIP] Token-optimized output: Tool responses encoded in GCF instead of JSON. 30-84% fewer tokens depending on tool (up to 92.7% with session dedup). 100% LLM comprehension on every frontier model, 91.2% on complex code graphs where JSON averages 54.1%. See below for measured savings per tool.

How the pieces fit together: LSP (Language Server Protocol) is how editors get code intelligence: completions, diagnostics, go-to-definition. MCP (Model Context Protocol) is the standard way AI tools like Claude Code discover and call external tools. agent-lsp bridges the two: language server intelligence, accessible to AI agents.

Use it when

  • Building agentic code generation systems
  • Automating refactors across large codebases
  • CI tooling that needs programmatic code intelligence
  • Any workflow where sequential LSP calls are too slow or complex

What agents say

We asked AI agents to evaluate agent-lsp across 10 coding tasks (find callers, rename safely, preview edits, detect dead code) and write an honest assessment. Four different models, four independent evaluations, same conclusion:

Claude (Opus 4.6): "I would recommend agent-lsp for any workflow involving refactoring, impact analysis, or safe editing. The standout tools are blast_radius (blast radius in one call, with test/non-test partitioning that would take 5-10 grep commands to replicate), go_to_implementation (type-checked interface satisfaction that grep simply cannot do), and the simulation session workflow (speculative type-checking without touching disk, which has no grep/read equivalent at all)."

Cursor (auto): "I would recommend agent-lsp for heavy refactors and code navigation because the rename, references, implementations, call hierarchy, and simulation tools remove a lot of brittle grep/manual-edit work and make changes safer."

GPT-5.5 (via Codex): "I would recommend agent-lsp for symbol-aware work: references, implementations, rename previews, diagnostics, and large-file structure are materially faster and less error-prone than grep/read loops."

Gemini 2.5 Pro (via Gemini CLI): "I would highly recommend agent-lsp because it provides a level of semantic awareness that standard text-searching tools simply cannot match. The ability to perform high-confidence renames, find interface implementations, and preview the diagnostic impact of edits without writing to disk significantly reduces the risk of introducing regressions."

Tested, not assumed

Every other MCP-LSP implementation lists supported languages in a config file. None of them run the actual language server in CI to verify it works.

agent-lsp CI runs 32 real language servers against real fixture codebases on every push, and all 32 pass end to end: Go, Python, TypeScript, Rust, Java, C, C++, C#, Ruby, PHP, Kotlin, Swift, Scala, Zig, Lua, Elixir, Gleam, Clojure, Dart, Terraform, Nix, Prisma, SQL, MongoDB, MQL, and more. When we say "works with gopls," that's a verified, automated claim, not a hope.

Speculative execution

Simulate changes in memory before writing to disk. No other MCP-LSP implementation has this.

preview_edit previews the diagnostic impact of any edit. You see exactly what breaks before the file is touched. simulate_chain evaluates a sequence of dependent edits (rename a function, update all callers, change the return type) and reports which step first introduces an error.

8 speculative execution tools. See docs/guide/speculative-execution.md for the full workflow.

Interactive refactoring

Some refactorings need answers before the language server can compute them: which struct tags to add and how to name them, which interface to implement, where a declaration should move. gopls v0.24 asks these questions through a new LSP extension (golang/go#76331), which editors show as dialogs. agent-lsp is a client for it built for agents: refactor returns the questions as a typed form (choices, defaults, a searchable list for the interface), the agent answers, and the server computes the edit. agent-lsp captures that edit before it is written, so dry_run previews it.

refactor(file, line, column)                          → available refactoringsrefactor(..., action: "Add struct tags")              → questions: tags (default "json"), naming style (camelCase, snake_case, ...)refactor(..., answers: {addTags: "json", transform: "snakecase"})  → applied

See refactor in the tool reference.

Token savings

Structured LSP responses use 5-34x fewer tokens than grep/read on the same tasks. On HashiCorp Consul (319K lines), a blast-radius analysis uses 17.7MB via grep vs 841KB via LSP, reducing 5,534 tool calls to 119. Savings scale with codebase size. See docs/guide/token-savings.md for the full experiment across five codebases.

Token-optimized output (GCF)

Tool responses are encoded in GCF (Graph Compact Format) instead of JSON. GCF eliminates field-name repetition, identifier repetition, and per-record structural overhead.

ProfileToolsSavings vs JSON
TabularOther structured results (find_references, diagnostics, detect_changes, ...)30-51%
Graphlist_symbols, find_symbol, blast_radius, find_callers, explore_symbol, type_hierarchy, get_cross_repo_references79-84%
Graph + session dedupSame, via gcf-proxy --session92.7% (5th call)

Workspace edits (rename and refactor previews) are always JSON, so they round-trip into apply_edit byte-exact. Grouped/nested responses (callers under a symbol, diagnostics with related info) tabularize too, for ~14% over JSON on that shape (details).

GCF is enabled by default. To revert to JSON:

bash
export AGENT_LSP_OUTPUT_FORMAT=json

Benchmark: go run scripts/gcf-benchmark.go. See docs/guide/gcf-integration.md for architecture details.

GCF: gcformat.com · Spec · Go · Python · TypeScript · Playground

Why orchestration matters

AI agents make incorrect code changes because they can't see the full picture: who calls this function, what breaks if I rename it, does the build still pass. Language servers have the answers, but raw LSP tools require 20+ sequential calls and complex orchestration logic.

agent-lsp solves this by encoding correct multi-step operations into single calls and skills. blast_radius does what would take an agent 20+ calls in one. /lsp-refactor chains impact → preview → apply → verify → test without per-prompt orchestration.

Persistent daemon mode

Python and TypeScript projects need minutes of background indexing before find_references works. agent-lsp automatically spawns a persistent daemon broker that survives between sessions, so the workspace stays indexed. First session: daemon starts and indexes (~10s for FastAPI). Subsequent sessions: instant connection to the warm daemon. Auto-exits after 30 minutes of inactivity. Go, Rust, and other fast-indexing languages bypass this entirely (zero overhead).

Phase enforcement

Skills tell agents the correct order of operations. Phase enforcement makes the runtime block violations instead of trusting the agent to follow instructions.

When an agent activates a skill, every tool call is checked against the current phase's permissions. Calling apply_edit during blast-radius analysis doesn't silently proceed; it returns an error with specific recovery guidance, followed by a JSON copy of the same fields:

Phase violation: apply_edit is forbidden in the "blast_radius" phase
Recovery: apply_edit becomes available in the "apply" phase. Next phase is "speculative_preview". Allowed tools: [open_document get_diagnostics preview_edit simulate_chain]

Phases advance automatically as the agent calls tools from later phases.

No other MCP tool provider enforces workflow ordering at runtime. See docs/guide/phase-enforcement.md.

Concurrency analysis

The inspector includes 4 concurrency checks that work across 25 languages in 4 concurrency families (goroutine, thread, async, actor):

  • Unrecovered concurrent entry: goroutines/threads/tasks without recovery
  • Unchecked shared state: bare type assertions on sync.Map, ConcurrentHashMap
  • Channel never closed: channels/queues created but never closed (goroutine leaks)
  • Shared field without sync: fields accessed from concurrent contexts without synchronization

blast_radius annotates symbols with sync_guarded: true when the parent type has a mutex. find_callers with cross_concurrent: true traces call chains through goroutine/thread boundaries. The /lsp-concurrency-audit skill produces a field-level safety report for any type.

Auto-diagnostics

Symbol edit tools (replace_symbol_body, insert_after_symbol, insert_before_symbol, safe_delete_symbol) automatically return errors_after and warnings_after counts. Agents know immediately whether an edit broke something without a separate get_diagnostics call.

safe_apply_edit combines preview + apply in one call: previews speculatively, applies to disk only if net_delta == 0 (no new errors). It also refuses edits it could not verify (a timed-out preview or a server still indexing) and writes only the content it previewed: if the file changed in between, nothing is written. One tool call instead of three.

Works with

AI ToolTransportSetup
Claude Codestdioagent-lsp init
Cursorstdioagent-lsp init
Windsurfstdioagent-lsp init
Gemini CLIstdioagent-lsp init
Codex and the ChatGPT desktop appstdioagent-lsp init
Continuestdiomanual config
Clinestdioagent-lsp init
Pistdioagent-lsp init + pi install npm:pi-mcp-adapter
Any MCP clientStreamable HTTPAGENT_LSP_TOKEN=secret agent-lsp --http --port 8080

See docs/getting-started/mcp-clients.md for copy-paste configs.

Skills

Raw tools get ignored. Skills get used. Each skill encodes the correct tool sequence so workflows actually happen without per-prompt orchestration instructions. Skills are available as AgentSkills slash commands and as MCP prompts via prompts/list / prompts/get for any MCP client.

See docs/guide/skills.md for full descriptions and usage guidance.

Before you change anything

SkillPurpose
/lsp-impactBlast-radius analysis before touching a symbol or file
/lsp-implementFind all concrete implementations of an interface
/lsp-dead-codeDetect zero-reference exports before cleanup

Editing safely

SkillPurpose
/lsp-safe-editSpeculative preview before disk write; before/after diagnostic diff; surfaces code actions on errors
/lsp-simulateTest changes in-memory without touching the file
/lsp-edit-symbolEdit a named symbol without knowing its file or position
/lsp-edit-exportSafe editing of exported symbols, finds all callers first
/lsp-renameprepare_rename safety gate, preview all sites, confirm, apply atomically

Getting started

SkillPurpose
/lsp-architectureStructural architecture overview: languages, package map, entry points, dependency graph, and hotspots
/lsp-onboardFirst-session project onboarding: detect languages, map packages, find entry points and hotspots, check diagnostics

Understanding unfamiliar code

SkillPurpose
/lsp-explore"Tell me about this symbol": hover + implementations + call hierarchy + references in one pass
/lsp-understandDeep-dive Code Map for a symbol or file: type info, call hierarchy, references, source
/lsp-docsThree-tier documentation: hover → offline toolchain → source
/lsp-cross-repoFind all usages of a library symbol across consumer repos
/lsp-local-symbolsFile-scoped symbol list, usage search, and type info

After editing

SkillPurpose
/lsp-verifyDiagnostics + build + tests after every edit
/lsp-fix-allApply quick-fix code actions for all diagnostics in a file
/lsp-test-correlationFind and run only tests that cover an edited file
/lsp-format-codeFormat a file or selection via the language server formatter

Generating code

SkillPurpose
/lsp-generateTrigger server-side code generation (interface stubs, test skeletons, mocks)
/lsp-extract-functionExtract a code block into a named function via code actions

Full workflow

SkillPurpose
/lsp-refactorEnd-to-end refactor: blast-radius → preview → apply → verify → test
/lsp-inspectFull code quality audit (12 checks): dead symbols, test coverage, error handling, doc drift, concurrency safety
/lsp-concurrency-auditField-level concurrency safety audit for a type: traces concurrent access, flags unsynced fields

Docker

Stdio mode (MCP client spawns the container directly):

bash
# Godocker run --rm -i -v /your/project:/workspace ghcr.io/blackwell-systems/agent-lsp:go go:gopls
# TypeScriptdocker run --rm -i -v /your/project:/workspace ghcr.io/blackwell-systems/agent-lsp:typescript typescript:typescript-language-server,--stdio
# Pythondocker run --rm -i -v /your/project:/workspace ghcr.io/blackwell-systems/agent-lsp:python python:pyright-langserver,--stdio

HTTP mode (persistent service, remote clients connect over Streamable HTTP):

bash
docker run --rm \  -p 8080:8080 \  -v /your/project:/workspace \  -e AGENT_LSP_TOKEN=your-secret-token \  ghcr.io/blackwell-systems/agent-lsp:go \  --http --port 8080 --listen-addr 0.0.0.0 go:gopls

The server binds 127.0.0.1 by default, so pass --listen-addr 0.0.0.0 inside a container for the port mapping to reach it. Images run as a non-root user (uid 65532) by default. Set AGENT_LSP_TOKEN via environment variable, never --token on the command line. Images are also mirrored to Docker Hub (blackwellsystems/agent-lsp). See DOCKER.md for the full tag list, HTTP mode setup, and security hardening options.

Setup

Step 1: Install agent-lsp

bash
curl -fsSL https://raw.githubusercontent.com/blackwell-systems/agent-lsp/main/install.sh | sh
Alternative install methods

macOS / Linux

bash
brew install blackwell-systems/tap/agent-lsp

Windows

powershell
# PowerShell (no admin required)iwr -useb https://raw.githubusercontent.com/blackwell-systems/agent-lsp/main/install.ps1 | iex
# Scoopscoop bucket add blackwell-systems https://github.com/blackwell-systems/agent-lspscoop install blackwell-systems/agent-lsp
# Wingetwinget install BlackwellSystems.agent-lsp

All platforms

bash
# pippip install agent-lsp
# npmnpm install -g @blackwell-systems/agent-lsp
# Go installgo install github.com/blackwell-systems/agent-lsp/cmd/agent-lsp@latest

Step 2: Install language servers

Install the servers for your stack. Common ones:

LanguageServerInstall
TypeScript / JavaScripttypescript-language-servernpm i -g typescript-language-server typescript@6
Pythonpyright-langservernpm i -g pyright
Gogoplsgo install golang.org/x/tools/gopls@latest
Rustrust-analyzerrustup component add rust-analyzer
C / C++clangdapt install clangd / brew install llvm
Rubysolargraphgem install solargraph

TypeScript 7 ships without tsserver, which typescript-language-server needs, so install TypeScript 6 (typescript@6) until that changes. A project with TypeScript 6 in its own node_modules works either way.

Full list of supported languages and their CI status in docs/reference/language-support.md.

Step 3: Verify setup

bash
agent-lsp doctor

Probes each configured language server and reports capabilities. Fix any failures before proceeding. See language support for install commands and server-specific notes.

Step 4: Configure your AI tool

bash
agent-lsp init

Detects language servers on your PATH, asks which AI tool you use, writes the correct MCP config, and installs skill awareness rules for your AI provider (CLAUDE.md for Claude Code, .cursor/rules/ for Cursor, .clinerules for Cline, .windsurfrules for Windsurf, GEMINI.md for Gemini CLI, AGENTS.md for Pi and Codex). For CI or scripted use: agent-lsp init --non-interactive.

For Claude Code, choose the project target (1, writes .mcp.json in the current directory) or the user scope (2, all projects: registers the server with claude mcp add --scope user when the claude CLI is installed, otherwise adds it to ~/.claude.json). init only sets the agent-lsp entry; every other server and setting in an existing config file is kept.

For Codex and the ChatGPT desktop app, which share one MCP configuration, choose the user target (11: registers the server with codex mcp add when the codex CLI is installed, otherwise adds an [mcp_servers.agent-lsp] table to $CODEX_HOME/config.toml, default ~/.codex/config.toml) or the project target (12: .codex/config.toml in the current directory, read for trusted projects). The TOML file is edited in place, so your other settings and comments are kept.

For Pi, choose the project (9) or global (10) target. Pi has no built-in MCP support; init writes the shared standard MCP files that the pi-mcp-adapter package reads — project .mcp.json (same file Claude Code uses, so one config serves both) or global ~/.config/mcp/mcp.json. Skill awareness rules go into AGENTS.md (project) or ~/.pi/agent/AGENTS.md (global). Install the adapter once with pi install npm:pi-mcp-adapter.

One-command complete setup

Add --with-skills to also install the embedded skill files (no repo clone needed):

bash
agent-lsp init --with-skills

Skills are written to the destination matching the chosen target: only the Pi project target (9) uses the tool-agnostic .agents/skills/ directory (versionable with the repo); the Pi global target (10) uses ~/.pi/agent/skills/; the Claude Code targets (1/2) use ~/.claude/skills/; Cursor (4) uses ~/.cursor/skills/; Gemini CLI (7) uses ~/.config/gemini-cli/skills/; and the Codex user target (11) uses $CODEX_HOME/skills/. Providers without a verified skills directory are skipped with a pointer to skills/install.sh --dest. Re-running overwrites the managed skill files, keeping them in sync with the installed binary. agent-lsp uninstall removes them.

The generated config looks like:

json
{  "mcpServers": {    "agent-lsp": {      "type": "stdio",      "command": "agent-lsp",      "args": [        "go:gopls",        "typescript:typescript-language-server,--stdio",        "python:pyright-langserver,--stdio"      ]    }  }}

Each arg is language:server-binary (comma-separate server args).

Step 5: Install skills

bash
git clone https://github.com/blackwell-systems/agent-lsp.git /tmp/agent-lsp-skillscd /tmp/agent-lsp-skills/skills && ./install.sh --copy

Or skip the clone entirely: agent-lsp init --with-skills installs the same embedded skills to the destination matching your chosen target.

Skills are prompt files copied into your AI tool's configuration. --copy means the clone can be safely deleted afterward. The script defaults to ~/.claude/skills/; pass --dest for other agents, e.g. --dest ~/.pi/agent/skills for Pi. It also appends a managed skills table to existing instruction files (~/.claude/CLAUDE.md, project AGENTS.md, ~/.pi/agent/AGENTS.md, GEMINI.md).

Skills are also available as MCP prompts: any MCP client can discover them via prompts/list and retrieve full workflow instructions via prompts/get, with no manual installation required. The install.sh path is for AgentSkills-compatible clients (Claude Code slash commands, Pi /skill:name commands).

Step 6: Allow tool permissions (Claude Code)

For Claude Code, add mcp__agent-lsp__* to your permissions allow list so all 66 tools are available without per-tool approval prompts:

json
// ~/.claude/settings.json{  "permissions": {    "allow": ["mcp__agent-lsp__*"]  }}

Without this, Claude Code will prompt for permission on each tool call. Other MCP clients handle permissions differently; check your client's documentation.

Skills are multi-tool workflows that encode reliable procedures: blast-radius check before edit, speculative preview before write, test run after change. See docs/guide/skills.md for the full list.

Step 7: Start working

Your AI agent calls tools automatically. The first call initializes the workspace:

start_lsp(root_dir="/your/project")

This is what the agent does, not something you type. Then use any of the 66 tools. The session stays warm; no restart needed when switching files.

What's unique about agent-lsp

CapabilityDetails
Tools66
Languages (CI-verified)32, end-to-end integration tests on every push
Agent workflows (skills)24, named multi-step procedures, discoverable via MCP prompts/list
Speculative execution8 tools, simulate changes before writing to disk
Interactive refactoring✓, answers the language server's refactoring questions (gopls v0.24+)
Phase enforcement4 skills, runtime blocks out-of-order tool calls with recovery guidance
Connection modelpersistent, warm index across files and projects
Call hierarchy✓, single tool, direction param
Type hierarchy✓, CI-verified
Cross-repo references✓, multi-root workspace
Multi-server queries✓, find_symbol and get_server_capabilities ask every running language server
Auto-watch✓, always-on, debounced file watching
Streamable HTTP transport✓, bearer token auth, non-root Docker
Distributionsingle Go binary, 10 install channels

Use Cases

  • Multi-project sessions: point your AI at ~/code/, work across any project without reconfiguring
  • Polyglot development: Go backend + TypeScript frontend + Python scripts in one session
  • Large monorepos: one server handles all languages, routes by file extension
  • Code migration: refactor across repos with full cross-repo reference tracking
  • CI pipelines: validate against real language server behavior
  • Niche language stacks: Gleam, Elixir, Prisma, Zig, Clojure, Nix, Dart, Scala, MongoDB, all CI-verified

Multi-Language Support

32 languages CI-verified end to end against real language servers on every CI run. A language that fails to start or answer fails CI rather than being skipped. No other MCP-LSP implementation tests a single language in CI.

Go, Python, TypeScript, Rust, Java, C, C++, C#, Ruby, PHP, Kotlin, Swift, Scala, Zig, Lua, Elixir, Gleam, Clojure, Dart, Terraform, Nix, Prisma, SQL, MongoDB, JavaScript, YAML, JSON, Dockerfile, CSS, HTML, MQL, Luau.

See docs/reference/language-support.md for the full coverage matrix.

Tools

66 tools covering navigation, analysis, refactoring, symbol editing, composite exploration, safe editing, speculative execution, and session lifecycle. All CI-verified.

See docs/reference/tools.md for the full reference with parameters and examples.

Further reading

Documentation

Contributing

Development

bash
git clone https://github.com/blackwell-systems/agent-lsp.gitcd agent-lsp && go build ./...go test ./...                   # unit testsgo test ./... -tags integration # integration tests (requires language servers)

Library Usage

The pkg/lsp, pkg/session, and pkg/types packages expose a stable Go API for using agent-lsp's LSP client directly without running the MCP server.

go
import "github.com/blackwell-systems/agent-lsp/pkg/lsp"
client := lsp.NewLSPClient("gopls", []string{})client.Initialize(ctx, "/path/to/workspace")defer client.Shutdown(ctx)
locs, err := client.GetDefinition(ctx, fileURI, lsp.Position{Line: 10, Character: 4})

See docs/architecture/architecture.md for the full package API.

License

MIT

來源:README.md,提交 4b8086e

工具

66

activate_skill

Activate Skill Phase Enforcement

Activate phase enforcement for a skill workflow. Once active, tool calls are checked against the skill's phase permissions. Phases advance automatically as you call tools from later phases. Use this at the start of a skill workflow to enable safety guardrails that prevent out-of-order operations (e.g., applying edits before completing blast-radius analysis).

輸入參數modeskill_name必填

add_workspace_folder

Add Workspace Folder

Add a directory to the LSP workspace, enabling cross-repo references, definitions, and diagnostics. Useful when working across a library and its consumers — after adding the consumer repo, find_references on a library function returns call sites in both repos. Requires start_lsp to have been called first. Language servers that support multi-root workspaces (gopls, rust-analyzer, typescript-language-server) will re-index the new folder automatically.

輸入參數path必填

apply_edit

Apply Edit

Apply an edit to a file. Two modes: (1) WorkspaceEdit mode: pass workspace_edit with positional changes returned by rename_symbol or format_document; (2) Text-match mode: pass file_path + old_text + new_text to find and replace text. For full function/method body replacements, consider replace_symbol_body which resolves by symbol name instead of text matching. Always call preview_edit first to verify the edit is safe.

輸入參數new_textold_textfile_pathworkspace_edit

blast_radius

Blast Radius

Enumerate all exported symbols in the specified files, resolve their references across the workspace, and partition callers into test vs non-test. Returns affected_symbols (name, file, line), test_callers (with enclosing test function names), and non_test_callers. Use before editing a file to understand blast radius. Set include_transitive=true to surface second-order callers (callers of callers). Set scope='all' to include unexported symbols for comprehensive dead code detection.

輸入參數scopefilterchanged_files必填include_transitive

callers

Callers

Find all incoming callers of a function or method. Shortcut for find_callers with direction='incoming'. Use before deleting or refactoring a function to see who depends on it.

輸入參數line必填column必填directionfile_path必填language_idcross_concurrent

close_document

Close Document

Close a file in the LSP server. Use this tool when you're done with a file to free up resources and reduce memory usage. It's good practice to close files that are no longer being actively analyzed, especially in long-running sessions or when working with large codebases.

輸入參數file_path必填

commit_session

Commit Session

Commit a simulation session. With apply=true, writes changes to disk and notifies LSP servers. With apply=false, returns a unified diff patch. Use after evaluate_session confirms the changes are safe.

輸入參數applytargetsession_id必填

create_simulation_session

Create Simulation Session

Create a new speculative code session for simulating edits without committing to disk. Returns a session ID. Baseline diagnostics are captured lazily on first edit per file. Use this to explore what-if scenarios before applying changes.

輸入參數language必填workspace_root必填

deactivate_skill

Deactivate Skill Phase Enforcement

Deactivate phase enforcement for the currently active skill. Tool calls will no longer be checked against phase permissions. Call this when the skill workflow is complete or when you need to exit the workflow early.

無需輸入參數。

destroy_session

Destroy Session

Destroy a simulation session and release all resources. Call this after commit or discard to clean up. Sessions in terminal states (committed, discarded, destroyed) cannot be reused.

輸入參數session_id必填

detect_changes

Detect Changes

Run git diff to identify changed files, analyze their exported symbols via blast_radius, and return affected symbols with risk classification. Risk levels: 'high' (callers from multiple packages), 'medium' (callers from same package only), 'low' (zero non-test callers). Use before committing to understand the blast radius of uncommitted or recently committed changes.

輸入參數rangescopeworkspace_root

detect_lsp_servers

Detect LSP Servers

Scan a workspace directory for source languages and check PATH for the corresponding LSP server binaries. Returns detected workspace languages (ranked by prevalence), installed servers with their paths, and a suggested_config array ready to paste into the agent-lsp MCP server args. Use this to set up agent-lsp for a new project or verify your configuration.

輸入參數workspace_dir必填

did_change_watched_files

Notify File Changes

Notify the language server that files have changed on disk outside the editor (workspace/didChangeWatchedFiles). Use this after writing files directly to disk so the server refreshes its caches. Change types: 1=created, 2=changed, 3=deleted. File URIs must use the file:/// scheme.

輸入參數changes必填

discard_session

Discard Session

Discard a simulation session and revert all in-memory changes by restoring baseline content. Use when simulation results show the changes would introduce errors.

輸入參數session_id必填

evaluate_session

Evaluate Session

Evaluate a simulation session by comparing current diagnostics against baselines. Returns errors introduced, errors resolved, net delta, and confidence (high for file scope, eventual for workspace). Use after simulate_edit to assess impact before committing.

輸入參數scopesession_id必填timeout_ms

execute_command

Execute Command

Execute a workspace command via LSP. Commands are server-defined identifiers returned by code actions (in the command field of a CodeAction). Use this after suggest_fixes to trigger a server-side operation such as applying a refactoring, generating code, or running a server-specific action. Returns the server-defined result or null.

輸入參數command必填arguments

explore

Explore

Deep exploration of a symbol: combines type info, source, callers, references, and test callers in one call. Use when navigating unfamiliar code and you need the full picture of what a symbol is and how it is used.

輸入參數linecolumnfile_path必填language_idposition_pattern

explore_symbol

Explore Symbol

Deep-dive into a symbol: type info, source code, callers (top 10), references (count + top 5 files), and test caller count in one call. Use when you need full context about a symbol before editing. Accepts file_path + line/column or position_pattern.

輸入參數linecolumnfile_path必填language_idposition_pattern

export_cache

Export Cache

Export the symbol reference cache as a gzip-compressed artifact for team sharing. The exported file can be committed to the repository (e.g. .agent-lsp/cache.db.gz) so teammates skip cold-start indexing. Requires start_lsp to have been called first.

輸入參數dest_path必填

find_callers

Find Callers

Find what calls this function and what it calls. Returns incoming callers, outgoing callees, or both (default). Use before deleting or refactoring a function to understand its role in the call graph. Works on functions and methods only; for types, use find_references instead.

輸入參數line必填column必填directionfile_path必填language_idcross_concurrent

find_references

Find References

Find all usages of a symbol across the codebase. Use before renaming, deleting, or changing any symbol to understand who calls it. Zero references means the symbol may be dead code; use safe_delete_symbol to remove it safely. For blast-radius analysis with test/non-test partitioning, use blast_radius instead.

輸入參數linecolumnfile_path必填language_idposition_patterninclude_declaration

find_symbol

Find Symbol

Search for a symbol by name across the entire workspace. Returns matching symbols with name, kind, file, and location. Use when you know a symbol's name but not its file. Use detail_level: "hover" to also get type signatures and docs for each match.

輸入參數limitqueryoffsetdetail_level

format_document

Format Document

Get formatting edits for a file via LSP. Returns TextEdit[] for inspection (not applied automatically). Apply via apply_edit. Formats one file at a time; to find which files need formatting, use your shell (e.g. gofmt -l ./...).

輸入參數tab_sizefile_path必填language_idinsert_spaces

format_range

Format Range

Get formatting edits for a specific range within a document via LSP (textDocument/rangeFormatting). Returns TextEdit[] for the selected lines/characters only. Use this when you want to format a function, block, or selection rather than the entire file. The edits are NOT applied automatically.

輸入參數end_line必填tab_sizefile_path必填end_column必填start_line必填language_idstart_column必填insert_spaces

get_completions

Get Completions

Get completion suggestions at a specific location in a file. Use this tool to retrieve code completion options based on the current context, including variable names, function calls, object properties, and more. Helpful for code assistance and auto-completion at a particular location. Use this when determining which functions you have available in a given package, for example when changing libraries.

輸入參數line必填column必填file_path必填language_id

get_cross_repo_references

Get Cross-Repo References

Find all references to a library symbol across one or more consumer repositories. Adds each consumer_root as a workspace folder, waits for indexing, then calls find_references and partitions results by repo. Returns library_references (within the primary repo), consumer_references (map of root → locations), and warnings (roots that could not be indexed). Use before changing a shared library API to find all downstream callers.

輸入參數line必填column必填language_idsymbol_file必填consumer_roots必填

get_diagnostics

Get Diagnostics

Get diagnostic messages (errors, warnings) for files. Use this tool to identify problems in code files such as syntax errors, type mismatches, or other issues detected by the language server. When used without a file_path, returns diagnostics for all open files.

輸入參數group_byfile_path

get_document_highlights

Get Document Highlights

Find all occurrences of the symbol at a position within the same file via LSP (textDocument/documentHighlight). Returns ranges and kinds: 1=Text, 2=Read, 3=Write. File-scoped and instant — does not trigger a workspace-wide reference search. Use this to find all local usages of a variable, parameter, or field without the overhead of find_references.

輸入參數line必填column必填file_path必填language_id

get_inlay_hints

Get Inlay Hints

Get inlay hints for a range within a document via LSP (textDocument/inlayHint). Inlay hints are inline annotations that IDEs display in source code — typically inferred type names (e.g. `: string`) and parameter name labels (e.g. `count:`). Useful in languages with type inference (TypeScript, Rust, Go) to see what the compiler knows without reading every type annotation. Returns an array of InlayHint objects, each with a position, label, and optional kind (1=Type, 2=Parameter). Returns an empty array if the language server does not support inlay hints.

輸入參數end_line必填file_path必填end_column必填start_line必填language_idstart_column必填

get_semantic_tokens

Get Semantic Tokens

Get semantic tokens for a range in a file. Returns each token's type (function, variable, keyword, parameter, type, etc.) and modifiers (readonly, static, deprecated, etc.) with 1-based line/character positions. Use this to understand the syntactic role of code elements — distinct from hover which gives documentation. Only available when the language server supports textDocument/semanticTokens.

輸入參數end_line必填file_path必填end_column必填start_line必填language_idstart_column必填

get_server_capabilities

Get Server Capabilities

Return the language server's capability map and classify every agent-lsp tool as supported or unsupported based on what the server advertised during initialization. Use this to determine which tools will return results before calling them — saves round trips on servers that don't support certain LSP features (e.g. not all servers support type_hierarchy or inlay_hints). Requires start_lsp to have been called first.

無需輸入參數。

get_signature_help

Get Signature Help

Get function signature help at a specific location in a file via LSP. Returns available overloads and highlights the active parameter. Use this when the cursor is inside a function call's argument list to understand what parameters the function expects.

輸入參數line必填column必填file_path必填language_id

get_skill_phase

Get Skill Phase Status

Get the current state of skill phase enforcement: active skill, current phase, allowed and forbidden tools, and tool call history. Use this to understand where you are in a skill workflow and what tools are available.

無需輸入參數。

get_symbol_documentation

Get Symbol Documentation

Fetch authoritative documentation for a named symbol from local toolchain sources (go doc, pydoc, cargo doc) without requiring an LSP hover response. Works on transitive dependencies not indexed by the language server. Returns the full doc text, extracted signature, and source tag. Falls back gracefully when the toolchain command fails or the language is unsupported.

輸入參數formatsymbol必填file_pathlanguage_id必填

get_symbol_source

Get Symbol Source

Return the source code of the innermost symbol (function, method, class, struct, etc.) whose range contains the given cursor position. Calls textDocument/documentSymbol, walks the symbol tree to find the smallest enclosing symbol, then slices the file at that symbol's range. Returns symbol_name, symbol_kind, start_line (1-based), end_line (1-based), and source text. Use line+character or position_pattern (@@-syntax) to specify the cursor. character defaults to 1.

輸入參數linecolumnfile_path必填language_idposition_pattern

get_tests_for_file

Get Tests for File

Given a source file path, return the test files that exercise it. Static lookup — no test execution. Go: *_test.go in same directory. Python: test_*.py / *_test.py in same dir and tests/ sibling. TypeScript/JS: *.test.ts, *.spec.ts etc. Rust: returns source file itself (tests inline). Does not require start_lsp.

輸入參數file_path必填

go_to_declaration

Go to Declaration

Jump to the declaration of a symbol at a specific location in a file via LSP. Completes the 'go to X' family alongside go_to_definition, go_to_type_definition, and go_to_implementation. Most useful for languages with separate declaration and definition (e.g., C/C++ header files). Returns the file path and position where the symbol is declared.

輸入參數line必填column必填file_path必填language_id

go_to_definition

Go to Definition

Jump to the definition of a symbol at a specific location in a file via LSP. Returns the file path and position where the symbol is defined. Useful for navigating to type declarations, function implementations, or variable assignments across the codebase.

輸入參數line必填column必填file_path必填language_idposition_pattern

go_to_implementation

Go to Implementation

Find all implementations of an interface or abstract method at a specific location in a file via LSP. Returns the file paths and positions of all concrete implementations. Use this to navigate from an interface declaration or abstract method to the concrete classes that implement it.

輸入參數line必填column必填file_path必填language_id

go_to_symbol

Go to Symbol

Navigate to a symbol definition by dot-notation name (e.g. "LSPClient.GetReferences", "http.Handler") without needing file_path or line/column. Uses workspace symbol search to locate the definition. Useful when you know the symbol name but not its location.

輸入參數languagesymbol_path必填workspace_root

go_to_type_definition

Go to Type Definition

Jump to the definition of the type of a symbol at a specific location in a file via LSP. Unlike go_to_definition (which goes to where the symbol itself is defined), this navigates to the type declaration. Useful for interface types, type aliases, and class definitions when working with instances or variables.

輸入參數line必填column必填file_path必填language_id

import_cache

Import Cache

Import a gzip-compressed cache artifact, replacing the current symbol reference cache. Use this to load a team-shared cache exported via export_cache. Validates database integrity after import. Requires start_lsp to have been called first.

輸入參數src_path必填

insert_after_symbol

Insert After Symbol

Insert code immediately after a named symbol definition. Resolves the symbol's end position via document symbols. Use for adding new methods after existing ones, appending related functions, etc.

輸入參數code必填file_path必填language_idsymbol_path必填

insert_before_symbol

Insert Before Symbol

Insert code immediately before a named symbol definition. Resolves the symbol's start position via document symbols. Use for adding imports, comments, decorators, or type definitions before their first consumer.

輸入參數code必填file_path必填language_idsymbol_path必填

inspect_symbol

Inspect Symbol

Get type information, documentation, and signature for a symbol at a specific location. Use this to understand what a function does, what type a variable has, or what a module exports before editing it. For finding all usages of the symbol, use find_references instead.

輸入參數linecolumnfile_path必填language_idposition_pattern

list_symbols

List Symbols

List all symbols defined in a file (functions, types, methods, variables). Returns a hierarchical tree showing the file's structure. Use to get an overview before editing, or to find the exact name of a symbol for use with replace_symbol_body or find_references. Pass format: "outline" for compact markdown output optimized for LLM consumption.

輸入參數formatfile_path必填language_id

list_workspace_folders

List Workspace Folders

List all currently active workspace folders. Use this to see which roots the language server is indexing.

無需輸入參數。

open_document

Open Document

Open a file in the LSP server for analysis. Use this tool before performing operations like getting diagnostics, hover information, or completions for a file. The file remains open for continued analysis until explicitly closed. The language_id parameter tells the server which language service to use (e.g., 'typescript', 'javascript', 'haskell'). The LSP server starts automatically on MCP launch.

輸入參數textfile_path必填language_id

prepare_rename

Prepare Rename

Validate that a rename is possible at the given position before committing to rename_symbol. Returns the range that would be renamed and a placeholder name suggestion, or a message indicating rename is not supported at this position. Use this before rename_symbol to avoid attempting invalid renames. Returns null if the server does not support prepareRename.

輸入參數line必填column必填file_path必填language_id

preview_edit

Preview Edit

Preview the impact of an edit before writing to disk. Shows what errors would be introduced or resolved without touching the file. If net_delta is 0, the edit is safe to apply without further verification. Use before every apply_edit to catch problems early. All line/column positions are 1-indexed. For full function replacements, consider replace_symbol_body instead of apply_edit.

輸入參數scopeend_line必填languagenew_text必填file_path必填end_column必填session_idstart_line必填timeout_msstart_column必填workspace_root

refactor

Refactor

Run a language server refactoring at a position: implement an interface, add or remove struct tags, extract to a new file, move a declaration, and others the server offers there. Call without action to list the refactorings at the position (pass end_line/end_column to select a range, e.g. struct fields). Call with action to run one. Refactorings that need input (gopls v0.24+ interactive refactorings) return status needs_input with their questions: field ids, kinds, options and defaults; call again with answers {field id: value}, and option_queries to search a lazyEnum field's options. Rejected answers come back with an error on the field. The server computes the edit; dry_run=true returns it without writing, otherwise it is applied and diagnostics are reported.

輸入參數lineactioncolumnanswersdry_runend_linefile_path必填end_columnlanguage_idoption_queriesposition_pattern

remove_workspace_folder

Remove Workspace Folder

Remove a directory from the LSP workspace. The language server will stop indexing that folder.

輸入參數path必填

rename_symbol

Rename Symbol

Rename a symbol across the entire workspace via LSP and write the edits to disk. Use dry_run=true first to preview the changes without writing them (files, locations, and the edit). Call find_references before renaming exported symbols to understand blast radius. The result reports diagnostics for the renamed file after the edit; call get_diagnostics on other affected files to confirm no errors were introduced.

輸入參數linecolumndry_runnew_name必填file_path必填language_idexclude_globsposition_pattern

replace_symbol_body

Replace Symbol Body

Replace the body of a named symbol (function, method, class) by dot-notation path, preserving the declaration/signature line. Resolves the symbol via document symbols without requiring line/column positions. Use symbol_path like 'MyStruct.Method' or 'Function'. For overload disambiguation, append [N] index (e.g. 'Handle[1]').

輸入參數new_body必填file_path必填language_idsymbol_path必填

restart_lsp_server

Restart LSP Server

Restart the LSP server process. Use this if the LSP server becomes unresponsive or after making significant changes to the project structure. Optionally provide a new root_dir to restart with a different workspace root.

輸入參數root_dir

run_build

Run Build

Compile the project at workspace_dir using the detected workspace language. Language-specific dispatch (no arbitrary shell execution): go build ./..., cargo build, tsc --noEmit, mypy . (Python typecheck proxy). Optional path param narrows scope. Returns: { success: bool, errors: [{file, line, column, message}], raw: string }. Does not require start_lsp.

輸入參數pathlanguageworkspace_dir必填

run_tests

Run Tests

Run the test suite for the detected workspace language. Language-specific dispatch: go test -json ./..., cargo test --message-format=json, pytest --tb=json, npm test. Optional path param narrows scope. Test failure locations are LSP-normalized — paste directly into go_to_definition. Returns: { passed: bool, failures: [{file, line, test_name, message, location}], raw: string }. Does not require start_lsp.

輸入參數pathlanguageworkspace_dir必填

safe_apply_edit

Safe Apply Edit

Preview an edit and apply it only if safe (net_delta == 0). Combines preview_edit + apply_edit into one call. If the edit would introduce errors (net_delta > 0), returns the preview result with applied=false so you can decide.

輸入參數new_text必填old_text必填file_path必填

safe_delete_symbol

Safe Delete Symbol

Delete a named symbol only if it has zero references across the workspace (verified via LSP references before deletion). Returns an error with the caller count if the symbol is still in use. Prevents accidental removal of active code.

輸入參數file_path必填language_idsymbol_path必填

safe_edit

Safe Edit

Preview an edit and apply it only if safe (net diagnostic delta == 0). Combines preview_edit + apply_edit into one step. Returns applied=true on success or applied=false with preview diagnostics when the edit would introduce errors.

輸入參數new_text必填old_text必填file_path必填

set_log_level

Set Log Level

Set the server logging level. Use this tool to control the verbosity of logs generated by the LSP MCP server. Available levels from least to most verbose: emergency, alert, critical, error, warning, notice, info, debug. Increasing verbosity can help troubleshoot issues but may generate large amounts of output.

輸入參數level必填

simulate_chain

Simulate Chain

Apply a sequence of edits and evaluate after each step. Returns per-step diagnostics and identifies the safe-to-apply-through step (last step with net delta == 0). Use this to find the safest partial application of a multi-step change. All line/column positions in each edit are 1-indexed.

輸入參數edits必填session_id必填timeout_ms

simulate_edit

Simulate Edit

Apply a range edit to a file within a simulation session. Changes are held in-memory only. The session captures baseline diagnostics on first edit to each file, then tracks versions for subsequent edits. Returns the new version number after the edit. All line/column positions are 1-indexed (matching editor line numbers).

輸入參數end_line必填new_text必填file_path必填end_column必填session_id必填start_line必填start_column必填

start_lsp

Start LSP Server

Initialize or reinitialize the LSP server with a specific project root directory. Call this before using find_references, inspect_symbol, or get_diagnostics when working in a project different from the one the server was started with. root_dir should be the workspace root (directory containing go.mod, package.json, Cargo.toml, etc.). Optional language_id (e.g. "go", "typescript", "rust") selects a specific configured server in multi-server mode — use this when working in a mixed-language repo to ensure the correct server handles the workspace. If unsure which server is active, call get_server_capabilities first.

輸入參數scopeconnectroot_dir必填language_idready_timeout_seconds

suggest_fixes

Suggest Fixes

Get available quick fixes and code actions for a diagnostic or code range. Returns actionable fixes (add missing import, implement interface, fix type error) that can be applied via apply_edit. To auto-fix all diagnostics in a file, use the /lsp-fix-all skill via prompts/get.

輸入參數end_line必填file_path必填end_column必填start_line必填language_idstart_column必填

type_hierarchy

Type Hierarchy

Show type hierarchy for a type at a position. Returns supertypes (parent classes/interfaces), subtypes (subclasses/implementations), or both depending on the direction parameter. Direction defaults to "both". Use this to understand class and interface inheritance relationships.

輸入參數line必填column必填directionfile_path必填language_id

版本歷史

15
  1. v0.24.2最新Nov 4, 2026
  2. v0.24.0Nov 4, 2026
  3. v0.23.6Oct 31, 2026
  4. v0.23.5Oct 29, 2026
  5. v0.23.4Oct 26, 2026
  6. v0.23.3Oct 26, 2026
  7. v0.23.2Oct 26, 2026
  8. v0.23.1Oct 24, 2026
  9. v0.23.0Oct 8, 2026
  10. v0.22.0Oct 7, 2026
  11. v0.21.0Sep 30, 2026
  12. v0.20.0Sep 29, 2026
  13. v0.19.5Sep 22, 2026
  14. v0.19.4Sep 21, 2026
  15. v0.19.1Sep 16, 2026

評分

已滿足適用檢查項的 90%

該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。

  • 近 30 天內可連通25 分
  • 已宣告認證方式10 分

    請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。

  • 已列出工具必需15 分
  • 描述必需15 分
  • 圖示10 分
  • 文件15 分
  • 授權條款10 分