LSP Bridge — VS Code Agent Bridge Skill
This skill lets you interact with the VS Code Agent Bridge extension, a local HTTP server that exposes Language Server Protocol (LSP) features as REST endpoints. It provides real-time compiler diagnostics, type information, code navigation, call hierarchies, type hierarchies, code completion, refactoring support, and more from the user's VS Code editor.
It works with any programming language that has a Language Server extension installed in VS Code (Java, Python, TypeScript, Go, Rust, C#, C++, etc.).
Prerequisites
The VS Code Agent Bridge extension must be installed and running. It activates automatically when VS Code starts.
Instance Discovery (recommended)
The extension writes a JSON discovery file to ~/.vsc-agent-bridge/ when it starts. Each VS Code instance writes its own file containing the port, auth token, and workspace folders.
To find the right instance automatically:
- List files in
~/.vsc-agent-bridge/*.json - Read each file to find the one whose
workspaceFolderscontains your project path - Use the
portandtokenfrom that file
Example discovery file:
{
"port": 54321,
"token": "abc123...",
"pid": 12345,
"version": "0.4.0",
"workspaceFolders": ["/Users/dev/projects/my-app"],
"startedAt": "2026-04-06T10:30:00Z"
}
You can also call GET /info (no auth required) on any port to verify which VS Code instance is running there.
Authentication
Every request (except GET /info) must include the header:
x-auth-token: <token>
The token is available from the discovery file (~/.vsc-agent-bridge/*.json). If discovery files are not available, ask the user to copy it from VS Code via the command "Agent Bridge: Copy Connection Info to Clipboard" in the Command Palette.
Language-specific prerequisites
JavaScript / CommonJS
For cross-file navigation (/definition, /references, /implementation, /rename-preview) to work correctly, a jsconfig.json must exist at the project root:
{
"compilerOptions": {
"baseUrl": ".",
"paths": { "src/*": ["src/*"] }
},
"include": ["src/**/*"]
}
Without this file, tsserver limits resolution to the current file only. The following endpoints degrade:
/definition— resolves to the localrequire(...)line instead of the source file/references— only finds references within the same file/implementation— only finds implementations within the same file/rename-preview— only renames within the same file (dangerous: partial rename can break the project)/call-hierarchy—incomingCallsalways empty/inlay-hints— empty unlessjavascript.inlayHints.*settings are enabled in VS Code
TypeScript
Works out of the box when tsconfig.json is present.
Java
No additional configuration required. JDT.LS resolves cross-module.
API Reference
The full API is described in the OpenAPI 3.0 specification:
📄 references/openapi.yaml
All POST endpoints expect a JSON body with Content-Type: application/json.
Quick reference
| Endpoint | Method | Description |
|---|---|---|
/info |
GET |
Instance info (no auth). Port, PID, workspace folders. |
/diagnostics |
GET |
Errors, warnings, hints. Filter with ?file=. |
/definition |
POST |
Go to definition of a symbol. |
/declaration |
POST |
Go to declaration of a symbol. |
/hover |
POST |
Type signature and documentation. |
/references |
POST |
Find all references to a symbol. |
/type-definition |
POST |
Go to the type definition. |
/implementation |
POST |
Find implementations of an interface/abstract. |
/document-symbols |
POST |
List symbols in a file. |
/code-actions |
POST |
Quick fixes and refactorings for a range. |
/signature-help |
POST |
Parameter hints for a function call. |
/rename-preview |
POST |
Preview rename edits. |
/call-hierarchy |
POST |
Incoming and outgoing calls. |
/type-hierarchy |
POST |
Supertypes and subtypes. |
/workspace-symbols |
POST |
Search symbols across the workspace. |
/completion |
POST |
Code completion suggestions. |
/inlay-hints |
POST |
Type annotations and parameter name hints. |
/folding-ranges |
POST |
Folding ranges (code blocks). |
/active-file-content |
GET |
Full text of the open file. |
/ |
GET |
Health-check / endpoint discovery. |
Common request bodies
Position-based endpoints (definition, declaration, hover, references, type-definition, implementation, signature-help, call-hierarchy, type-hierarchy, completion):
{ "file": "/absolute/path/to/file.ts", "line": 15, "character": 10 }
Range-based endpoints (code-actions, inlay-hints):
{ "file": "/absolute/path/to/file.ts", "startLine": 10, "startCharacter": 0, "endLine": 10, "endCharacter": 30 }
File-only endpoints (document-symbols, folding-ranges):
{ "file": "/absolute/path/to/file.ts" }
Rename (rename-preview):
{ "file": "/absolute/path/to/file.ts", "line": 5, "character": 10, "newName": "newVariableName" }
Workspace search (workspace-symbols):
{ "query": "UserService" }
Use the optional folder parameter to scope results to a specific project and exclude symbols from other projects, dependencies, or Markdown files:
{ "query": "UserService", "folder": "/absolute/path/to/project" }
Workflow: Debugging Compilation Errors
- Get the auth token — ask the user if you don't have it.
- Fetch diagnostics —
GET /diagnosticsto see all errors and warnings. - Investigate errors — use
POST /hoveron the problematic position to understand the types involved. - Navigate definitions — use
POST /definitionto trace where symbols are defined. - Find references — use
POST /referencesto see where a symbol is used. - Check implementations — use
POST /implementationto find concrete implementations of interfaces. - Explore call hierarchy — use
POST /call-hierarchyto understand who calls the problematic code and what it calls. - Get code actions — use
POST /code-actionson the error range to see available quick fixes. - Read file content — use
GET /active-file-contentfor the full source. - Propose fixes — suggest concrete code changes based on all the information gathered.
Workflow: Understanding Code Structure
- List symbols —
POST /document-symbolsto get an overview of classes, methods, and variables in a file. - Search workspace —
POST /workspace-symbolsto find symbols across the entire project by name. - Inspect types —
POST /hoveron interesting symbols to see their types. UsePOST /inlay-hintsfor a range overview of type annotations. - Trace definitions —
POST /definition,POST /declaration, andPOST /type-definitionto understand the type hierarchy. - Explore hierarchy —
POST /type-hierarchyto see supertypes and subtypes.POST /call-hierarchyto trace call graphs. - Find usages —
POST /referencesto see how symbols are used across the project. - View code blocks —
POST /folding-rangesto understand the logical structure of a file. - Get completions —
POST /completionto see what the language server suggests at a specific position.
Error Handling
- 401 Unauthorized: The
x-auth-tokenheader is missing or incorrect. Read the token from the discovery file or ask the user. - 400 Bad Request: Missing or invalid parameters in the request body. Check the required fields.
- 404 Not Found: The file path does not exist, or (on
/active-file-content) no file is currently open. - Empty results: If endpoints return empty arrays, the Language Server may still be loading, the position/file may be incorrect, or the Language Server does not support the feature for this language.
- Connection refused: The extension is not running. Ask the user to ensure VS Code Agent Bridge is installed and active.
Note: The
/diagnosticsendpoint returns a root-level JSON array[...], not wrapped in an object, unlike other endpoints.
Language Server Limitations
The quality and completeness of results depends on the Language Server behind each language. Known limitations:
Java (JDT.LS / Red Hat Java)
/declaration: Always returns empty. Java does not distinguish declaration from definition. Use/definitioninstead./type-hierarchy: May returnitem: nullfor many positions. The cursor must be precisely on the type name in its declaration. Consider/implementationas an alternative./inlay-hints: Thekindfield is not provided by JDT.LS. The bridge applies a heuristic: labels ending with:→Parameter, labels starting with:→Type. Some hints may still have nokind./folding-ranges: Only import blocks havekind: "Imports". Other code blocks have nokindvalue./hover: Contents may include VS Code internalcommand:links (automatically stripped by the bridge).
JavaScript / CommonJS (tsserver)
/declaration: Always returns empty (same as Java)./type-definition: Always empty for pure JavaScript without JSDoc@typeannotations./type-hierarchy: Returnsitem: nullsystematically./document-symbols:module.exports = ...appears as<unknown>symbol names./workspace-symbols: Results are global and may include symbols from other projects, dependencies, and Markdown files in the workspace. Use thefolderparameter to scope results.
General Notes
- Optional fields (
kind,documentation,isPreferred) may be absent from responses when the Language Server does not provide them. - Cross-file features degrade without proper project configuration (see Language-specific prerequisites).
_warningfield: Cross-file endpoints (/definition,/references,/implementation,/rename-preview,/call-hierarchy) include a_warningstring when nojsconfig.jsonortsconfig.jsonis found for a JS/TS file. This signals that results may be limited to the current file.
Configuration
By default the extension picks a random available port (port 0). The actual port is written to the discovery file at ~/.vsc-agent-bridge/<workspace-id>.json.
To use a fixed port, set vscAgentBridge.port in VS Code settings. Use 0 for automatic assignment (recommended for multi-instance support).
Source: knightmax/vsc-agent-bridge — distributed by TomeVault.