@treedy/lsp-mcp 0.1.0

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 ADDED
@@ -0,0 +1,272 @@
1
+ # @treedy/lsp-mcp
2
+
3
+ Unified MCP server aggregating multi-language LSP backends for code intelligence. One server provides Python and TypeScript code intelligence through namespaced tools.
4
+
5
+ ## Features
6
+
7
+ - **Unified Entry Point**: Single MCP server for multiple languages
8
+ - **Namespaced Tools**: `python/hover`, `typescript/definition`, etc.
9
+ - **Auto Language Detection**: Infers language from file extensions
10
+ - **Skill Prompts**: Best practices exposed as MCP prompts for agents
11
+ - **Lazy Loading**: Backends start on first use
12
+ - **Graceful Degradation**: Clear error messages when backends unavailable
13
+
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:
31
+
32
+ ```json
33
+ {
34
+ "mcpServers": {
35
+ "lsp-mcp": {
36
+ "command": "npx",
37
+ "args": ["@treedy/lsp-mcp@latest"]
38
+ }
39
+ }
40
+ }
41
+ ```
42
+
43
+ ### Environment Variables
44
+
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
+ | `status` | Overall server and backend status with versions |
99
+ | `check_versions` | Detailed version info for server and all backends |
100
+ | `switch_python_backend` | Switch Python provider |
101
+
102
+ ## Available Prompts (Skills)
103
+
104
+ The server exposes skill documentation as MCP prompts that agents can request:
105
+
106
+ | Prompt | Description |
107
+ |--------|-------------|
108
+ | `code-navigation` | Navigate codebases using hover, definition, references |
109
+ | `refactoring` | Safe cross-file refactoring (rename, move, change_signature) |
110
+ | `code-analysis` | Code analysis techniques (symbols, diagnostics, search) |
111
+ | `lsp-rules` | Best practices for using LSP tools effectively |
112
+ | `lsp-quick-start` | Quick reference guide for essential workflows |
113
+
114
+ ### Key Workflows from Prompts
115
+
116
+ **1. Search → LSP Tools**
117
+ ```
118
+ search("ClassName") → get positions
119
+ hover(file, line, column) → get type info
120
+ definition(...) → jump to definition
121
+ references(...) → find usages
122
+ ```
123
+
124
+ **2. Learn API Before Using**
125
+ ```
126
+ hover(file, line, column) → get documentation
127
+ signature_help(...) → get parameter details
128
+ → Then write correct code
129
+ ```
130
+
131
+ **3. Always Verify with Diagnostics**
132
+ ```
133
+ Edit code
134
+ diagnostics(path) → check for errors
135
+ Fix issues
136
+ Repeat until clean
137
+ ```
138
+
139
+ ## Usage Examples
140
+
141
+ ### Python Hover
142
+
143
+ ```json
144
+ {
145
+ "name": "python/hover",
146
+ "arguments": {
147
+ "file": "/path/to/file.py",
148
+ "line": 10,
149
+ "column": 5
150
+ }
151
+ }
152
+ ```
153
+
154
+ ### TypeScript Definition
155
+
156
+ ```json
157
+ {
158
+ "name": "typescript/definition",
159
+ "arguments": {
160
+ "file": "/path/to/file.ts",
161
+ "line": 15,
162
+ "column": 10
163
+ }
164
+ }
165
+ ```
166
+
167
+ ### Auto Language Detection
168
+
169
+ If you don't use namespaced tools, the language is inferred from the file extension:
170
+
171
+ ```json
172
+ {
173
+ "name": "hover",
174
+ "arguments": {
175
+ "file": "/path/to/file.py"
176
+ }
177
+ }
178
+ ```
179
+
180
+ This will automatically route to the Python backend.
181
+
182
+ ## Architecture
183
+
184
+ ```
185
+ ┌─────────────────────────────────────────────────────────────────┐
186
+ │ Claude Code / AI Client │
187
+ └─────────────────────────────────────────────────────────────────┘
188
+ │ MCP (stdio)
189
+
190
+ ┌─────────────────────────────────────────────────────────────────┐
191
+ │ @treedy/lsp-mcp │
192
+ │ (Unified MCP Server) │
193
+ │ │
194
+ │ ┌────────────────────────────────────────────────────────────┐ │
195
+ │ │ Tool Router │ │
196
+ │ │ - Parse tool name (python/hover → {lang, tool}) │ │
197
+ │ │ - Infer language from file extension │ │
198
+ │ │ - Route to appropriate backend │ │
199
+ │ └────────────────────────────────────────────────────────────┘ │
200
+ │ │ │
201
+ │ ┌────────────────────────────────────────────────────────────┐ │
202
+ │ │ Backend Manager │ │
203
+ │ │ - Lazy load backend processes │ │
204
+ │ │ - Health check and auto-restart │ │
205
+ │ │ - Graceful shutdown │ │
206
+ │ └────────────────────────────────────────────────────────────┘ │
207
+ │ │ │ │
208
+ │ ▼ ▼ │
209
+ │ ┌────────────┐ ┌────────────┐ │
210
+ │ │ Python │ │ TypeScript │ │
211
+ │ │ Backend │ │ Backend │ │
212
+ │ └────────────┘ └────────────┘ │
213
+ └─────────────────────────────────────────────────────────────────┘
214
+ │ MCP (stdio) │ MCP (stdio)
215
+ ▼ ▼
216
+ ┌──────────────┐ ┌──────────────┐
217
+ │python-lsp-mcp│ │typescript- │
218
+ │ (subprocess) │ │ lsp-mcp │
219
+ └──────────────┘ └──────────────┘
220
+ ```
221
+
222
+ ## Development
223
+
224
+ ```bash
225
+ # Install dependencies
226
+ bun install
227
+
228
+ # Build
229
+ bun run build
230
+
231
+ # Run in development mode
232
+ bun run dev
233
+
234
+ # Run tests
235
+ bun run test
236
+
237
+ # Test with MCP Inspector
238
+ bun run inspector
239
+ ```
240
+
241
+ ### Local Development Mode
242
+
243
+ For testing with local backend packages (not published to npm/PyPI):
244
+
245
+ ```bash
246
+ # Set environment variable for local mode
247
+ export LSP_MCP_LOCAL=1
248
+
249
+ # Or set the project root explicitly
250
+ export LSP_MCP_ROOT=/path/to/PyLspMcp
251
+
252
+ # Then run the server
253
+ bun dist/index.js
254
+ ```
255
+
256
+ In local mode, backends are started from:
257
+ - Python (pyright-mcp): `{root}/backends/python/pyright-mcp/dist/index.js`
258
+ - Python (python-lsp-mcp): `{root}/backends/python/python-lsp-mcp` via `uv run`
259
+ - TypeScript: `{root}/backends/typescript/typescript-lsp-mcp/dist/index.js`
260
+
261
+ ## Dependencies
262
+
263
+ The unified server requires the backend packages to be available:
264
+
265
+ - **Python**: `python-lsp-mcp` (via uvx) or `@treedy/pyright-mcp` (via npx)
266
+ - **TypeScript**: `@treedy/typescript-lsp-mcp` (via npx)
267
+
268
+ These are installed automatically when the respective backends are first used.
269
+
270
+ ## License
271
+
272
+ MIT