mcp-vector-search 0.4.13__py3-none-any.whl → 0.5.0__py3-none-any.whl
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.
Potentially problematic release.
This version of mcp-vector-search might be problematic. Click here for more details.
- mcp_vector_search/__init__.py +2 -2
- mcp_vector_search/cli/commands/index.py +73 -31
- mcp_vector_search/cli/commands/init.py +189 -113
- mcp_vector_search/cli/commands/install.py +525 -113
- mcp_vector_search/cli/commands/mcp.py +201 -151
- mcp_vector_search/cli/commands/reset.py +41 -41
- mcp_vector_search/cli/commands/search.py +73 -14
- mcp_vector_search/cli/commands/status.py +51 -17
- mcp_vector_search/cli/didyoumean.py +254 -246
- mcp_vector_search/cli/main.py +171 -52
- mcp_vector_search/cli/output.py +152 -0
- mcp_vector_search/cli/suggestions.py +246 -197
- mcp_vector_search/core/database.py +81 -49
- mcp_vector_search/core/indexer.py +10 -4
- mcp_vector_search/core/search.py +17 -6
- mcp_vector_search/mcp/__main__.py +1 -1
- mcp_vector_search/mcp/server.py +211 -203
- mcp_vector_search/parsers/__init__.py +6 -0
- mcp_vector_search/parsers/dart.py +605 -0
- mcp_vector_search/parsers/php.py +694 -0
- mcp_vector_search/parsers/registry.py +16 -1
- mcp_vector_search/parsers/ruby.py +678 -0
- mcp_vector_search/parsers/text.py +31 -25
- mcp_vector_search/utils/gitignore.py +72 -71
- {mcp_vector_search-0.4.13.dist-info → mcp_vector_search-0.5.0.dist-info}/METADATA +59 -2
- {mcp_vector_search-0.4.13.dist-info → mcp_vector_search-0.5.0.dist-info}/RECORD +29 -26
- {mcp_vector_search-0.4.13.dist-info → mcp_vector_search-0.5.0.dist-info}/WHEEL +0 -0
- {mcp_vector_search-0.4.13.dist-info → mcp_vector_search-0.5.0.dist-info}/entry_points.txt +0 -0
- {mcp_vector_search-0.4.13.dist-info → mcp_vector_search-0.5.0.dist-info}/licenses/LICENSE +0 -0
|
@@ -13,8 +13,11 @@ from ..output import (
|
|
|
13
13
|
console,
|
|
14
14
|
print_error,
|
|
15
15
|
print_info,
|
|
16
|
+
print_next_steps,
|
|
17
|
+
print_panel,
|
|
16
18
|
print_project_info,
|
|
17
19
|
print_success,
|
|
20
|
+
print_tip,
|
|
18
21
|
print_warning,
|
|
19
22
|
)
|
|
20
23
|
|
|
@@ -33,18 +36,21 @@ def main(
|
|
|
33
36
|
file_okay=True,
|
|
34
37
|
dir_okay=False,
|
|
35
38
|
readable=True,
|
|
39
|
+
rich_help_panel="📁 Configuration",
|
|
36
40
|
),
|
|
37
41
|
extensions: str | None = typer.Option(
|
|
38
42
|
None,
|
|
39
43
|
"--extensions",
|
|
40
44
|
"-e",
|
|
41
45
|
help="Comma-separated list of file extensions to index (e.g., '.py,.js,.ts,.txt,.md')",
|
|
46
|
+
rich_help_panel="📁 Configuration",
|
|
42
47
|
),
|
|
43
48
|
embedding_model: str = typer.Option(
|
|
44
49
|
DEFAULT_EMBEDDING_MODELS["code"],
|
|
45
50
|
"--embedding-model",
|
|
46
51
|
"-m",
|
|
47
52
|
help="Embedding model to use for semantic search",
|
|
53
|
+
rich_help_panel="🧠 Model Settings",
|
|
48
54
|
),
|
|
49
55
|
similarity_threshold: float = typer.Option(
|
|
50
56
|
0.5,
|
|
@@ -53,27 +59,32 @@ def main(
|
|
|
53
59
|
help="Similarity threshold for search results (0.0 to 1.0)",
|
|
54
60
|
min=0.0,
|
|
55
61
|
max=1.0,
|
|
62
|
+
rich_help_panel="🧠 Model Settings",
|
|
56
63
|
),
|
|
57
64
|
force: bool = typer.Option(
|
|
58
65
|
False,
|
|
59
66
|
"--force",
|
|
60
67
|
"-f",
|
|
61
68
|
help="Force re-initialization if project is already initialized",
|
|
69
|
+
rich_help_panel="⚙️ Advanced Options",
|
|
62
70
|
),
|
|
63
71
|
auto_index: bool = typer.Option(
|
|
64
72
|
True,
|
|
65
73
|
"--auto-index/--no-auto-index",
|
|
66
74
|
help="Automatically start indexing after initialization",
|
|
75
|
+
rich_help_panel="🚀 Workflow Options",
|
|
67
76
|
),
|
|
68
77
|
mcp: bool = typer.Option(
|
|
69
78
|
True,
|
|
70
79
|
"--mcp/--no-mcp",
|
|
71
80
|
help="Install Claude Code MCP integration after initialization",
|
|
81
|
+
rich_help_panel="🚀 Workflow Options",
|
|
72
82
|
),
|
|
73
83
|
auto_indexing: bool = typer.Option(
|
|
74
84
|
True,
|
|
75
85
|
"--auto-indexing/--no-auto-indexing",
|
|
76
86
|
help="Set up automatic indexing for file changes",
|
|
87
|
+
rich_help_panel="🚀 Workflow Options",
|
|
77
88
|
),
|
|
78
89
|
) -> None:
|
|
79
90
|
"""🚀 Complete project setup for semantic code search with MCP integration.
|
|
@@ -90,11 +101,25 @@ def main(
|
|
|
90
101
|
|
|
91
102
|
Perfect for getting started quickly in any project!
|
|
92
103
|
|
|
93
|
-
Examples:
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
mcp-vector-search init
|
|
97
|
-
|
|
104
|
+
[bold cyan]Examples:[/bold cyan]
|
|
105
|
+
|
|
106
|
+
[green]Basic setup (recommended):[/green]
|
|
107
|
+
$ mcp-vector-search init
|
|
108
|
+
|
|
109
|
+
[green]Quick setup without MCP:[/green]
|
|
110
|
+
$ mcp-vector-search init --no-mcp
|
|
111
|
+
|
|
112
|
+
[green]Custom file extensions:[/green]
|
|
113
|
+
$ mcp-vector-search init --extensions .py,.js,.ts,.txt,.md
|
|
114
|
+
|
|
115
|
+
[green]Re-initialize existing project:[/green]
|
|
116
|
+
$ mcp-vector-search init --force
|
|
117
|
+
|
|
118
|
+
[green]Setup without auto-indexing:[/green]
|
|
119
|
+
$ mcp-vector-search init --no-auto-index
|
|
120
|
+
|
|
121
|
+
[dim]💡 Tip: The command creates .mcp-vector-search/ for project config
|
|
122
|
+
and .mcp.json for MCP integration.[/dim]
|
|
98
123
|
"""
|
|
99
124
|
try:
|
|
100
125
|
# Get project root from context or auto-detect
|
|
@@ -109,12 +134,13 @@ def main(
|
|
|
109
134
|
|
|
110
135
|
# Find the development source directory
|
|
111
136
|
import mcp_vector_search
|
|
137
|
+
|
|
112
138
|
dev_source_path = Path(mcp_vector_search.__file__).parent.parent.parent
|
|
113
139
|
|
|
114
140
|
try:
|
|
141
|
+
import shutil
|
|
115
142
|
import subprocess
|
|
116
143
|
import sys
|
|
117
|
-
import shutil
|
|
118
144
|
|
|
119
145
|
# Try different installation methods based on available tools
|
|
120
146
|
install_success = False
|
|
@@ -123,7 +149,9 @@ def main(
|
|
|
123
149
|
if shutil.which("pip"):
|
|
124
150
|
install_cmd = ["pip", "install", "-e", str(dev_source_path)]
|
|
125
151
|
try:
|
|
126
|
-
result = subprocess.run(
|
|
152
|
+
result = subprocess.run(
|
|
153
|
+
install_cmd, capture_output=True, text=True, timeout=120
|
|
154
|
+
)
|
|
127
155
|
if result.returncode == 0:
|
|
128
156
|
install_success = True
|
|
129
157
|
except:
|
|
@@ -131,9 +159,18 @@ def main(
|
|
|
131
159
|
|
|
132
160
|
# Method 2: Try python -m pip
|
|
133
161
|
if not install_success:
|
|
134
|
-
install_cmd = [
|
|
162
|
+
install_cmd = [
|
|
163
|
+
sys.executable,
|
|
164
|
+
"-m",
|
|
165
|
+
"pip",
|
|
166
|
+
"install",
|
|
167
|
+
"-e",
|
|
168
|
+
str(dev_source_path),
|
|
169
|
+
]
|
|
135
170
|
try:
|
|
136
|
-
result = subprocess.run(
|
|
171
|
+
result = subprocess.run(
|
|
172
|
+
install_cmd, capture_output=True, text=True, timeout=120
|
|
173
|
+
)
|
|
137
174
|
if result.returncode == 0:
|
|
138
175
|
install_success = True
|
|
139
176
|
except:
|
|
@@ -143,7 +180,9 @@ def main(
|
|
|
143
180
|
if not install_success and shutil.which("uv"):
|
|
144
181
|
install_cmd = ["uv", "add", "--editable", str(dev_source_path)]
|
|
145
182
|
try:
|
|
146
|
-
result = subprocess.run(
|
|
183
|
+
result = subprocess.run(
|
|
184
|
+
install_cmd, capture_output=True, text=True, timeout=120
|
|
185
|
+
)
|
|
147
186
|
if result.returncode == 0:
|
|
148
187
|
install_success = True
|
|
149
188
|
except:
|
|
@@ -152,7 +191,9 @@ def main(
|
|
|
152
191
|
if install_success:
|
|
153
192
|
print_success("✅ mcp-vector-search installed successfully!")
|
|
154
193
|
else:
|
|
155
|
-
print_warning(
|
|
194
|
+
print_warning(
|
|
195
|
+
"⚠️ Could not install automatically - you may need to install manually"
|
|
196
|
+
)
|
|
156
197
|
print_info(f"💡 Try: pip install -e {dev_source_path}")
|
|
157
198
|
print_info("Continuing with setup...")
|
|
158
199
|
|
|
@@ -167,7 +208,9 @@ def main(
|
|
|
167
208
|
if project_manager.is_initialized() and not force:
|
|
168
209
|
print_success("Project is already initialized and ready to use!")
|
|
169
210
|
print_info("Your project has vector search capabilities enabled.")
|
|
170
|
-
print_info(
|
|
211
|
+
print_info(
|
|
212
|
+
"Use --force to re-initialize or run 'mcp-vector-search status' to see current configuration"
|
|
213
|
+
)
|
|
171
214
|
return # Exit gracefully without raising an exception
|
|
172
215
|
|
|
173
216
|
# Parse file extensions
|
|
@@ -187,8 +230,12 @@ def main(
|
|
|
187
230
|
console.print(f" 📄 File Extensions: {', '.join(file_extensions)}")
|
|
188
231
|
console.print(f" 🧠 Embedding Model: {embedding_model}")
|
|
189
232
|
console.print(f" 🎯 Similarity Threshold: {similarity_threshold}")
|
|
190
|
-
console.print(
|
|
191
|
-
|
|
233
|
+
console.print(
|
|
234
|
+
f" 🔍 Auto-indexing: {'✅ Enabled' if auto_index else '❌ Disabled'}"
|
|
235
|
+
)
|
|
236
|
+
console.print(
|
|
237
|
+
f" ⚡ File watching: {'✅ Enabled' if auto_indexing else '❌ Disabled'}"
|
|
238
|
+
)
|
|
192
239
|
console.print(f" 🔗 Claude Code MCP: {'✅ Enabled' if mcp else '❌ Disabled'}")
|
|
193
240
|
|
|
194
241
|
# Confirm initialization (only if not using defaults)
|
|
@@ -238,7 +285,9 @@ def main(
|
|
|
238
285
|
"You can run 'mcp-vector-search index' later to index your codebase"
|
|
239
286
|
)
|
|
240
287
|
else:
|
|
241
|
-
print_info(
|
|
288
|
+
print_info(
|
|
289
|
+
"💡 Run 'mcp-vector-search index' to index your codebase when ready"
|
|
290
|
+
)
|
|
242
291
|
|
|
243
292
|
# Install MCP integration if requested
|
|
244
293
|
if mcp:
|
|
@@ -246,78 +295,84 @@ def main(
|
|
|
246
295
|
|
|
247
296
|
try:
|
|
248
297
|
# Import MCP functionality
|
|
249
|
-
from .mcp import
|
|
250
|
-
import subprocess
|
|
298
|
+
from .mcp import create_project_claude_config
|
|
251
299
|
|
|
252
|
-
#
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
300
|
+
# Create .mcp.json in project root with proper configuration
|
|
301
|
+
create_project_claude_config(
|
|
302
|
+
project_root,
|
|
303
|
+
"mcp-vector-search",
|
|
304
|
+
enable_file_watching=auto_indexing,
|
|
305
|
+
)
|
|
306
|
+
print_success("✅ Claude Code MCP integration installed!")
|
|
307
|
+
print_info(
|
|
308
|
+
"📁 Created .mcp.json for team sharing - commit this file to your repo"
|
|
309
|
+
)
|
|
259
310
|
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
"mcp-vector-search",
|
|
265
|
-
"--",
|
|
266
|
-
] + server_command.split()
|
|
311
|
+
# Also set up auto-indexing if requested
|
|
312
|
+
if auto_indexing:
|
|
313
|
+
try:
|
|
314
|
+
import asyncio
|
|
267
315
|
|
|
268
|
-
|
|
269
|
-
cmd_args,
|
|
270
|
-
capture_output=True,
|
|
271
|
-
text=True,
|
|
272
|
-
timeout=30
|
|
273
|
-
)
|
|
316
|
+
from .auto_index import _setup_auto_indexing
|
|
274
317
|
|
|
275
|
-
|
|
276
|
-
print_success("
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
import asyncio
|
|
283
|
-
from .auto_index import _setup_auto_indexing
|
|
284
|
-
asyncio.run(_setup_auto_indexing(project_root, "search", 60, 5))
|
|
285
|
-
print_success("⚡ Auto-indexing configured for file changes")
|
|
286
|
-
except Exception as e:
|
|
287
|
-
print_warning(f"Auto-indexing setup failed: {e}")
|
|
288
|
-
print_info("You can set it up later with: mcp-vector-search auto-index setup")
|
|
289
|
-
else:
|
|
290
|
-
print_warning(f"MCP integration failed: {result.stderr}")
|
|
291
|
-
print_info("You can install it later with: mcp-vector-search mcp install")
|
|
318
|
+
asyncio.run(_setup_auto_indexing(project_root, "search", 60, 5))
|
|
319
|
+
print_success("⚡ Auto-indexing configured for file changes")
|
|
320
|
+
except Exception as e:
|
|
321
|
+
print_warning(f"Auto-indexing setup failed: {e}")
|
|
322
|
+
print_info(
|
|
323
|
+
"You can set it up later with: mcp-vector-search auto-index setup"
|
|
324
|
+
)
|
|
292
325
|
|
|
293
326
|
except Exception as e:
|
|
294
327
|
print_warning(f"MCP integration failed: {e}")
|
|
295
|
-
print_info(
|
|
328
|
+
print_info(
|
|
329
|
+
"You can install it later with: mcp-vector-search mcp install"
|
|
330
|
+
)
|
|
296
331
|
|
|
297
332
|
# Show completion status and next steps
|
|
298
|
-
|
|
333
|
+
print_success("🎉 Setup Complete!")
|
|
299
334
|
|
|
300
335
|
if auto_index and mcp:
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
336
|
+
# Full setup completed
|
|
337
|
+
completed_items = [
|
|
338
|
+
"Vector database initialized",
|
|
339
|
+
"Codebase indexed and searchable",
|
|
340
|
+
"Auto-indexing enabled for file changes",
|
|
341
|
+
"Claude Code MCP integration installed",
|
|
342
|
+
"Team configuration saved in .mcp.json",
|
|
343
|
+
]
|
|
344
|
+
print_panel(
|
|
345
|
+
"\n".join(f" ✅ {item}" for item in completed_items),
|
|
346
|
+
title="✨ Your Project is Fully Configured",
|
|
347
|
+
border_style="green",
|
|
348
|
+
)
|
|
349
|
+
|
|
350
|
+
# Next steps for fully configured project
|
|
351
|
+
next_steps = [
|
|
352
|
+
"[cyan]mcp-vector-search search 'your query'[/cyan] - Search your code",
|
|
353
|
+
"Use MCP tools in Claude Code for AI-powered code search",
|
|
354
|
+
"[cyan]mcp-vector-search status[/cyan] - Check indexing statistics",
|
|
355
|
+
]
|
|
356
|
+
print_next_steps(next_steps, title="Ready to Use")
|
|
357
|
+
|
|
358
|
+
print_tip("Commit .mcp.json to share MCP integration with your team!")
|
|
313
359
|
else:
|
|
314
|
-
|
|
360
|
+
# Partial setup - show what's next
|
|
361
|
+
steps = []
|
|
315
362
|
if not auto_index:
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
363
|
+
steps.append(
|
|
364
|
+
"[cyan]mcp-vector-search index[/cyan] - Index your codebase"
|
|
365
|
+
)
|
|
366
|
+
steps.append(
|
|
367
|
+
"[cyan]mcp-vector-search search 'your query'[/cyan] - Try semantic search"
|
|
368
|
+
)
|
|
369
|
+
steps.append("[cyan]mcp-vector-search status[/cyan] - Check project status")
|
|
319
370
|
if not mcp:
|
|
320
|
-
|
|
371
|
+
steps.append(
|
|
372
|
+
"[cyan]mcp-vector-search mcp install[/cyan] - Add Claude Code integration"
|
|
373
|
+
)
|
|
374
|
+
|
|
375
|
+
print_next_steps(steps)
|
|
321
376
|
|
|
322
377
|
except ProjectInitializationError as e:
|
|
323
378
|
print_error(f"Initialization failed: {e}")
|
|
@@ -420,9 +475,14 @@ async def run_init_setup(
|
|
|
420
475
|
|
|
421
476
|
try:
|
|
422
477
|
# Import MCP functionality
|
|
423
|
-
from .mcp import check_claude_code_available, get_claude_command, get_mcp_server_command
|
|
424
478
|
import subprocess
|
|
425
479
|
|
|
480
|
+
from .mcp import (
|
|
481
|
+
check_claude_code_available,
|
|
482
|
+
get_claude_command,
|
|
483
|
+
get_mcp_server_command,
|
|
484
|
+
)
|
|
485
|
+
|
|
426
486
|
# Check if Claude Code is available
|
|
427
487
|
if not check_claude_code_available():
|
|
428
488
|
print_warning("Claude Code not found. Skipping MCP integration.")
|
|
@@ -433,35 +493,43 @@ async def run_init_setup(
|
|
|
433
493
|
|
|
434
494
|
# Install MCP server with project scope for team sharing
|
|
435
495
|
cmd_args = [
|
|
436
|
-
claude_cmd,
|
|
496
|
+
claude_cmd,
|
|
497
|
+
"mcp",
|
|
498
|
+
"add",
|
|
437
499
|
"--scope=project", # Use project scope for team sharing
|
|
438
500
|
"mcp-vector-search",
|
|
439
501
|
"--",
|
|
440
502
|
] + server_command.split()
|
|
441
503
|
|
|
442
504
|
result = subprocess.run(
|
|
443
|
-
cmd_args,
|
|
444
|
-
capture_output=True,
|
|
445
|
-
text=True,
|
|
446
|
-
timeout=30
|
|
505
|
+
cmd_args, capture_output=True, text=True, timeout=30
|
|
447
506
|
)
|
|
448
507
|
|
|
449
508
|
if result.returncode == 0:
|
|
450
509
|
print_success("✅ Claude Code MCP integration installed!")
|
|
451
|
-
print_info(
|
|
510
|
+
print_info(
|
|
511
|
+
"📁 Created .mcp.json for team sharing - commit this file to your repo"
|
|
512
|
+
)
|
|
452
513
|
|
|
453
514
|
# Also set up auto-indexing if requested
|
|
454
515
|
if auto_indexing:
|
|
455
516
|
try:
|
|
456
517
|
from .auto_index import _setup_auto_indexing
|
|
518
|
+
|
|
457
519
|
await _setup_auto_indexing(project_root, "search", 60, 5)
|
|
458
|
-
print_success(
|
|
520
|
+
print_success(
|
|
521
|
+
"⚡ Auto-indexing configured for file changes"
|
|
522
|
+
)
|
|
459
523
|
except Exception as e:
|
|
460
524
|
print_warning(f"Auto-indexing setup failed: {e}")
|
|
461
|
-
print_info(
|
|
525
|
+
print_info(
|
|
526
|
+
"You can set it up later with: mcp-vector-search auto-index setup"
|
|
527
|
+
)
|
|
462
528
|
else:
|
|
463
529
|
print_warning(f"MCP integration failed: {result.stderr}")
|
|
464
|
-
print_info(
|
|
530
|
+
print_info(
|
|
531
|
+
"You can install it later with: mcp-vector-search mcp install"
|
|
532
|
+
)
|
|
465
533
|
|
|
466
534
|
except Exception as e:
|
|
467
535
|
print_warning(f"MCP integration failed: {e}")
|
|
@@ -472,16 +540,11 @@ async def run_init_setup(
|
|
|
472
540
|
def init_mcp_integration(
|
|
473
541
|
ctx: typer.Context,
|
|
474
542
|
server_name: str = typer.Option(
|
|
475
|
-
"mcp-vector-search",
|
|
476
|
-
"--name",
|
|
477
|
-
help="Name for the MCP server"
|
|
543
|
+
"mcp-vector-search", "--name", help="Name for the MCP server"
|
|
478
544
|
),
|
|
479
545
|
force: bool = typer.Option(
|
|
480
|
-
False,
|
|
481
|
-
|
|
482
|
-
"-f",
|
|
483
|
-
help="Force installation even if server already exists"
|
|
484
|
-
)
|
|
546
|
+
False, "--force", "-f", help="Force installation even if server already exists"
|
|
547
|
+
),
|
|
485
548
|
) -> None:
|
|
486
549
|
"""Install/fix Claude Code MCP integration for the current project.
|
|
487
550
|
|
|
@@ -494,13 +557,12 @@ def init_mcp_integration(
|
|
|
494
557
|
"""
|
|
495
558
|
try:
|
|
496
559
|
# Import MCP functions
|
|
560
|
+
import json
|
|
561
|
+
|
|
497
562
|
from .mcp import (
|
|
498
563
|
check_claude_code_available,
|
|
499
564
|
create_project_claude_config,
|
|
500
|
-
get_mcp_server_command,
|
|
501
565
|
)
|
|
502
|
-
import subprocess
|
|
503
|
-
import json
|
|
504
566
|
|
|
505
567
|
# Get project root
|
|
506
568
|
project_root = ctx.obj.get("project_root") or Path.cwd()
|
|
@@ -513,13 +575,13 @@ def init_mcp_integration(
|
|
|
513
575
|
|
|
514
576
|
print_info(f"Setting up MCP integration for project: {project_root}")
|
|
515
577
|
|
|
516
|
-
# Check if project-level .
|
|
517
|
-
|
|
518
|
-
if
|
|
519
|
-
with open(
|
|
578
|
+
# Check if project-level .mcp.json already has the server
|
|
579
|
+
mcp_config_path = project_root / ".mcp.json"
|
|
580
|
+
if mcp_config_path.exists() and not force:
|
|
581
|
+
with open(mcp_config_path) as f:
|
|
520
582
|
config = json.load(f)
|
|
521
583
|
if config.get("mcpServers", {}).get(server_name):
|
|
522
|
-
print_warning(f"MCP server '{server_name}' already exists in
|
|
584
|
+
print_warning(f"MCP server '{server_name}' already exists in .mcp.json")
|
|
523
585
|
print_info("Use --force to overwrite or try a different --name")
|
|
524
586
|
|
|
525
587
|
# Still test the existing configuration
|
|
@@ -530,8 +592,12 @@ def init_mcp_integration(
|
|
|
530
592
|
# Create project-level configuration
|
|
531
593
|
create_project_claude_config(project_root, server_name)
|
|
532
594
|
|
|
533
|
-
print_success(
|
|
534
|
-
|
|
595
|
+
print_success(
|
|
596
|
+
f"✅ MCP server '{server_name}' installed in project configuration"
|
|
597
|
+
)
|
|
598
|
+
print_info(
|
|
599
|
+
"📁 Created .mcp.json for team sharing - commit this file to your repo"
|
|
600
|
+
)
|
|
535
601
|
|
|
536
602
|
# Test the server
|
|
537
603
|
print_info("Testing server startup...")
|
|
@@ -541,16 +607,24 @@ def init_mcp_integration(
|
|
|
541
607
|
if not check_claude_code_available():
|
|
542
608
|
print_warning("⚠️ Claude Code not detected on this system")
|
|
543
609
|
print_info("📥 Install Claude Code from: https://claude.ai/download")
|
|
544
|
-
print_info(
|
|
610
|
+
print_info(
|
|
611
|
+
"🔄 After installation, restart Claude Code to detect the MCP server"
|
|
612
|
+
)
|
|
545
613
|
else:
|
|
546
|
-
print_success(
|
|
547
|
-
|
|
614
|
+
print_success(
|
|
615
|
+
"✅ Claude Code detected - server should be available automatically"
|
|
616
|
+
)
|
|
617
|
+
print_info(
|
|
618
|
+
"🔄 If Claude Code is running, restart it to detect the new server"
|
|
619
|
+
)
|
|
548
620
|
|
|
549
621
|
print_info("\n📋 Next steps:")
|
|
550
622
|
print_info(" 1. Restart Claude Code if it's currently running")
|
|
551
623
|
print_info(" 2. Open this project in Claude Code")
|
|
552
624
|
print_info(" 3. The MCP server should appear automatically in the tools list")
|
|
553
|
-
print_info(
|
|
625
|
+
print_info(
|
|
626
|
+
" 4. Test with: 'Search for functions that handle user authentication'"
|
|
627
|
+
)
|
|
554
628
|
|
|
555
629
|
except Exception as e:
|
|
556
630
|
logger.error(f"MCP integration setup failed: {e}")
|
|
@@ -561,9 +635,10 @@ def init_mcp_integration(
|
|
|
561
635
|
def _test_mcp_server(project_root: Path) -> None:
|
|
562
636
|
"""Test MCP server startup and basic functionality."""
|
|
563
637
|
try:
|
|
564
|
-
from .mcp import get_mcp_server_command
|
|
565
|
-
import subprocess
|
|
566
638
|
import json
|
|
639
|
+
import subprocess
|
|
640
|
+
|
|
641
|
+
from .mcp import get_mcp_server_command
|
|
567
642
|
|
|
568
643
|
server_command = get_mcp_server_command(project_root)
|
|
569
644
|
test_process = subprocess.Popen(
|
|
@@ -571,7 +646,7 @@ def _test_mcp_server(project_root: Path) -> None:
|
|
|
571
646
|
stdin=subprocess.PIPE,
|
|
572
647
|
stdout=subprocess.PIPE,
|
|
573
648
|
stderr=subprocess.PIPE,
|
|
574
|
-
text=True
|
|
649
|
+
text=True,
|
|
575
650
|
)
|
|
576
651
|
|
|
577
652
|
# Send a simple initialization request
|
|
@@ -582,20 +657,21 @@ def _test_mcp_server(project_root: Path) -> None:
|
|
|
582
657
|
"params": {
|
|
583
658
|
"protocolVersion": "2024-11-05",
|
|
584
659
|
"capabilities": {},
|
|
585
|
-
"clientInfo": {"name": "test", "version": "1.0.0"}
|
|
586
|
-
}
|
|
660
|
+
"clientInfo": {"name": "test", "version": "1.0.0"},
|
|
661
|
+
},
|
|
587
662
|
}
|
|
588
663
|
|
|
589
664
|
try:
|
|
590
665
|
stdout, stderr = test_process.communicate(
|
|
591
|
-
input=json.dumps(init_request) + "\n",
|
|
592
|
-
timeout=10
|
|
666
|
+
input=json.dumps(init_request) + "\n", timeout=10
|
|
593
667
|
)
|
|
594
668
|
|
|
595
669
|
if test_process.returncode == 0:
|
|
596
670
|
print_success("✅ Server startup test passed")
|
|
597
671
|
else:
|
|
598
|
-
print_warning(
|
|
672
|
+
print_warning(
|
|
673
|
+
f"⚠️ Server test failed with return code {test_process.returncode}"
|
|
674
|
+
)
|
|
599
675
|
if stderr:
|
|
600
676
|
print_info(f"Error output: {stderr}")
|
|
601
677
|
|