Skip to main content
Glama

opencode-lsp-tools starts the language servers already installed on your machine and exposes them through a single native opencode tool lsp. It answers questions an agent cannot settle by searching text: where a symbol is defined, who references it, what type it has, what the compiler would complain about

The project started as an MCP server and was reworked into an opencode V2 plugin. The MCP entry point is gone. One native tool lsp dispatches on an action argument

Why

Plain text search cannot resolve types. interface implementations, overloads, re-exports and shadowed names all look identical to grep. Language servers do this resolution properly, but editor integrations are the only common way to reach them

AI coding agents typically run without a language server attached. opencode-lsp-tools gives an agent the same queries an IDE has, reusing the servers you already trust

Related MCP server: universal-lsp

Install

Requires Node.js 20 or newer, and the language servers you want to use already on PATH

Published on npm as @sglwsjxh/opencode-lsp-tools. Load it from a local path, one of two ways

In ~/.config/opencode/opencode.json:

{
  "plugins": [
    {
      "package": "C:/path/to/opencode-lsp-tools",
      "options": {
        "config": "C:/path/to/dir"
      }
    }
  ]
}

options.config points to lsp.json or the directory that contains it. It may be omitted; the plugin then checks, in order: the LSP_CONFIG environment variable, the plugin directory and its parent for a bundled lsp.json, and finally the process working directory. When nothing is found the error lists every path that was checked

Or drop the package folder into .opencode/plugins/ and let opencode discover it

Configuration

Create lsp.json from the template:

cp lsp.json.example lsp.json

Each entry maps a language to one command. The command is spawned directly when it resolves to an executable, and through cmd.exe when it resolves to a .cmd or .bat wrapper. This distinction matters on Windows only

{
  "servers": {
    "typescript": {
      "extensions": [".ts", ".tsx", ".js", ".jsx", ".mjs", ".cjs"],
      "languageIds": { ".tsx": "typescriptreact", ".jsx": "javascriptreact" },
      "command": ["typescript-language-server", "--stdio"]
    },
    "java": {
      "extensions": [".java"],
      "command": ["jdtls", "-data", "{cache}/opencode-lsp-tools/jdtls/{rootHash}"]
    }
  }
}

Field

Required

Meaning

extensions

yes

File suffixes routed to this server, matched case-insensitively

command

yes

Executable plus arguments

languageIds

no

Per-extension override of the LSP languageId, used when a suffix is not what the server expects

{root} inside any argument is replaced with the project root passed to lsp with action: "init"

If the file is absent the plugin fails loudly and prints the paths it looked at, rather than silently falling back to the template

Environment variables:

Variable

Meaning

LSP_CONFIG

Path to lsp.json or its directory, used when options.config is absent

LSP_LOG_LEVEL

error, info or debug, default error

Servers in the template

Language

Command

Extra requirement

TypeScript / JavaScript

typescript-language-server

none

Vue

vue-language-server

project needs a local typescript; missing it disables the entry instead of falling back to a global copy. Script-region queries additionally need the plugin shown in Vue single-file components

Python

pyright-langserver

none

C#

csharp-ls

none

Rust

rust-analyzer

none

Go

gopls

none

C / C++

clangd

a compilation database gives materially better results

Dart / Flutter

dart language-server

Flutter SDK provides this command

JSON

vscode-json-language-server

syntax checking only, no schema store lookup

HTML

vscode-html-language-server

standalone .html files

CSS

vscode-css-language-server

standalone .css files

Java

jdtls

needs jdtls on PATH and python available; the wrapper script resolves the Eclipse launcher itself

Add or edit entries freely. Nothing about the language set is compiled in

Tool

A single native tool lsp, read-only. There is no rename, format or code action, because those mutate your working tree and belong to an editing tool

action selects the operation:

action

Input

Returns

init

root, optional languages

binds the project root, reports detected languages, starts nothing

health

none

state per language: ready, failed, crashed, missing command, plus the reason

shutdown

optional language

stops one or all servers and reaps their process tree

definition

file, line, character

where the symbol is declared

references

file, line, character, optional include_declaration, limit, offset

all usages, paginated

implementation

file, line, character

implementations of an interface or abstract member

hover

file, line, character

resolved type signature and documentation

document_symbols

file

symbols in one file with line numbers

diagnostics

file, or scope set to workspace

errors and warnings with severity, code and range

file is an absolute path or a path relative to the project root bound by init. line and character are 1-based, matching editor display and file readers. They are converted internally for the 0-based LSP wire format

