@treedy/lsp-mcp 0.1.7 → 0.1.8

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.
Files changed (76) hide show
  1. package/dist/bundled/pyright/dist/index.d.ts +2 -0
  2. package/dist/bundled/pyright/dist/index.js +1620 -0
  3. package/dist/bundled/pyright/dist/index.js.map +26 -0
  4. package/dist/bundled/pyright/dist/lsp/connection.d.ts +71 -0
  5. package/dist/bundled/pyright/dist/lsp/document-manager.d.ts +67 -0
  6. package/dist/bundled/pyright/dist/lsp/index.d.ts +3 -0
  7. package/dist/bundled/pyright/dist/lsp/types.d.ts +55 -0
  8. package/dist/bundled/pyright/dist/lsp-client.d.ts +55 -0
  9. package/dist/bundled/pyright/dist/tools/completions.d.ts +18 -0
  10. package/dist/bundled/pyright/dist/tools/definition.d.ts +16 -0
  11. package/dist/bundled/pyright/dist/tools/diagnostics.d.ts +12 -0
  12. package/dist/bundled/pyright/dist/tools/hover.d.ts +16 -0
  13. package/dist/bundled/pyright/dist/tools/references.d.ts +16 -0
  14. package/dist/bundled/pyright/dist/tools/rename.d.ts +18 -0
  15. package/dist/bundled/pyright/dist/tools/search.d.ts +20 -0
  16. package/dist/bundled/pyright/dist/tools/signature-help.d.ts +16 -0
  17. package/dist/bundled/pyright/dist/tools/status.d.ts +14 -0
  18. package/dist/bundled/pyright/dist/tools/symbols.d.ts +17 -0
  19. package/dist/bundled/pyright/dist/tools/update-document.d.ts +14 -0
  20. package/dist/bundled/pyright/dist/utils/position.d.ts +33 -0
  21. package/dist/bundled/pyright/package.json +54 -0
  22. package/dist/bundled/python/README.md +230 -0
  23. package/dist/bundled/python/pyproject.toml +61 -0
  24. package/dist/bundled/python/src/rope_mcp/__init__.py +3 -0
  25. package/dist/bundled/python/src/rope_mcp/__pycache__/__init__.cpython-312.pyc +0 -0
  26. package/dist/bundled/python/src/rope_mcp/__pycache__/__init__.cpython-313.pyc +0 -0
  27. package/dist/bundled/python/src/rope_mcp/__pycache__/config.cpython-312.pyc +0 -0
  28. package/dist/bundled/python/src/rope_mcp/__pycache__/config.cpython-313.pyc +0 -0
  29. package/dist/bundled/python/src/rope_mcp/__pycache__/pyright_client.cpython-313.pyc +0 -0
  30. package/dist/bundled/python/src/rope_mcp/__pycache__/rope_client.cpython-313.pyc +0 -0
  31. package/dist/bundled/python/src/rope_mcp/__pycache__/server.cpython-312.pyc +0 -0
  32. package/dist/bundled/python/src/rope_mcp/__pycache__/server.cpython-313.pyc +0 -0
  33. package/dist/bundled/python/src/rope_mcp/config.py +408 -0
  34. package/dist/bundled/python/src/rope_mcp/lsp/__init__.py +15 -0
  35. package/dist/bundled/python/src/rope_mcp/lsp/__pycache__/__init__.cpython-313.pyc +0 -0
  36. package/dist/bundled/python/src/rope_mcp/lsp/__pycache__/client.cpython-313.pyc +0 -0
  37. package/dist/bundled/python/src/rope_mcp/lsp/__pycache__/types.cpython-313.pyc +0 -0
  38. package/dist/bundled/python/src/rope_mcp/lsp/client.py +624 -0
  39. package/dist/bundled/python/src/rope_mcp/lsp/types.py +82 -0
  40. package/dist/bundled/python/src/rope_mcp/pyright_client.py +147 -0
  41. package/dist/bundled/python/src/rope_mcp/rope_client.py +198 -0
  42. package/dist/bundled/python/src/rope_mcp/server.py +963 -0
  43. package/dist/bundled/python/src/rope_mcp/tools/__init__.py +26 -0
  44. package/dist/bundled/python/src/rope_mcp/tools/__pycache__/__init__.cpython-313.pyc +0 -0
  45. package/dist/bundled/python/src/rope_mcp/tools/__pycache__/change_signature.cpython-313.pyc +0 -0
  46. package/dist/bundled/python/src/rope_mcp/tools/__pycache__/completions.cpython-313.pyc +0 -0
  47. package/dist/bundled/python/src/rope_mcp/tools/__pycache__/definition.cpython-313.pyc +0 -0
  48. package/dist/bundled/python/src/rope_mcp/tools/__pycache__/diagnostics.cpython-313.pyc +0 -0
  49. package/dist/bundled/python/src/rope_mcp/tools/__pycache__/hover.cpython-313.pyc +0 -0
  50. package/dist/bundled/python/src/rope_mcp/tools/__pycache__/move.cpython-313.pyc +0 -0
  51. package/dist/bundled/python/src/rope_mcp/tools/__pycache__/references.cpython-313.pyc +0 -0
  52. package/dist/bundled/python/src/rope_mcp/tools/__pycache__/rename.cpython-313.pyc +0 -0
  53. package/dist/bundled/python/src/rope_mcp/tools/__pycache__/search.cpython-313.pyc +0 -0
  54. package/dist/bundled/python/src/rope_mcp/tools/__pycache__/symbols.cpython-313.pyc +0 -0
  55. package/dist/bundled/python/src/rope_mcp/tools/change_signature.py +184 -0
  56. package/dist/bundled/python/src/rope_mcp/tools/completions.py +84 -0
  57. package/dist/bundled/python/src/rope_mcp/tools/definition.py +51 -0
  58. package/dist/bundled/python/src/rope_mcp/tools/diagnostics.py +18 -0
  59. package/dist/bundled/python/src/rope_mcp/tools/hover.py +49 -0
  60. package/dist/bundled/python/src/rope_mcp/tools/move.py +81 -0
  61. package/dist/bundled/python/src/rope_mcp/tools/references.py +60 -0
  62. package/dist/bundled/python/src/rope_mcp/tools/rename.py +61 -0
  63. package/dist/bundled/python/src/rope_mcp/tools/search.py +128 -0
  64. package/dist/bundled/python/src/rope_mcp/tools/symbols.py +118 -0
  65. package/dist/bundled/python/uv.lock +979 -0
  66. package/dist/bundled/typescript/dist/index.js +29534 -0
  67. package/dist/bundled/typescript/dist/index.js.map +211 -0
  68. package/dist/bundled/typescript/package.json +46 -0
  69. package/dist/bundled/vue/dist/index.d.ts +8 -0
  70. package/dist/bundled/vue/dist/index.js +21111 -0
  71. package/dist/bundled/vue/dist/ts-vue-service.d.ts +67 -0
  72. package/dist/bundled/vue/dist/vue-service.d.ts +144 -0
  73. package/dist/bundled/vue/package.json +45 -0
  74. package/dist/index.js +148 -58
  75. package/dist/index.js.map +4 -4
  76. package/package.json +1 -1
