lspi (Giving AI the sight of LSP)
lspi bridges Language Server Protocol (LSP) capabilities to Codex via an MCP server over stdio.
When to use
- You need semantic navigation: definition / references / implementation / type definition.
- You need call graph insights: incoming calls / outgoing calls (call hierarchy).
- You need quick type/doc info at a cursor: hover.
- You want to list symbols in a file or search symbols across the workspace.
- You want a safe rename workflow (preview first, apply only when confirmed).
Core rules
- All
*_attools use 1-basedline/character. - Prefer
*_attools when you have a cursor position: they apply bounded position fuzzing. - For multi-language workspaces:
search_workspace_symbolsMUST includefile_pathif multiple language servers are configured. - If
lspiis started in read-only mode (lspi mcp --read-onlyormcp.read_only=true), rename and server-control tools are disabled. rename_symbol/rename_symbol_strictdefaults to preview (dry_run=true). Only apply edits when explicitly requested.- If a tool call returns an error, look for
structuredContent.next_stepsand follow them (introspection tools + config hints). - If you can run local commands, prefer
lspi doctor --workspace-root . --jsonfor a machine-readable environment/config report. - After each tool call, briefly summarize what you did and what you got (method, key inputs like
file_path/position, number of results, and whether output was truncated). - Most tools accept
max_resultsandmax_total_chars. For reproducible behavior, set them explicitly when needed. - For large result sets, consider disabling snippets (
include_snippet=false) to keep outputs small and deterministic. - If a generic LSP server returns empty/odd results, suggest tuning per-server config:
initialize_options,client_capabilities, andworkspace_configuration.
Recommended workflow (read -> verify -> change)
- Gather context:
hover_at(fast type/doc check)get_document_symbols(what symbols exist in this file?)search_workspace_symbols(find candidate symbols by name)
- Verify target:
find_definition_at/find_references_at- optionally:
find_implementation_at/find_type_definition_at
- Change safely:
rename_symbol_strict(position-based) orrename_symbol(name-based)- start with
dry_run=true, inspect the preview edit, then rerun withdry_run=false
- Validate and recover:
get_diagnosticsrestart_serverorstop_serverif the LSP process is stuck or needs to be released
Tool cheat sheet
- Read-only:
get_current_configlist_serversget_server_statushover_atget_document_symbolssearch_workspace_symbolsfind_definition/find_definition_atfind_references/find_references_atfind_implementation_atfind_type_definition_atfind_incoming_calls/find_incoming_calls_atfind_outgoing_calls/find_outgoing_calls_atget_diagnostics
- Control:
restart_serverstop_server