@treedy/lsp-mcp 0.2.2 → 0.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,33 +1,12 @@
1
1
  # @treedy/lsp-mcp
2
2
 
3
- Unified MCP server aggregating multi-language LSP backends for code intelligence. One server provides Python and TypeScript code intelligence through namespaced tools.
3
+ One MCP server for Python, TypeScript/JavaScript, and Vue code intelligence.
4
4
 
5
- ## Features
5
+ It pre-registers unified LSP tools (`hover`, `definition`, `diagnostics`, etc.), auto-detects language from file path, and auto-starts backends on first use.
6
6
 
7
- - **Unified Entry Point**: Single MCP server for multiple languages
8
- - **Namespaced Tools**: `python_hover`, `typescript_definition`, etc.
9
- - **On-Demand Loading**: Backends are installed and started only when needed
10
- - **Dynamic Tool Registration**: Backend tools are discovered automatically
11
- - **Skill Prompts**: Best practices exposed as MCP prompts for agents
12
- - **Graceful Degradation**: Clear error messages when backends unavailable
7
+ ## 60-Second Setup
13
8
 
14
- ## Installation
15
-
16
- ```bash
17
- npm install -g @treedy/lsp-mcp
18
- ```
19
-
20
- Or use directly with npx:
21
-
22
- ```bash
23
- npx @treedy/lsp-mcp
24
- ```
25
-
26
- ## Configuration
27
-
28
- ### Claude Code / AI Client
29
-
30
- Add to your MCP configuration:
9
+ 1) Add to your MCP client config:
31
10
 
32
11
  ```json
33
12
  {
@@ -40,259 +19,131 @@ Add to your MCP configuration:
40
19
  }
41
20
  ```
42
21
 
43
- ### Environment Variables
22
+ 2) Try these first calls:
44
23
 