@@ -0,0 +1,18 @@
1
+ import { z } from 'zod';
2
+ export declare const renameSchema: {
3
+ file: z.ZodString;
4
+ line: z.ZodNumber;
5
+ column: z.ZodNumber;
6
+ newName: z.ZodString;
7
+ };
8
+ export declare function rename(args: {
9
+ file: string;
10
+ line: number;
11
+ column: number;
12
+ newName: string;
13
+ }): Promise<{
14
+ content: {
15
+ type: "text";
16
+ text: string;
17
+ }[];
18
+ }>;
@@ -0,0 +1,20 @@
1
+ import { z } from 'zod';
2
+ export declare const searchSchema: {
3
+ pattern: z.ZodString;
4
+ path: z.ZodOptional<z.ZodString>;
5
+ glob: z.ZodOptional<z.ZodString>;
6
+ caseSensitive: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
7
+ maxResults: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
8
+ };
9
+ export declare function search(args: {
10
+ pattern: string;
11
+ path?: string;
12
+ glob?: string;
13
+ caseSensitive?: boolean;
14
+ maxResults?: number;
15
+ }): Promise<{
16
+ content: Array<{
17
+ type: 'text';
18
+ text: string;
19
+ }>;
20
+ }>;
@@ -0,0 +1,16 @@
1
+ import { z } from 'zod';
2
+ export declare const signatureHelpSchema: {
3
+ file: z.ZodString;
4
+ line: z.ZodNumber;
5
+ column: z.ZodNumber;
6
+ };
7
+ export declare function signatureHelp(args: {
8
+ file: string;
9
+ line: number;
10
+ column: number;
11
+ }): Promise<{
12
+ content: {
13
+ type: "text";
14
+ text: string;
15
+ }[];
16
+ }>;
@@ -0,0 +1,14 @@
1
+ import { z } from 'zod';
2
+ export declare const statusSchema: {
3
+ file: z.ZodString;
4
+ };
5
+ type StatusArgs = {
6
+ file: string;
7
+ };
8
+ export declare function status(args: StatusArgs): Promise<{
9
+ content: Array<{
10
+ type: 'text';
11
+ text: string;
12
+ }>;
13
+ }>;
14
+ export {};
@@ -0,0 +1,17 @@
1
+ import { z } from 'zod';
2
+ import { SymbolFilter } from '../lsp/types.js';
3
+ export declare const symbolsSchema: {
4
+ file: z.ZodString;
5
+ filter: z.ZodDefault<z.ZodOptional<z.ZodEnum<["all", "classes", "functions", "methods", "variables"]>>>;
6
+ includeChildren: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
7
+ };
8
+ export declare function symbols(args: {
9
+ file: string;
10
+ filter?: SymbolFilter;
11
+ includeChildren?: boolean;
12
+ }): Promise<{
13
+ content: {
14
+ type: "text";
15
+ text: string;
16
+ }[];
17
+ }>;
@@ -0,0 +1,14 @@
1
+ import { z } from 'zod';
2
+ export declare const updateDocumentSchema: {
3
+ file: z.ZodString;
4
+ content: z.ZodString;
5
+ };
6
+ export declare function updateDocument(args: {
7
+ file: string;
8
+ content: string;
9
+ }): Promise<{
10
+ content: {
11
+ type: "text";
12
+ text: string;
13
+ }[];
14
+ }>;
@@ -0,0 +1,33 @@
1
+ import { Position, Range, Location } from 'vscode-languageserver-protocol';
2
+ /**
3
+ * Convert 1-based line/column (user input) to 0-based LSP Position
4
+ */
5
+ export declare function toPosition(line: number, column: number): Position;
6
+ /**
7
+ * Convert 0-based LSP Position to 1-based line/column (user output)
8
+ */
9
+ export declare function fromPosition(pos: Position): {
10
+ line: number;
11
+ column: number;
12
+ };
13
+ /**
14
+ * Format a Location for display
15
+ */
16
+ export declare function formatLocation(loc: Location): string;
17
+ /**
18
+ * Format a Range for display
19
+ */
20
+ export declare function formatRange(range: Range): string;
21
+ /**
22
+ * Convert file path to URI
23
+ */
24
+ export declare function pathToUri(filePath: string): string;
25
+ /**
26
+ * Convert URI to file path
27
+ */
28
+ export declare function uriToPath(uri: string): string;
29
+ /**
30
+ * Find project root by looking for pyrightconfig.json or pyproject.toml
31
+ * starting from the given file path and walking up the directory tree
32
+ */
33
+ export declare function findProjectRoot(filePath: string): string;
@@ -0,0 +1,54 @@
1
+ {
2
+ "name": "@treedy/pyright-mcp",
3
+ "version": "1.1.6",
4
+ "description": "MCP server exposing Pyright LSP features for Python code intelligence",
5
+ "type": "module",
6
+ "main": "dist/index.js",
7
+ "bin": {
8
+ "pyright-mcp": "./dist/index.js"
9
+ },
10
+ "files": [
11
+ "dist"
12
+ ],
13
+ "scripts": {
14
+ "build": "bun run build.ts",
15
+ "build:tsc": "tsc",
16
+ "prepublishOnly": "bun run build",
17
+ "start": "bun dist/index.js",
18
+ "dev": "bun --watch src/index.ts",
19
+ "test:pyright": "bun test/test-pyright-direct.mjs",
20
+ "test:mcp": "bun test/test-mcp.mjs",
21
+ "test:benchmark": "node test/test-benchmark.mjs",
22
+ "inspector": "bunx @modelcontextprotocol/inspector bun dist/index.js"
23
+ },
24
+ "keywords": [
25
+ "mcp",
26
+ "pyright",
27
+ "python",
28
+ "lsp",
29
+ "language-server",
30
+ "claude",
31
+ "ai",
32
+ "code-intelligence",
33
+ "type-checking"
34
+ ],
35
+ "author": "",
36
+ "license": "MIT",
37
+ "repository": {
38
+ "type": "git",
39
+ "url": ""
40
+ },
41
+ "engines": {
42
+ "node": ">=18.0.0"
43
+ },
44
+ "dependencies": {
45
+ "@modelcontextprotocol/sdk": "^1.0.0",
46
+ "vscode-jsonrpc": "^8.2.0",
47
+ "vscode-languageserver-protocol": "^3.17.5",
48
+ "zod": "^3.23.0"
49
+ },
50
+ "devDependencies": {
51
+ "@types/node": "^20.0.0",
52
+ "typescript": "^5.4.0"
53
+ }
54
+ }
@@ -0,0 +1,230 @@
1
+ # Python LSP MCP Server
2
+
3
+ Python MCP server providing code analysis features using [Rope](https://github.com/python-rope/rope) and [Pyright](https://github.com/microsoft/pyright).
4
+
5
+ ## Features
6
+
7
+ | Tool | Description | Backend |
8
+ |------|-------------|---------|
9
+ | `hover` | Get documentation at position | Rope/Pyright |
10
+ | `definition` | Go to symbol definition | Rope/Pyright |
11
+ | `references` | Find all references | Rope/Pyright |
12
+ | `completions` | Code completion suggestions | Rope/Pyright |
13
+ | `symbols` | Extract document symbols | Rope/Pyright |
14
+ | `rename` | Rename refactoring | Rope |
15
+ | `move` | Move function/class to another module | Rope |
16
+ | `change_signature` | Change function parameters | Rope |
17
+ | `function_signature` | Get function signature info | Rope |
18
+ | `diagnostics` | Type checking errors | Pyright |
19
+ | `signature_help` | Function signatures | Pyright |
20
+ | `update_document` | Incremental document updates | Pyright |
21
+ | `search` | Regex search in files | ripgrep |
22
+ | `set_backend` | Switch backend at runtime | - |
23
+ | `status` | Server status info | - |
24
+
25
+ ## Installation
26
+
27
+ ### From PyPI (Recommended)
28
+
29
+ ```bash
30
+ # Using uvx (no install needed)
31
+ uvx python-lsp-mcp@latest
32
+
33
+ # Using pipx
34
+ pipx install python-lsp-mcp
35
+
36
+ # Using pip
37
+ pip install python-lsp-mcp
38
+ ```
39
+
40
+ ### From Source
41
+
42
+ ```bash
43
+ cd python
44
+ uv sync
45
+ uv run python-lsp-mcp
46
+ ```
47
+
48
+ ## Usage
49
+
50
+ ### Run the server
51
+
52
+ ```bash
53
+ # With uvx (recommended)
54
+ uvx python-lsp-mcp@latest
55
+
56
+ # With pip install
57
+ python-lsp-mcp
58
+
59
+ # From source
60
+ uv run python-lsp-mcp
61
+ ```
62
+
63
+ ### Configure in Claude Code
64
+
65
+ Add to your `.mcp.json` or MCP settings:
66
+
67
+ ```json
68
+ {
69
+ "mcpServers": {
70
+ "python-lsp-mcp": {
71
+ "command": "uvx",
72
+ "args": ["python-lsp-mcp@latest"]
73
+ }
74
+ }
75
+ }
76
+ ```
77
+
78
+ Or if installed from source:
79
+
80
+ ```json
81
+ {
82
+ "mcpServers": {
83
+ "python-lsp-mcp": {
84
+ "command": "uv",
85
+ "args": ["run", "--directory", "/path/to/PyLspMcp/python", "python-lsp-mcp"]
86
+ }
87
+ }
88
+ }
89
+ ```
90
+
91
+ ### MCP Inspector
92
+
93
+ ```bash
94
+ uvx mcp dev python-lsp-mcp
95
+ ```
96
+
97
+ ## Configuration
98
+
99
+ ### Backend Selection
100
+
101
+ The server supports two backends for shared tools (hover, definition, references, completions, symbols):
102
+
103
+ | Backend | Strengths | Use Case |
104
+ |---------|-----------|----------|
105
+ | **rope** (default) | Fast, low latency, good refactoring | Quick operations, CI/CD |
106
+ | **pyright** | Accurate types, cross-file analysis | Type-heavy projects |
107
+
108
+ ### Runtime Switching
109
+
110
+ Use the `set_backend` tool to switch backends at runtime:
111
+
112
+ ```python
113
+ # Switch all shared tools to pyright
114
+ set_backend(backend="pyright")
115
+
116
+ # Switch only hover to rope
117
+ set_backend(backend="rope", tool="hover")
118
+
119
+ # Check current configuration
120
+ status()
121
+ ```
122
+
123
+ ### Environment Variables
124
+
125
+ Configure backends at startup via environment variables (supports both prefixes):
126
+
127
+ | Variable | Description | Default |
128
+ |----------|-------------|---------|
129
+ | `PYTHON_LSP_MCP_BACKEND` | Default backend (`rope` or `pyright`) | `rope` |
130
+ | `PYTHON_LSP_MCP_HOVER_BACKEND` | Backend for hover | inherited |
131
+ | `PYTHON_LSP_MCP_DEFINITION_BACKEND` | Backend for definition | inherited |
132
+ | `PYTHON_LSP_MCP_REFERENCES_BACKEND` | Backend for references | inherited |
133
+ | `PYTHON_LSP_MCP_COMPLETIONS_BACKEND` | Backend for completions | inherited |
134
+ | `PYTHON_LSP_MCP_SYMBOLS_BACKEND` | Backend for symbols | inherited |
135
+ | `PYTHON_LSP_MCP_NO_CACHE` | Disable Rope caching (`1` or `true`) | `false` |
136
+
137
+ > Note: `ROPE_MCP_*` prefix is also supported for backward compatibility.
138
+
139
+ ### Rope Caching
140
+
141
+ By default, Rope creates a `.ropeproject` folder in each analyzed project to cache analysis results. This significantly improves performance for medium to large projects.
142
+
143
+ - **Cache location**: `.ropeproject/` in each project root (project-isolated)
144
+ - **Cache contents**: Module info, object database, refactoring history
145
+ - **Disable caching**: Set `PYTHON_LSP_MCP_NO_CACHE=1`
146
+
147
+ You may want to add `.ropeproject/` to your `.gitignore`.
148
+
149
+ Example:
150
+ ```bash
151
+ # Use pyright for all shared tools
152
+ PYTHON_LSP_MCP_BACKEND=pyright uvx python-lsp-mcp@latest
153
+
154
+ # Use pyright for hover only
155
+ PYTHON_LSP_MCP_HOVER_BACKEND=pyright uvx python-lsp-mcp@latest
156
+ ```
157
+
158
+ ## Development
159
+
160
+ ### Run tests
161
+
162
+ ```bash
163
+ uv run pytest tests/ -v
164
+ ```
165
+
166
+ ### Run benchmarks
167
+
168
+ ```bash
169
+ uv run pytest tests/test_benchmark.py -v -s
170
+ ```
171
+
172
+ ## Architecture
173
+
174
+ ```
175
+ ┌─────────────────┐ stdio ┌─────────────────────┐
176
+ │ Claude / AI │ ◄────────────► │ python-lsp-mcp │
177
+ │ │ MCP │ │
178
+ └─────────────────┘ └─────────┬───────────┘
179
+
180
+ ┌─────────────────┼─────────────────┐
181
+ │ │ │
182
+ ▼ ▼ ▼
183
+ ┌───────────┐ ┌───────────┐ ┌───────────┐
184
+ │ Rope │ │ Pyright │ │ Pyright │
185
+ │ Library │ │ CLI │ │ LSP │
186
+ └───────────┘ └───────────┘ └───────────┘
187
+ ```
188
+
189
+ ## Project Structure
190
+
191
+ ```
192
+ python/
193
+ ├── pyproject.toml
194
+ ├── src/rope_mcp/
195
+ │ ├── server.py # MCP server entry point
196
+ │ ├── rope_client.py # Rope library wrapper
197
+ │ ├── pyright_client.py # Pyright CLI wrapper
198
+ │ ├── config.py # Backend configuration
199
+ │ ├── lsp/ # LSP client for Pyright
200
+ │ │ ├── client.py
201
+ │ │ └── types.py
202
+ │ └── tools/ # Tool implementations
203
+ │ ├── hover.py
204
+ │ ├── definition.py
205
+ │ ├── references.py
206
+ │ ├── completions.py
207
+ │ ├── symbols.py
208
+ │ ├── rename.py
209
+ │ └── diagnostics.py
210
+ └── tests/
211
+ ├── test_tools.py
212
+ └── test_benchmark.py
213
+ ```
214
+
215
+ ## Performance
216
+
217
+ Rope is significantly faster than Pyright LSP for basic operations:
218
+
219
+ | Tool | Rope (ms) | Pyright (ms) | Speedup |
220
+ |------|-----------|--------------|---------|
221
+ | hover | 0.16 | 0.79 | 4.9x |
222
+ | definition | 0.12 | 0.40 | 3.3x |
223
+ | completions | 0.36 | 1.52 | 4.2x |
224
+ | symbols | 0.24 | 0.44 | 1.8x |
225
+
226
+ See [docs/BENCHMARKS.md](../docs/BENCHMARKS.md) for detailed benchmarks.
227
+
228
+ ## License
229
+
230
+ MIT
@@ -0,0 +1,61 @@
1
+ [project]
2
+ name = "python-lsp-mcp"
3
+ version = "0.3.1"
4
+ description = "MCP server providing Python code analysis using Rope and Pyright"
5
+ readme = "README.md"
6
+ license = "MIT"
7
+ requires-python = ">=3.10"
8
+ authors = [{ name = "treedy" }]
9
+ keywords = [
10
+ "mcp",
11
+ "rope",
12
+ "pyright",
13
+ "python",
14
+ "lsp",
15
+ "code-intelligence",
16
+ "claude",
17
+ "ai",
18
+ "refactoring",
19
+ "type-checking",
20
+ ]
21
+ classifiers = [
22
+ "Development Status :: 4 - Beta",
23
+ "Intended Audience :: Developers",
24
+ "License :: OSI Approved :: MIT License",
25
+ "Programming Language :: Python :: 3",
26
+ "Programming Language :: Python :: 3.10",
27
+ "Programming Language :: Python :: 3.11",
28
+ "Programming Language :: Python :: 3.12",
29
+ "Programming Language :: Python :: 3.13",
30
+ "Topic :: Software Development :: Libraries :: Python Modules",
31
+ "Topic :: Text Editors :: Integrated Development Environments (IDE)",
32
+ ]
33
+ dependencies = [
34
+ "mcp>=1.0.0",
35
+ "rope>=1.13.0",
36
+ "tomli>=2.0.0; python_version < '3.11'",
37
+ ]
38
+
39
+ [project.optional-dependencies]
40
+ dev = ["watchdog>=4.0.0", "pytest>=8.0.0", "ruff>=0.4.0"]
41
+
42
+ [project.urls]
43
+ Homepage = "https://github.com/pinylin/pyright-mcp"
44
+ Repository = "https://github.com/pinylin/pyright-mcp"
45
+ Documentation = "https://github.com/pinylin/pyright-mcp#readme"
46
+
47
+ [project.scripts]
48
+ python-lsp-mcp = "rope_mcp.server:main"
49
+
50
+ [build-system]
51
+ requires = ["hatchling"]
52
+ build-backend = "hatchling.build"
53
+
54
+ [tool.hatch.build.targets.wheel]
55
+ packages = ["src/rope_mcp"]
56
+
57
+ [tool.pytest.ini_options]
58
+ testpaths = ["tests"]
59
+
60
+ [dependency-groups]
61
+ dev = ["pytest>=9.0.2"]
@@ -0,0 +1,3 @@
1
+ """Rope MCP Server - Python code analysis via MCP."""
2
+
3
+ __version__ = "0.1.0"