update README

This commit is contained in:
EFLKumo committed 2026-09-19 18:52:08 +08:00
1 parent 241a5ba417
commit d864978ab3
1 file changed
+19 -24
+19 -24
View File
@@ -1,5 +1,9 @@
# lsp-mcp # lsp-mcp
```sh
npx -y @opticlm/lsp-mcp
```
An [MCP](https://modelcontextprotocol.io/) server that exposes a single [Language Server Protocol](https://microsoft.github.io/language-server-protocol/) server to agents as a headless editor. An [MCP](https://modelcontextprotocol.io/) server that exposes a single [Language Server Protocol](https://microsoft.github.io/language-server-protocol/) server to agents as a headless editor.
`lsp-mcp` starts the language server you provide, keeps its document state in sync with the workspace, and exposes the language server's capabilities through MCP tools and resources. It is written in TypeScript and [Effect](https://effect.website). `lsp-mcp` starts the language server you provide, keeps its document state in sync with the workspace, and exposes the language server's capabilities through MCP tools and resources. It is written in TypeScript and [Effect](https://effect.website).
@@ -18,27 +22,12 @@ Underlying techniques:
- 1-based line and column positions designed for agent-facing use - 1-based line and column positions designed for agent-facing use
- Capability-aware tool registration: unsupported LSP features are not advertised - Capability-aware tool registration: unsupported LSP features are not advertised
## Requirements
- Node.js 26+
- pnpm 12.4.2+
- An installed language server executable
## Installation
```sh
pnpm install
pnpm build
```
From a checkout, invoke the built server with `node dist/main.mjs`. Use `pnpm dev` to run the TypeScript source directly during development.
## Usage ## Usage
The general form is: The general form is:
```sh ```sh
node dist/main.mjs [lsp-mcp options] -- <language-server> [language-server args...] npx -y @opticlm/lsp-mcp [lsp-mcp options] -- <language-server> [language-server args...]
``` ```
The `--` separates `lsp-mcp` options from the executable and arguments passed to the language server. The `--` separates `lsp-mcp` options from the executable and arguments passed to the language server.
@@ -48,7 +37,7 @@ The `--` separates `lsp-mcp` options from the executable and arguments passed to
stdio is the default transport and is suitable for MCP clients that launch a local server process: stdio is the default transport and is suitable for MCP clients that launch a local server process:
```sh ```sh
node dist/main.mjs --root /path/to/project -- typescript-language-server --stdio npx -y @opticlm/lsp-mcp --root /path/to/project -- typescript-language-server --stdio
``` ```
For example, an MCP client configuration can point at the checkout like this: For example, an MCP client configuration can point at the checkout like this:
@@ -57,9 +46,10 @@ For example, an MCP client configuration can point at the checkout like this:
{ {
"mcpServers": { "mcpServers": {
"typescript": { "typescript": {
"command": "node", "command": "npx",
"args": [ "args": [
"/path/to/lsp-mcp/dist/main.mjs", "-y",
"@opticlm/lsp-mcp",
"--root", "--root",
"/path/to/project", "/path/to/project",
"--", "--",
@@ -76,7 +66,7 @@ For example, an MCP client configuration can point at the checkout like this:
Run the MCP endpoint on a local port with `--http`: Run the MCP endpoint on a local port with `--http`:
```sh ```sh
node dist/main.mjs --http 9010 --root ./crate -- rust-analyzer npx -y @opticlm/lsp-mcp --http 9010 --root ./crate -- rust-analyzer
``` ```
The endpoint is available at: The endpoint is available at:
@@ -89,24 +79,29 @@ http://localhost:9010/mcp
```sh ```sh
# Pass JSON initialization options to the language server. # Pass JSON initialization options to the language server.
node dist/main.mjs \ npx -y @opticlm/lsp-mcp \
--init-options '{"typescript":{"useInferredProjectPerProjectRoot":true}}' \ --init-options '{"typescript":{"useInferredProjectPerProjectRoot":true}}' \
-- typescript-language-server --stdio -- typescript-language-server --stdio
# Serve workspace/configuration and didChangeConfiguration with JSON settings. # Serve workspace/configuration and didChangeConfiguration with JSON settings.
node dist/main.mjs \ npx -y @opticlm/lsp-mcp \
--settings '{"gopls":{"staticcheck":true}}' \ --settings '{"gopls":{"staticcheck":true}}' \
-- gopls -- gopls
# Add a file-extension to language-id mapping. # Add a file-extension to language-id mapping.
node dist/main.mjs --language vue=vue --root ./web -- vue-language-server --stdio npx -y @opticlm/lsp-mcp --language vue=vue --root ./web -- vue-language-server --stdio
# Keep more documents open, and always restart a crashed language server. # Keep more documents open, and always restart a crashed language server.
node dist/main.mjs --open-documents 64 --restart always -- clangd npx -y @opticlm/lsp-mcp --open-documents 64 --restart always -- clangd
``` ```
## Development ## Development
Requirements:
- Node.js 26+
- pnpm 12.4.2+
```sh ```sh
pnpm test # Run the Vitest suite, including the fixture LSP integration tests pnpm test # Run the Vitest suite, including the fixture LSP integration tests
pnpm check # Type-check without emitting JavaScript pnpm check # Type-check without emitting JavaScript