First use: call lsp with action: "init" and pass the project root. Servers then start on demand by file extension. Querying a .py file for a project whose Python server is not running yet starts it, waits for initialize, then serves the request

Behavior notes

  • The plugin runs inside the opencode server process. Unloading it reaps the language server process trees

  • A server that never declared a capability returns an explicit "not supported by this language server" instead of an empty list, so absence never reads as success

  • Crashed servers are restarted on the next call and reported through the health action

  • Diagnostics arrive asynchronously. A query waits within a bounded timeout rather than returning immediately empty

  • On Windows, stopping a server kills the whole process tree. jdtls spawns cmd then python then java, and killing only the direct child leaves orphans holding hundreds of megabytes

  • The Java workspace lives outside the project at ~/.cache/opencode-lsp-tools/jdtls/<project hash>, so git status stays clean and no .jdtls-workspace/ directory is created (remove a leftover one by hand if you have it). Never point -data inside the project root: Eclipse rejects a workspace nested in its own project and the Maven import silently degrades to a non-project mode where hover and definition return nothing. Importing may still generate Eclipse metadata inside the project (.project, .classpath, .settings/); gitignore those yourself if you commit the repo. Other servers either write nothing into your tree or manage their own ignore files: clangd writes its index to .cache/clangd/index/ and creates a .gitignore there itself, cargo writes target/

Vue single-file components

.vue needs two servers, and they do different halves of the job. @vue/language-server 3 and later dropped its own pipe to the TypeScript server and made the client responsible for relaying tsserver traffic: the server emits a tsserver/request notification and blocks until a matching tsserver/response arrives. Without that relay every query on a .vue file hangs until timeout

opencode-lsp-tools implements the relay. Starting a vue server always brings up the typescript server for the same root first and routes the requests through it

The remaining split is real, not a bug:

Query on a .vue file

Answered by

document_symbols

vue — the SFC structure plus the whole template node tree

hover, definition, references, implementation

typescript — tried on vue first, retried there when it comes back empty

diagnostics

both, merged and deduplicated by file, line, column and message

Every response names the server that answered, so a fallback never looks like a native result

Script-region semantics also need the TypeScript plugin loaded in the typescript entry:

"typescript": {
  "extensions": [".ts", ".tsx", ".js", ".jsx", ".mjs", ".cjs"],
  "command": ["typescript-language-server", "--stdio"],
  "initialization": {
    "plugins": [
      {
        "name": "@vue/typescript-plugin",
        "location": "PATH/TO/node_modules/@vue/language-server",
        "languages": ["vue"]
      }
    ]
  }
}

location is a directory that contains the plugin under its node_modules; the plugin must be the same version as the running @vue/language-server. Without that block, template structure and syntax diagnostics still work, but hover, definition and references inside <script> return nothing

Known limits

  • jdtls does not advertise diagnosticProvider, so Java diagnostics come from publishDiagnostics pushes and a fresh file may need a moment to settle. It does advertise implementationProvider

  • Markdown servers are not included. vscode-markdown-language-server requires a client that answers its private markdown/parse request, which generic LSP clients do not implement

  • Position-based actions need the token to be under the cursor position you pass. Selecting a whole identifier range is ambiguous; point at its start

  • No automatic project discovery. The agent passes root explicitly through init, because scanning a directory tree is slow and does not prove which project a file belongs to

Development

npm ci
npm run typecheck
npm run build

dist/ is gitignored and only serves the typecheck and build scripts. opencode loads the root index.ts source directly, so source edits take effect after a plugin reload, no build step required

License

Apache License 2.0. See LICENSE

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • F
      license
      A
      quality
      D
      maintenance
      An MCP stdio server that wraps language servers to expose read-oriented code-intelligence tools (hover, definition, references, diagnostics, etc.) for coding agents, supporting TypeScript/JavaScript and Python.
      56
      1
      -
    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables AI agents to query language intelligence over MCP, including definitions, references, symbols, and code relationship graphs across many languages, all in one native process with no external language servers.
      1
      Apache 2.0
    • F
      license
      Not graded
      quality
      A
      maintenance
      Enables AI coding agents and MCP clients to pull real-time language-server data from a running editor instance, including diagnostics, hover/definition/signature and type information, and symbol references with usage context. It also supports workspace-wide symbol renaming, opening files, and command execution, letting agents validate changes without waiting on slow tsc/eslint runs.
      -
    • F
      license
      Not graded
      quality
      A
      maintenance
      Enables AI coding agents and MCP clients to query real-time LSP diagnostics, type information, definitions, references, and workspace-wide symbol renaming through the editor's language servers, avoiding slow tsc/eslint checks.
      -