@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 +98 -247
- package/dist/index.js +697 -60
- package/dist/index.js.map +6 -6
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,33 +1,12 @@
|
|
|
1
1
|
# @treedy/lsp-mcp
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
One MCP server for Python, TypeScript/JavaScript, and Vue code intelligence.
|
|
4
4
|
|
|
5
|
-
|
|
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
|
-
-
|
|
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
|
-
|
|
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
|
-
|
|
22
|
+
2) Try these first calls:
|
|
44
23
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
44
|
+
## Tool Model (Current)
|
|
169
45
|
|
|
170
|
-
|
|
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
|
-
|
|
48
|
+
Use these directly; language is inferred from file/path:
|
|
182
49
|
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
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
|
-
|
|
55
|
+
Compatibility aliases are also available for older clients, for example:
|
|
56
|
+
`python_hover`, `typescript_definition`, `python_diagnostics`.
|
|
195
57
|
|
|
196
|
-
|
|
58
|
+
### High-volume output controls
|
|
197
59
|
|
|
198
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
77
|
+
- Python-only: `python_move`, `python_change_signature`, `python_function_signature`
|
|
78
|
+
- TypeScript-only: `typescript_move`, `typescript_function_signature`
|
|
250
79
|
|
|
251
|
-
|
|
252
|
-
# Install dependencies
|
|
253
|
-
bun install
|
|
80
|
+
### Server/meta tools
|
|
254
81
|
|
|
255
|
-
|
|
256
|
-
bun run build
|
|
82
|
+
- `status`, `list_backends`, `start_backend`, `update_backend`, `check_versions`, `reload_config`, `switch_python_backend`, `switch_workspace`
|
|
257
83
|
|
|
258
|
-
|
|
259
|
-
bun run dev
|
|
84
|
+
## Prompts (Skills)
|
|
260
85
|
|
|
261
|
-
|
|
262
|
-
|
|
86
|
+
- `code-navigation`
|
|
87
|
+
- `refactoring`
|
|
88
|
+
- `code-analysis`
|
|
89
|
+
- `lsp-rules`
|
|
90
|
+
- `explore-project`
|
|
91
|
+
- `debug-file`
|
|
92
|
+
- `lsp-quick-start`
|
|
263
93
|
|
|
264
|
-
|
|
265
|
-
bun run inspector
|
|
266
|
-
```
|
|
94
|
+
## Configuration
|
|
267
95
|
|
|
268
|
-
|
|
96
|
+
You can configure with env vars or `.lsp-mcp.json` in your workspace.
|
|
269
97
|
|
|
270
|
-
|
|
98
|
+
### Environment Variables
|
|
271
99
|
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
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
|
-
|
|
277
|
-
export LSP_MCP_ROOT=/path/to/PyLspMcp
|
|
110
|
+
### Auto-update behavior
|
|
278
111
|
|
|
279
|
-
|
|
280
|
-
bun dist/index.js
|
|
281
|
-
```
|
|
112
|
+
When `LSP_MCP_AUTO_UPDATE=true`:
|
|
282
113
|
|
|
283
|
-
|
|
284
|
-
-
|
|
285
|
-
-
|
|
286
|
-
-
|
|
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
|
-
##
|
|
119
|
+
## Better Out-of-Box Experience (Recommended)
|
|
289
120
|
|
|
290
|
-
|
|
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
|
-
|
|
293
|
-
- **TypeScript**: `@treedy/typescript-lsp-mcp` (via npx)
|
|
126
|
+
## Development
|
|
294
127
|
|
|
295
|
-
|
|
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
|
|