45
- | Variable | Default | Description |
46
- |----------|---------|-------------|
47
- | `LSP_MCP_PYTHON_ENABLED` | `true` | Enable Python backend |
48
- | `LSP_MCP_PYTHON_PROVIDER` | `python-lsp-mcp` | Python provider (`python-lsp-mcp` or `pyright-mcp`) |
49
- | `LSP_MCP_TYPESCRIPT_ENABLED` | `true` | Enable TypeScript backend |
50
- | `LSP_MCP_AUTO_UPDATE` | `true` | Automatically update backends to latest versions on startup |
51
-
52
- ### Auto-Update Behavior
53
-
54
- When `LSP_MCP_AUTO_UPDATE=true` (default), backends are automatically updated on startup:
55
-
56
- | Backend | Registry | Update Command |
57
- |---------|----------|----------------|
58
- | python-lsp-mcp (Rope) | PyPI | `uvx --upgrade python-lsp-mcp` |
59
- | pyright-mcp | npm | `npx --yes @treedy/pyright-mcp@latest` |
60
- | typescript-lsp-mcp | npm | `npx --yes @treedy/typescript-lsp-mcp@latest` |
61
-
62
- This ensures backends are always up-to-date when the server starts. To disable auto-update and use cached versions, set `LSP_MCP_AUTO_UPDATE=false`.
63
-
64
- ## Available Tools
65
-
66
- ### Common Tools (both languages)
67
-
68
- | Tool | Description |
69
- |------|-------------|
70
- | `{lang}_hover` | Get type information and documentation |
71
- | `{lang}_definition` | Go to definition |
72
- | `{lang}_references` | Find all references |
73
- | `{lang}_completions` | Code completion suggestions |
74
- | `{lang}_diagnostics` | Type errors and warnings |
75
- | `{lang}_symbols` | Extract symbols from file |
76
- | `{lang}_rename` | Rename symbol |
77
- | `{lang}_search` | Regex pattern search |
78
- | `{lang}_signature_help` | Function signature help |
79
- | `{lang}_update_document` | Update file for incremental analysis |
80
- | `{lang}_status` | Backend status |
81
-
82
- Replace `{lang}` with `python` or `typescript`.
83
-
84
- ### Python-Only Tools
85
-
86
- | Tool | Description |
87
- |------|-------------|
88
- | `python_move` | Move function/class to another module |
89
- | `python_change_signature` | Modify function signature |
90
- | `python_function_signature` | Get current function signature |
91
- | `python_set_backend` | Switch between rope/pyright |
92
- | `python_set_python_path` | Set Python interpreter |
93
-
94
- ### Meta Tools
95
-
96
- | Tool | Description |
97
- |------|-------------|
98
- | `list_backends` | List available backends and their status |
99
- | `start_backend` | Install and start a backend (downloads if needed) |
100
- | `update_backend` | Update a backend to the latest version |
101
- | `status` | Overall server and backend status with versions |
102
- | `check_versions` | Detailed version info for server and all backends |
103
- | `switch_python_backend` | Switch Python provider |
104
-
105
- ## Quick Start
106
-
107
- 1. **List available backends**:
108
- ```
109
- list_backends
110
- ```
111
-
112
- 2. **Start a backend** (this will download and install if needed):
113
- ```
114
- start_backend language=python
115
- start_backend language=typescript
116
- ```
117
-
118
- 3. **Use backend tools** (available after starting):
119
- ```
120
- python_hover file=/path/to/file.py line=10 column=5
121
- typescript_definition file=/path/to/file.ts line=15 column=10
122
- ```
123
-
124
- 4. **Update a backend** (when new version is available):
125
- ```
126
- update_backend language=python
127
- ```
128
-
129
- ## Available Prompts (Skills)
130
-
131
- The server exposes skill documentation as MCP prompts that agents can request:
132
-
133
- | Prompt | Description |
134
- |--------|-------------|
135
- | `code-navigation` | Navigate codebases using hover, definition, references |
136
- | `refactoring` | Safe cross-file refactoring (rename, move, change_signature) |
137
- | `code-analysis` | Code analysis techniques (symbols, diagnostics, search) |
138
- | `lsp-rules` | Best practices for using LSP tools effectively |
139
- | `lsp-quick-start` | Quick reference guide for essential workflows |
140
-
141
- ### Key Workflows from Prompts
142
-
143
- **1. Search → LSP Tools**
144
- ```
145
- search("ClassName") → get positions
146
- hover(file, line, column) → get type info
147
- definition(...) → jump to definition
148
- references(...) → find usages
24
+ ```txt
25
+ status
26
+ list_backends
27
+ hover file=/abs/path/to/file.py line=10 column=5
28
+ diagnostics path=/abs/path/to/project
29
+ git_diagnostics
149
30
  ```
150
31
 
151
- **2. Learn API Before Using**
152
- ```
153
- hover(file, line, column) → get documentation
154
- signature_help(...) → get parameter details
155
- → Then write correct code
156
- ```
32
+ `start_backend` is optional now. Backends are started automatically when a tool needs them.
157
33
 
158
- **3. Always Verify with Diagnostics**
159
- ```
160
- Edit code
161
- diagnostics(path) → check for errors
162
- Fix issues
163
- Repeat until clean
164
- ```
34
+ ## What You Get
165
35
 
166
- ## Usage Examples
36
+ - Unified tools across languages: `hover`, `definition`, `references`, `search`, `diagnostics`, `rename`, etc.
37
+ - Language-specific refactor tools where needed:
38
+ - Python: `python_move`, `python_change_signature`, `python_function_signature`
39
+ - TypeScript: `typescript_move`, `typescript_function_signature`
40
+ - Meta/admin tools: `status`, `list_backends`, `check_versions`, `update_backend`, `reload_config`, `switch_workspace`
41
+ - Meta/admin tools: `status`, `list_backends`, `check_versions`, `update_backend`, `reload_config`, `switch_workspace`, `doctor`, `expand_result`
42
+ - Built-in prompts for agent workflows and best practices
167
43
 
168
- ### Python Hover
44
+ ## Tool Model (Current)
169
45
 
170
- ```json
171
- {
172
- "name": "python_hover",
173
- "arguments": {
174
- "file": "/path/to/file.py",
175
- "line": 10,
176
- "column": 5
177
- }
178
- }
179
- ```
46
+ ### Unified tools (preferred)
180
47
 
181
- ### TypeScript Definition
48
+ Use these directly; language is inferred from file/path:
182
49
 
183
- ```json
184
- {
185
- "name": "typescript_definition",
186
- "arguments": {
187
- "file": "/path/to/file.ts",
188
- "line": 15,
189
- "column": 10
190
- }
191
- }
192
- ```
50
+ - Navigation: `hover`, `definition`, `references`, `peek_definition`, `workspace_symbol`
51
+ - Editing support: `completions`, `signature_help`, `rename`, `code_action`, `run_code_action`
52
+ - Analysis: `diagnostics`, `git_diagnostics`, `symbols`, `search`, `summarize_file`, `read_file_with_hints`, `project_structure`
53
+ - Sync/edit loop: `update_document`
193
54
 
194
- ### Auto Language Detection
55
+ Compatibility aliases are also available for older clients, for example:
56
+ `python_hover`, `typescript_definition`, `python_diagnostics`.
195
57
 
196
- If you don't use namespaced tools, the language is inferred from the file extension:
58
+ ### High-volume output controls
197
59
 
198
- ```json
199
- {
200
- "name": "hover",
201
- "arguments": {
202
- "file": "/path/to/file.py"
203
- }
204
- }
205
- ```
60
+ For large repos, use preview arguments to reduce token usage:
206
61
 
207
- This will automatically route to the Python backend.
62
+ - `search` / `workspace_symbol`: `preview_limit` or `page_size` (default `200`), plus `cursor` for next page
63
+ - `diagnostics`: `preview_limit` or `page_size` (default `200`), `summary_only` (default `false`), plus `cursor`
64
+ - `doctor`: `page_size` (default `50`) plus `cursor` for long environment reports
65
+ - `project_structure`: `max_depth` (default `3`), `max_entries` (default `300`)
66
+ - `summarize_file`: `max_symbols` (default `200`)
67
+ - `read_file_with_hints`: `start_line` (default `1`), `max_lines` (default `300`)
68
+ - `project_structure` / `summarize_file` / `read_file_with_hints`: also support `page_size` + `cursor`
208
69
 
209
- ## Architecture
70
+ Paged responses include:
71
+ - `page`: `{ shown, offset, page_size, has_more, next_cursor }`
72
+ - `next`: ready-to-call arguments for the next page (via `expand_result`)
73
+ - Cursors are signed and expire automatically (TTL-based) for safer paging.
210
74
 
211
- ```
212
- ┌─────────────────────────────────────────────────────────────────┐
213
- │ Claude Code / AI Client │
214
- └─────────────────────────────────────────────────────────────────┘
215
- │ MCP (stdio)
216
-
217
- ┌─────────────────────────────────────────────────────────────────┐
218
- │ @treedy/lsp-mcp │
219
- │ (Unified MCP Server) │
220
- │ │
221
- │ ┌────────────────────────────────────────────────────────────┐ │
222
- │ │ Tool Router │ │
223
- │ │ - Parse tool name (python_hover → {lang, tool}) │ │
224
- │ │ - Infer language from file extension │ │
225
- │ │ - Route to appropriate backend │ │
226
- │ └────────────────────────────────────────────────────────────┘ │
227
- │ │ │
228
- │ ┌────────────────────────────────────────────────────────────┐ │
229
- │ │ Backend Manager │ │
230
- │ │ - Lazy load backend processes │ │
231
- │ │ - Health check and auto-restart │ │
232
- │ │ - Graceful shutdown │ │
233
- │ └────────────────────────────────────────────────────────────┘ │
234
- │ │ │ │
235
- │ ▼ ▼ │
236
- │ ┌────────────┐ ┌────────────┐ │
237
- │ │ Python │ │ TypeScript │ │
238
- │ │ Backend │ │ Backend │ │
239
- │ └────────────┘ └────────────┘ │
240
- └─────────────────────────────────────────────────────────────────┘
241
- │ MCP (stdio) │ MCP (stdio)
242
- ▼ ▼
243
- ┌──────────────┐ ┌──────────────┐
244
- │python-lsp-mcp│ │typescript- │
245
- │ (subprocess) │ │ lsp-mcp │
246
- └──────────────┘ └──────────────┘
247
- ```
75
+ ### Language-specific tools
248
76
 
249
- ## Development
77
+ - Python-only: `python_move`, `python_change_signature`, `python_function_signature`
78
+ - TypeScript-only: `typescript_move`, `typescript_function_signature`
250
79
 
251
- ```bash
252
- # Install dependencies
253
- bun install
80
+ ### Server/meta tools
254
81
 
