code-index-mcp 0.1.0__tar.gz
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.
- code_index_mcp-0.1.0/LICENSE +21 -0
- code_index_mcp-0.1.0/PKG-INFO +321 -0
- code_index_mcp-0.1.0/README.md +307 -0
- code_index_mcp-0.1.0/pyproject.toml +27 -0
- code_index_mcp-0.1.0/setup.cfg +4 -0
- code_index_mcp-0.1.0/src/code_index_mcp/__init__.py +6 -0
- code_index_mcp-0.1.0/src/code_index_mcp/__main__.py +6 -0
- code_index_mcp-0.1.0/src/code_index_mcp/project_settings.py +521 -0
- code_index_mcp-0.1.0/src/code_index_mcp/server.py +802 -0
- code_index_mcp-0.1.0/src/code_index_mcp.egg-info/PKG-INFO +321 -0
- code_index_mcp-0.1.0/src/code_index_mcp.egg-info/SOURCES.txt +13 -0
- code_index_mcp-0.1.0/src/code_index_mcp.egg-info/dependency_links.txt +1 -0
- code_index_mcp-0.1.0/src/code_index_mcp.egg-info/entry_points.txt +2 -0
- code_index_mcp-0.1.0/src/code_index_mcp.egg-info/requires.txt +1 -0
- code_index_mcp-0.1.0/src/code_index_mcp.egg-info/top_level.txt +1 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2015 johnhuang316
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,321 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: code-index-mcp
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Code indexing and analysis tools for LLMs using MCP
|
|
5
|
+
Author: johnhuang316
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/johnhuang316/code-index-mcp
|
|
8
|
+
Project-URL: Bug Tracker, https://github.com/johnhuang316/code-index-mcp/issues
|
|
9
|
+
Requires-Python: >=3.10
|
|
10
|
+
Description-Content-Type: text/markdown
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Requires-Dist: mcp>=0.3.0
|
|
13
|
+
Dynamic: license-file
|
|
14
|
+
|
|
15
|
+
# Code Index MCP
|
|
16
|
+
|
|
17
|
+
Code Index MCP is a Model Context Protocol server that enables large language models (LLMs) to index, search, and analyze code in project directories.
|
|
18
|
+
|
|
19
|
+
## Features
|
|
20
|
+
|
|
21
|
+
- Index and navigate project file structures
|
|
22
|
+
- Search for specific patterns in code
|
|
23
|
+
- Get detailed file summaries
|
|
24
|
+
- Analyze code structure and complexity
|
|
25
|
+
- Support for multiple programming languages
|
|
26
|
+
- Persistent storage of project settings
|
|
27
|
+
|
|
28
|
+
## Installation
|
|
29
|
+
|
|
30
|
+
This project uses the following tools:
|
|
31
|
+
|
|
32
|
+
1. **uv**: A fast Python package manager for dependency installation (recommended but optional)
|
|
33
|
+
2. **code-indexer** or **uvx**: Command-line entry points provided by this package to run the Code Index MCP server
|
|
34
|
+
|
|
35
|
+
> **Note about `uvx`**: Our `uvx` command is a custom entry point defined in this package, and is not related to the `uvx` command from the uv package manager (which is an alias for `uv tool run`). If you have both installed, you can use the full path to our `uvx` command or use the `code-indexer` command instead to avoid conflicts.
|
|
36
|
+
|
|
37
|
+
### Installation Steps
|
|
38
|
+
|
|
39
|
+
1. Ensure you have Python 3.10 or later installed
|
|
40
|
+
|
|
41
|
+
2. Install uv (recommended but not required):
|
|
42
|
+
```bash
|
|
43
|
+
# Windows
|
|
44
|
+
powershell -c "irm https://astral.sh/uv/install.ps1 | iex"
|
|
45
|
+
# macOS/Linux
|
|
46
|
+
curl -LsSf https://astral.sh/uv/install.sh | sh
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
3. Install the code-index-mcp package to get the command-line tools:
|
|
50
|
+
```bash
|
|
51
|
+
# Using uv (recommended)
|
|
52
|
+
uv pip install code-index-mcp
|
|
53
|
+
|
|
54
|
+
# Or using traditional pip
|
|
55
|
+
pip install code-index-mcp
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
4. After installation, you can use either the `code-indexer` or `uvx` command (both do the same thing):
|
|
59
|
+
```bash
|
|
60
|
+
# Using code-indexer
|
|
61
|
+
code-indexer /path/to/your/project
|
|
62
|
+
|
|
63
|
+
# Or using uvx
|
|
64
|
+
uvx /path/to/your/project
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
Note: Both commands are entry points defined in this package that run the same code. If you have the uv package manager installed, be aware that it also has a command called `uvx` (which is an alias for `uv tool run`). To avoid conflicts, you can:
|
|
68
|
+
|
|
69
|
+
- Use the full path to our `uvx` command
|
|
70
|
+
- Use the `code-indexer` command instead
|
|
71
|
+
- Create an alias in your shell for our `uvx` command
|
|
72
|
+
|
|
73
|
+
### Installing from Source
|
|
74
|
+
|
|
75
|
+
If you want to install from source code:
|
|
76
|
+
|
|
77
|
+
1. Clone the repository:
|
|
78
|
+
```bash
|
|
79
|
+
git clone https://github.com/johnhuang316/code-index-mcp.git
|
|
80
|
+
cd code-index-mcp
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
2. Install the package (this will also install the command-line tools):
|
|
84
|
+
```bash
|
|
85
|
+
# Using uv (recommended)
|
|
86
|
+
uv pip install -e .
|
|
87
|
+
|
|
88
|
+
# Or using traditional pip
|
|
89
|
+
pip install -e .
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
This will make both the `code-indexer` and `uvx` commands available in your environment.
|
|
93
|
+
|
|
94
|
+
## Usage
|
|
95
|
+
|
|
96
|
+
### Running the Server Directly
|
|
97
|
+
|
|
98
|
+
There are multiple ways to run the server:
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
# Using the code-indexer command (requires installing the package first)
|
|
102
|
+
code-indexer
|
|
103
|
+
|
|
104
|
+
# Or using the uvx command (requires installing the package first)
|
|
105
|
+
uvx
|
|
106
|
+
|
|
107
|
+
# Using uv to run the script directly (doesn't require installing the package)
|
|
108
|
+
uv run run.py
|
|
109
|
+
|
|
110
|
+
# Using Python directly (doesn't require installing the package)
|
|
111
|
+
python -m code_index_mcp.server
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
Note: When run without arguments, both `code-indexer` and `uvx` will start the server without setting a project path. You'll need to set the project path using the `set_project_path` tool after connecting.
|
|
115
|
+
|
|
116
|
+
> **Important**: If you have the uv package manager installed, be aware that it also provides a command called `uvx` (which is an alias for `uv tool run`). To avoid command conflicts, you can use the full path to our `uvx` command, use `code-indexer` instead, or create a shell alias.
|
|
117
|
+
|
|
118
|
+
UV will automatically handle all dependency installations based on the project's configuration.
|
|
119
|
+
|
|
120
|
+
### Using Docker
|
|
121
|
+
|
|
122
|
+
You can also use Code Index MCP as a containerized tool with Docker:
|
|
123
|
+
|
|
124
|
+
```bash
|
|
125
|
+
# Build the Docker image
|
|
126
|
+
docker build -t code-index-mcp .
|
|
127
|
+
|
|
128
|
+
# Use the container as a tool to analyze your code
|
|
129
|
+
docker run --rm -i code-index-mcp
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
This containerized approach works well with Claude Desktop, which treats MCP servers as on-demand processes rather than persistent servers. Claude Desktop will start the container when needed and communicate with it via stdio, keeping it running only for the duration of the session.
|
|
133
|
+
|
|
134
|
+
When using the containerized version, you'll need to set the project path explicitly using the `set_project_path` tool, just like in the non-containerized version.
|
|
135
|
+
|
|
136
|
+
### Integrating with Claude Desktop
|
|
137
|
+
|
|
138
|
+
You can easily integrate Code Index MCP with Claude Desktop:
|
|
139
|
+
|
|
140
|
+
#### Prerequisites
|
|
141
|
+
|
|
142
|
+
1. Make sure you have completed the appropriate installation steps above
|
|
143
|
+
2. Verify that the command you plan to use is available:
|
|
144
|
+
- For Option 1: Verify `uvx` is available by running `uvx --help` in your terminal
|
|
145
|
+
- For Option 2: Make sure you have the source code repository
|
|
146
|
+
- For Option 3: Ensure Docker is installed and the image is built
|
|
147
|
+
|
|
148
|
+
#### Configuration Steps
|
|
149
|
+
|
|
150
|
+
1. Find or create the Claude Desktop configuration file:
|
|
151
|
+
- Windows: `%APPDATA%\Claude\claude_desktop_config.json`
|
|
152
|
+
- macOS/Linux: `~/Library/Application Support/Claude/claude_desktop_config.json`
|
|
153
|
+
|
|
154
|
+
2. Add the appropriate configuration based on your preferred method:
|
|
155
|
+
|
|
156
|
+
#### Option 1: Using command-line tools (Recommended, requires package installation)
|
|
157
|
+
|
|
158
|
+
**For Windows**:
|
|
159
|
+
|
|
160
|
+
```json
|
|
161
|
+
{
|
|
162
|
+
"mcpServers": {
|
|
163
|
+
"code-indexer": {
|
|
164
|
+
"command": "code-indexer",
|
|
165
|
+
"args": [
|
|
166
|
+
"C:\\Users\\username\\path\\to\\project"
|
|
167
|
+
]
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
**For macOS/Linux**:
|
|
174
|
+
|
|
175
|
+
```json
|
|
176
|
+
{
|
|
177
|
+
"mcpServers": {
|
|
178
|
+
"code-indexer": {
|
|
179
|
+
"command": "code-indexer",
|
|
180
|
+
"args": [
|
|
181
|
+
"/Users/username/path/to/project"
|
|
182
|
+
]
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
**Note**: You can also use `uvx` instead of `code-indexer` as the command - both are entry points defined in this package that do the same thing. These commands are available after installing the package with `pip install code-index-mcp` or `uv pip install code-index-mcp`.
|
|
189
|
+
|
|
190
|
+
#### Option 2: Using Python directly (No package installation required)
|
|
191
|
+
|
|
192
|
+
```json
|
|
193
|
+
{
|
|
194
|
+
"mcpServers": {
|
|
195
|
+
"code-indexer": {
|
|
196
|
+
"command": "python",
|
|
197
|
+
"args": [
|
|
198
|
+
"-m",
|
|
199
|
+
"code_index_mcp.server"
|
|
200
|
+
],
|
|
201
|
+
"cwd": "C:\\path\\to\\code-index-mcp"
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
**Note**: This option requires specifying the full path to the source code repository in the `cwd` parameter.
|
|
208
|
+
|
|
209
|
+
#### Option 3: Using Docker (Containerized)
|
|
210
|
+
|
|
211
|
+
1. Build the Docker image as described in the Docker section above
|
|
212
|
+
2. Find or create the Claude Desktop configuration file (same locations as above)
|
|
213
|
+
3. Add the following configuration:
|
|
214
|
+
|
|
215
|
+
```json
|
|
216
|
+
{
|
|
217
|
+
"mcpServers": {
|
|
218
|
+
"code-indexer": {
|
|
219
|
+
"command": "docker",
|
|
220
|
+
"args": [
|
|
221
|
+
"run",
|
|
222
|
+
"-i",
|
|
223
|
+
"--rm",
|
|
224
|
+
"code-index-mcp"
|
|
225
|
+
]
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
**Note**: This configuration allows Claude Desktop to start the containerized MCP tool on demand.
|
|
232
|
+
|
|
233
|
+
4. Restart Claude Desktop to use Code Indexer for analyzing code projects
|
|
234
|
+
|
|
235
|
+
Claude Desktop will start the MCP server as an on-demand process when needed, communicate with it via stdio, and keep it running only for the duration of your session.
|
|
236
|
+
|
|
237
|
+
### Basic Workflow
|
|
238
|
+
|
|
239
|
+
1. **Set Project Path** (required first step):
|
|
240
|
+
|
|
241
|
+
- When using for the first time, you must set the project path to analyze
|
|
242
|
+
- Through Claude command: "I need to analyze a project, help me set up the project path"
|
|
243
|
+
- Provide the complete project directory path
|
|
244
|
+
2. **Code Search**:
|
|
245
|
+
|
|
246
|
+
- Search for specific keywords or patterns: "Search for 'function name' in the project"
|
|
247
|
+
- Filter by file type: "Search for 'import' in all .py files"
|
|
248
|
+
3. **File Analysis**:
|
|
249
|
+
|
|
250
|
+
- Analyze specific files: "Analyze the file src/main.py"
|
|
251
|
+
- Get file summaries: "Give me a list of functions in utils/helpers.js"
|
|
252
|
+
3. **Project Navigation**:
|
|
253
|
+
|
|
254
|
+
- View project structure: "Show me the structure of this project"
|
|
255
|
+
- Find files matching specific patterns: "Find all test_*.py files"
|
|
256
|
+
|
|
257
|
+
## Technical Details
|
|
258
|
+
|
|
259
|
+
### Persistent Storage
|
|
260
|
+
|
|
261
|
+
All index and settings data are stored in the system temporary directory, in a subfolder specific to each project:
|
|
262
|
+
|
|
263
|
+
- Windows: `%TEMP%\code_indexer\[project_hash]\`
|
|
264
|
+
- Linux/macOS: `/tmp/code_indexer/[project_hash]/`
|
|
265
|
+
|
|
266
|
+
Each project's data includes:
|
|
267
|
+
- `config.json`: Project configuration information
|
|
268
|
+
- `file_index.pickle`: File index data
|
|
269
|
+
- `content_cache.pickle`: File content cache
|
|
270
|
+
|
|
271
|
+
This approach ensures that:
|
|
272
|
+
1. Different projects' data are kept separate
|
|
273
|
+
2. The data is automatically cleaned up by the OS when no longer needed
|
|
274
|
+
3. In containerized environments, the data is stored in the container's temporary directory
|
|
275
|
+
|
|
276
|
+
### Dependency Management with UV
|
|
277
|
+
|
|
278
|
+
Code Index MCP uses UV for dependency management, which provides several advantages:
|
|
279
|
+
|
|
280
|
+
- Automatic dependency resolution based on project requirements
|
|
281
|
+
- Faster package installation and environment setup
|
|
282
|
+
- Consistent dependency versions via the lock file
|
|
283
|
+
|
|
284
|
+
### Supported File Types
|
|
285
|
+
|
|
286
|
+
The following file types are currently supported for indexing and analysis:
|
|
287
|
+
|
|
288
|
+
- Python (.py)
|
|
289
|
+
- JavaScript/TypeScript (.js, .ts, .jsx, .tsx)
|
|
290
|
+
- Java (.java)
|
|
291
|
+
- C/C++ (.c, .cpp, .h, .hpp)
|
|
292
|
+
- C# (.cs)
|
|
293
|
+
- Go (.go)
|
|
294
|
+
- Ruby (.rb)
|
|
295
|
+
- PHP (.php)
|
|
296
|
+
- Swift (.swift)
|
|
297
|
+
- Kotlin (.kt)
|
|
298
|
+
- Rust (.rs)
|
|
299
|
+
- Scala (.scala)
|
|
300
|
+
- Shell (.sh, .bash)
|
|
301
|
+
- HTML/CSS (.html, .css, .scss)
|
|
302
|
+
- Markdown (.md)
|
|
303
|
+
- JSON (.json)
|
|
304
|
+
- XML (.xml)
|
|
305
|
+
- YAML (.yml, .yaml)
|
|
306
|
+
|
|
307
|
+
## Security Considerations
|
|
308
|
+
|
|
309
|
+
- File path validation prevents directory traversal attacks
|
|
310
|
+
- Absolute path access is not allowed
|
|
311
|
+
- Project path must be explicitly set, with no default value
|
|
312
|
+
- Index data is stored in the system temporary directory, not in the project directory
|
|
313
|
+
- Each project's data is stored in a separate directory based on the project path's hash
|
|
314
|
+
|
|
315
|
+
## Contributing
|
|
316
|
+
|
|
317
|
+
Contributions via issues or pull requests to add new features or fix bugs are welcome.
|
|
318
|
+
|
|
319
|
+
---
|
|
320
|
+
|
|
321
|
+
*For documentation in Chinese, please see [README_zh.md](README_zh.md).*
|
|
@@ -0,0 +1,307 @@
|
|
|
1
|
+
# Code Index MCP
|
|
2
|
+
|
|
3
|
+
Code Index MCP is a Model Context Protocol server that enables large language models (LLMs) to index, search, and analyze code in project directories.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- Index and navigate project file structures
|
|
8
|
+
- Search for specific patterns in code
|
|
9
|
+
- Get detailed file summaries
|
|
10
|
+
- Analyze code structure and complexity
|
|
11
|
+
- Support for multiple programming languages
|
|
12
|
+
- Persistent storage of project settings
|
|
13
|
+
|
|
14
|
+
## Installation
|
|
15
|
+
|
|
16
|
+
This project uses the following tools:
|
|
17
|
+
|
|
18
|
+
1. **uv**: A fast Python package manager for dependency installation (recommended but optional)
|
|
19
|
+
2. **code-indexer** or **uvx**: Command-line entry points provided by this package to run the Code Index MCP server
|
|
20
|
+
|
|
21
|
+
> **Note about `uvx`**: Our `uvx` command is a custom entry point defined in this package, and is not related to the `uvx` command from the uv package manager (which is an alias for `uv tool run`). If you have both installed, you can use the full path to our `uvx` command or use the `code-indexer` command instead to avoid conflicts.
|
|
22
|
+
|
|
23
|
+
### Installation Steps
|
|
24
|
+
|
|
25
|
+
1. Ensure you have Python 3.10 or later installed
|
|
26
|
+
|
|
27
|
+
2. Install uv (recommended but not required):
|
|
28
|
+
```bash
|
|
29
|
+
# Windows
|
|
30
|
+
powershell -c "irm https://astral.sh/uv/install.ps1 | iex"
|
|
31
|
+
# macOS/Linux
|
|
32
|
+
curl -LsSf https://astral.sh/uv/install.sh | sh
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
3. Install the code-index-mcp package to get the command-line tools:
|
|
36
|
+
```bash
|
|
37
|
+
# Using uv (recommended)
|
|
38
|
+
uv pip install code-index-mcp
|
|
39
|
+
|
|
40
|
+
# Or using traditional pip
|
|
41
|
+
pip install code-index-mcp
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
4. After installation, you can use either the `code-indexer` or `uvx` command (both do the same thing):
|
|
45
|
+
```bash
|
|
46
|
+
# Using code-indexer
|
|
47
|
+
code-indexer /path/to/your/project
|
|
48
|
+
|
|
49
|
+
# Or using uvx
|
|
50
|
+
uvx /path/to/your/project
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Note: Both commands are entry points defined in this package that run the same code. If you have the uv package manager installed, be aware that it also has a command called `uvx` (which is an alias for `uv tool run`). To avoid conflicts, you can:
|
|
54
|
+
|
|
55
|
+
- Use the full path to our `uvx` command
|
|
56
|
+
- Use the `code-indexer` command instead
|
|
57
|
+
- Create an alias in your shell for our `uvx` command
|
|
58
|
+
|
|
59
|
+
### Installing from Source
|
|
60
|
+
|
|
61
|
+
If you want to install from source code:
|
|
62
|
+
|
|
63
|
+
1. Clone the repository:
|
|
64
|
+
```bash
|
|
65
|
+
git clone https://github.com/johnhuang316/code-index-mcp.git
|
|
66
|
+
cd code-index-mcp
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
2. Install the package (this will also install the command-line tools):
|
|
70
|
+
```bash
|
|
71
|
+
# Using uv (recommended)
|
|
72
|
+
uv pip install -e .
|
|
73
|
+
|
|
74
|
+
# Or using traditional pip
|
|
75
|
+
pip install -e .
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
This will make both the `code-indexer` and `uvx` commands available in your environment.
|
|
79
|
+
|
|
80
|
+
## Usage
|
|
81
|
+
|
|
82
|
+
### Running the Server Directly
|
|
83
|
+
|
|
84
|
+
There are multiple ways to run the server:
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
# Using the code-indexer command (requires installing the package first)
|
|
88
|
+
code-indexer
|
|
89
|
+
|
|
90
|
+
# Or using the uvx command (requires installing the package first)
|
|
91
|
+
uvx
|
|
92
|
+
|
|
93
|
+
# Using uv to run the script directly (doesn't require installing the package)
|
|
94
|
+
uv run run.py
|
|
95
|
+
|
|
96
|
+
# Using Python directly (doesn't require installing the package)
|
|
97
|
+
python -m code_index_mcp.server
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
Note: When run without arguments, both `code-indexer` and `uvx` will start the server without setting a project path. You'll need to set the project path using the `set_project_path` tool after connecting.
|
|
101
|
+
|
|
102
|
+
> **Important**: If you have the uv package manager installed, be aware that it also provides a command called `uvx` (which is an alias for `uv tool run`). To avoid command conflicts, you can use the full path to our `uvx` command, use `code-indexer` instead, or create a shell alias.
|
|
103
|
+
|
|
104
|
+
UV will automatically handle all dependency installations based on the project's configuration.
|
|
105
|
+
|
|
106
|
+
### Using Docker
|
|
107
|
+
|
|
108
|
+
You can also use Code Index MCP as a containerized tool with Docker:
|
|
109
|
+
|
|
110
|
+
```bash
|
|
111
|
+
# Build the Docker image
|
|
112
|
+
docker build -t code-index-mcp .
|
|
113
|
+
|
|
114
|
+
# Use the container as a tool to analyze your code
|
|
115
|
+
docker run --rm -i code-index-mcp
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
This containerized approach works well with Claude Desktop, which treats MCP servers as on-demand processes rather than persistent servers. Claude Desktop will start the container when needed and communicate with it via stdio, keeping it running only for the duration of the session.
|
|
119
|
+
|
|
120
|
+
When using the containerized version, you'll need to set the project path explicitly using the `set_project_path` tool, just like in the non-containerized version.
|
|
121
|
+
|
|
122
|
+
### Integrating with Claude Desktop
|
|
123
|
+
|
|
124
|
+
You can easily integrate Code Index MCP with Claude Desktop:
|
|
125
|
+
|
|
126
|
+
#### Prerequisites
|
|
127
|
+
|
|
128
|
+
1. Make sure you have completed the appropriate installation steps above
|
|
129
|
+
2. Verify that the command you plan to use is available:
|
|
130
|
+
- For Option 1: Verify `uvx` is available by running `uvx --help` in your terminal
|
|
131
|
+
- For Option 2: Make sure you have the source code repository
|
|
132
|
+
- For Option 3: Ensure Docker is installed and the image is built
|
|
133
|
+
|
|
134
|
+
#### Configuration Steps
|
|
135
|
+
|
|
136
|
+
1. Find or create the Claude Desktop configuration file:
|
|
137
|
+
- Windows: `%APPDATA%\Claude\claude_desktop_config.json`
|
|
138
|
+
- macOS/Linux: `~/Library/Application Support/Claude/claude_desktop_config.json`
|
|
139
|
+
|
|
140
|
+
2. Add the appropriate configuration based on your preferred method:
|
|
141
|
+
|
|
142
|
+
#### Option 1: Using command-line tools (Recommended, requires package installation)
|
|
143
|
+
|
|
144
|
+
**For Windows**:
|
|
145
|
+
|
|
146
|
+
```json
|
|
147
|
+
{
|
|
148
|
+
"mcpServers": {
|
|
149
|
+
"code-indexer": {
|
|
150
|
+
"command": "code-indexer",
|
|
151
|
+
"args": [
|
|
152
|
+
"C:\\Users\\username\\path\\to\\project"
|
|
153
|
+
]
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
**For macOS/Linux**:
|
|
160
|
+
|
|
161
|
+
```json
|
|
162
|
+
{
|
|
163
|
+
"mcpServers": {
|
|
164
|
+
"code-indexer": {
|
|
165
|
+
"command": "code-indexer",
|
|
166
|
+
"args": [
|
|
167
|
+
"/Users/username/path/to/project"
|
|
168
|
+
]
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
**Note**: You can also use `uvx` instead of `code-indexer` as the command - both are entry points defined in this package that do the same thing. These commands are available after installing the package with `pip install code-index-mcp` or `uv pip install code-index-mcp`.
|
|
175
|
+
|
|
176
|
+
#### Option 2: Using Python directly (No package installation required)
|
|
177
|
+
|
|
178
|
+
```json
|
|
179
|
+
{
|
|
180
|
+
"mcpServers": {
|
|
181
|
+
"code-indexer": {
|
|
182
|
+
"command": "python",
|
|
183
|
+
"args": [
|
|
184
|
+
"-m",
|
|
185
|
+
"code_index_mcp.server"
|
|
186
|
+
],
|
|
187
|
+
"cwd": "C:\\path\\to\\code-index-mcp"
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
**Note**: This option requires specifying the full path to the source code repository in the `cwd` parameter.
|
|
194
|
+
|
|
195
|
+
#### Option 3: Using Docker (Containerized)
|
|
196
|
+
|
|
197
|
+
1. Build the Docker image as described in the Docker section above
|
|
198
|
+
2. Find or create the Claude Desktop configuration file (same locations as above)
|
|
199
|
+
3. Add the following configuration:
|
|
200
|
+
|
|
201
|
+
```json
|
|
202
|
+
{
|
|
203
|
+
"mcpServers": {
|
|
204
|
+
"code-indexer": {
|
|
205
|
+
"command": "docker",
|
|
206
|
+
"args": [
|
|
207
|
+
"run",
|
|
208
|
+
"-i",
|
|
209
|
+
"--rm",
|
|
210
|
+
"code-index-mcp"
|
|
211
|
+
]
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
**Note**: This configuration allows Claude Desktop to start the containerized MCP tool on demand.
|
|
218
|
+
|
|
219
|
+
4. Restart Claude Desktop to use Code Indexer for analyzing code projects
|
|
220
|
+
|
|
221
|
+
Claude Desktop will start the MCP server as an on-demand process when needed, communicate with it via stdio, and keep it running only for the duration of your session.
|
|
222
|
+
|
|
223
|
+
### Basic Workflow
|
|
224
|
+
|
|
225
|
+
1. **Set Project Path** (required first step):
|
|
226
|
+
|
|
227
|
+
- When using for the first time, you must set the project path to analyze
|
|
228
|
+
- Through Claude command: "I need to analyze a project, help me set up the project path"
|
|
229
|
+
- Provide the complete project directory path
|
|
230
|
+
2. **Code Search**:
|
|
231
|
+
|
|
232
|
+
- Search for specific keywords or patterns: "Search for 'function name' in the project"
|
|
233
|
+
- Filter by file type: "Search for 'import' in all .py files"
|
|
234
|
+
3. **File Analysis**:
|
|
235
|
+
|
|
236
|
+
- Analyze specific files: "Analyze the file src/main.py"
|
|
237
|
+
- Get file summaries: "Give me a list of functions in utils/helpers.js"
|
|
238
|
+
3. **Project Navigation**:
|
|
239
|
+
|
|
240
|
+
- View project structure: "Show me the structure of this project"
|
|
241
|
+
- Find files matching specific patterns: "Find all test_*.py files"
|
|
242
|
+
|
|
243
|
+
## Technical Details
|
|
244
|
+
|
|
245
|
+
### Persistent Storage
|
|
246
|
+
|
|
247
|
+
All index and settings data are stored in the system temporary directory, in a subfolder specific to each project:
|
|
248
|
+
|
|
249
|
+
- Windows: `%TEMP%\code_indexer\[project_hash]\`
|
|
250
|
+
- Linux/macOS: `/tmp/code_indexer/[project_hash]/`
|
|
251
|
+
|
|
252
|
+
Each project's data includes:
|
|
253
|
+
- `config.json`: Project configuration information
|
|
254
|
+
- `file_index.pickle`: File index data
|
|
255
|
+
- `content_cache.pickle`: File content cache
|
|
256
|
+
|
|
257
|
+
This approach ensures that:
|
|
258
|
+
1. Different projects' data are kept separate
|
|
259
|
+
2. The data is automatically cleaned up by the OS when no longer needed
|
|
260
|
+
3. In containerized environments, the data is stored in the container's temporary directory
|
|
261
|
+
|
|
262
|
+
### Dependency Management with UV
|
|
263
|
+
|
|
264
|
+
Code Index MCP uses UV for dependency management, which provides several advantages:
|
|
265
|
+
|
|
266
|
+
- Automatic dependency resolution based on project requirements
|
|
267
|
+
- Faster package installation and environment setup
|
|
268
|
+
- Consistent dependency versions via the lock file
|
|
269
|
+
|
|
270
|
+
### Supported File Types
|
|
271
|
+
|
|
272
|
+
The following file types are currently supported for indexing and analysis:
|
|
273
|
+
|
|
274
|
+
- Python (.py)
|
|
275
|
+
- JavaScript/TypeScript (.js, .ts, .jsx, .tsx)
|
|
276
|
+
- Java (.java)
|
|
277
|
+
- C/C++ (.c, .cpp, .h, .hpp)
|
|
278
|
+
- C# (.cs)
|
|
279
|
+
- Go (.go)
|
|
280
|
+
- Ruby (.rb)
|
|
281
|
+
- PHP (.php)
|
|
282
|
+
- Swift (.swift)
|
|
283
|
+
- Kotlin (.kt)
|
|
284
|
+
- Rust (.rs)
|
|
285
|
+
- Scala (.scala)
|
|
286
|
+
- Shell (.sh, .bash)
|
|
287
|
+
- HTML/CSS (.html, .css, .scss)
|
|
288
|
+
- Markdown (.md)
|
|
289
|
+
- JSON (.json)
|
|
290
|
+
- XML (.xml)
|
|
291
|
+
- YAML (.yml, .yaml)
|
|
292
|
+
|
|
293
|
+
## Security Considerations
|
|
294
|
+
|
|
295
|
+
- File path validation prevents directory traversal attacks
|
|
296
|
+
- Absolute path access is not allowed
|
|
297
|
+
- Project path must be explicitly set, with no default value
|
|
298
|
+
- Index data is stored in the system temporary directory, not in the project directory
|
|
299
|
+
- Each project's data is stored in a separate directory based on the project path's hash
|
|
300
|
+
|
|
301
|
+
## Contributing
|
|
302
|
+
|
|
303
|
+
Contributions via issues or pull requests to add new features or fix bugs are welcome.
|
|
304
|
+
|
|
305
|
+
---
|
|
306
|
+
|
|
307
|
+
*For documentation in Chinese, please see [README_zh.md](README_zh.md).*
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61.0"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "code-index-mcp"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Code indexing and analysis tools for LLMs using MCP"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.10"
|
|
11
|
+
license = {text = "MIT"}
|
|
12
|
+
authors = [
|
|
13
|
+
{name = "johnhuang316"}
|
|
14
|
+
]
|
|
15
|
+
dependencies = [
|
|
16
|
+
"mcp>=0.3.0",
|
|
17
|
+
]
|
|
18
|
+
|
|
19
|
+
[project.urls]
|
|
20
|
+
Homepage = "https://github.com/johnhuang316/code-index-mcp"
|
|
21
|
+
"Bug Tracker" = "https://github.com/johnhuang316/code-index-mcp/issues"
|
|
22
|
+
|
|
23
|
+
[project.scripts]
|
|
24
|
+
code-indexer = "code_index_mcp.server:main"
|
|
25
|
+
|
|
26
|
+
[tool.setuptools]
|
|
27
|
+
package-dir = {"" = "src"}
|