255
- # Build
256
- bun run build
82
+ - `status`, `list_backends`, `start_backend`, `update_backend`, `check_versions`, `reload_config`, `switch_python_backend`, `switch_workspace`
257
83
 
258
- # Run in development mode
259
- bun run dev
84
+ ## Prompts (Skills)
260
85
 
261
- # Run tests
262
- bun run test
86
+ - `code-navigation`
87
+ - `refactoring`
88
+ - `code-analysis`
89
+ - `lsp-rules`
90
+ - `explore-project`
91
+ - `debug-file`
92
+ - `lsp-quick-start`
263
93
 
264
- # Test with MCP Inspector
265
- bun run inspector
266
- ```
94
+ ## Configuration
267
95
 
268
- ### Local Development Mode
96
+ You can configure with env vars or `.lsp-mcp.json` in your workspace.
269
97
 
270
- For testing with local backend packages (not published to npm/PyPI):
98
+ ### Environment Variables
271
99
 
272
- ```bash
273
- # Set environment variable for local mode
274
- export LSP_MCP_LOCAL=1
100
+ | Variable | Default | Description |
101
+ |----------|---------|-------------|
102
+ | `LSP_MCP_PYTHON_ENABLED` | `true` | Enable Python backend |
103
+ | `LSP_MCP_PYTHON_PROVIDER` | `python-lsp-mcp` | Python provider (`python-lsp-mcp` or `pyright-mcp`) |
104
+ | `LSP_MCP_TYPESCRIPT_ENABLED` | `true` | Enable TypeScript backend |
105
+ | `LSP_MCP_VUE_ENABLED` | `true` | Enable Vue backend |
106
+ | `LSP_MCP_AUTO_UPDATE` | `true` | Update backend packages to latest on startup/update |
107
+ | `LSP_MCP_EAGER_START` | `false` | Start all enabled backends when server boots |
108
+ | `LSP_MCP_IDLE_TIMEOUT` | `600` | Backend idle timeout in seconds |
275
109
 
276
- # Or set the project root explicitly
277
- export LSP_MCP_ROOT=/path/to/PyLspMcp
110
+ ### Auto-update behavior
278
111
 
279
- # Then run the server
280
- bun dist/index.js
281
- ```
112
+ When `LSP_MCP_AUTO_UPDATE=true`:
282
113
 
283
- In local mode, backends are started from:
284
- - Python (pyright-mcp): `{root}/backends/python/pyright-mcp/dist/index.js`
285
- - Python (python-lsp-mcp): `{root}/backends/python/python-lsp-mcp` via `uv run`
286
- - TypeScript: `{root}/backends/typescript/typescript-lsp-mcp/dist/index.js`
114
+ - `python-lsp-mcp` via `uvx --upgrade python-lsp-mcp`
115
+ - `pyright-mcp` via `npx --yes @treedy/pyright-mcp@latest`
116
+ - `typescript-lsp-mcp` via `npx --yes @treedy/typescript-lsp-mcp@latest`
117
+ - `vue-lsp-mcp` via `npx --yes @treedy/vue-lsp-mcp@latest`
287
118
 
288
- ## Dependencies
119
+ ## Better Out-of-Box Experience (Recommended)
289
120
 
290
- The unified server requires the backend packages to be available:
121
+ - Use absolute file paths for the first calls to avoid inference edge cases.
122
+ - Call `switch_workspace path=/abs/project/root` once per session for stable cross-file behavior.
123
+ - For mixed-language repos, prefer `git_diagnostics` before broad `diagnostics path=.`
124
+ - If startup speed matters, set `LSP_MCP_EAGER_START=true`.
291
125
 
292
- - **Python**: `python-lsp-mcp` (via uvx) or `@treedy/pyright-mcp` (via npx)
293
- - **TypeScript**: `@treedy/typescript-lsp-mcp` (via npx)
126
+ ## Development
294
127
 
295
- These are installed automatically when the respective backends are first used.
128
+ ```bash
129
+ # Install deps
130
+ bun install
131
+
132
+ # Build
133
+ bun run build
134
+
135
+ # Run in watch mode
136
+ bun run dev
137
+
138
+ # Core integration tests
139
+ bun run test
140
+
141
+ # Prompt integration tests
142
+ bun test test/integration/prompts.test.ts
143
+
144
+ # Manual inspection
145
+ bun run inspector
146
+ ```
296
147
 
297
148
  ## License
298
149