mcp-vector-search 0.0.3__py3-none-any.whl → 0.4.11__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 +3 -2
- mcp_vector_search/cli/commands/auto_index.py +397 -0
- mcp_vector_search/cli/commands/config.py +88 -40
- mcp_vector_search/cli/commands/index.py +198 -52
- mcp_vector_search/cli/commands/init.py +472 -58
- mcp_vector_search/cli/commands/install.py +284 -0
- mcp_vector_search/cli/commands/mcp.py +495 -0
- mcp_vector_search/cli/commands/search.py +241 -87
- mcp_vector_search/cli/commands/status.py +184 -58
- mcp_vector_search/cli/commands/watch.py +34 -35
- mcp_vector_search/cli/didyoumean.py +184 -0
- mcp_vector_search/cli/export.py +320 -0
- mcp_vector_search/cli/history.py +292 -0
- mcp_vector_search/cli/interactive.py +342 -0
- mcp_vector_search/cli/main.py +163 -26
- mcp_vector_search/cli/output.py +63 -45
- mcp_vector_search/config/defaults.py +50 -36
- mcp_vector_search/config/settings.py +49 -35
- mcp_vector_search/core/auto_indexer.py +298 -0
- mcp_vector_search/core/connection_pool.py +322 -0
- mcp_vector_search/core/database.py +335 -25
- mcp_vector_search/core/embeddings.py +73 -29
- mcp_vector_search/core/exceptions.py +19 -2
- mcp_vector_search/core/factory.py +310 -0
- mcp_vector_search/core/git_hooks.py +345 -0
- mcp_vector_search/core/indexer.py +237 -73
- mcp_vector_search/core/models.py +21 -19
- mcp_vector_search/core/project.py +73 -58
- mcp_vector_search/core/scheduler.py +330 -0
- mcp_vector_search/core/search.py +574 -86
- mcp_vector_search/core/watcher.py +48 -46
- mcp_vector_search/mcp/__init__.py +4 -0
- mcp_vector_search/mcp/__main__.py +25 -0
- mcp_vector_search/mcp/server.py +701 -0
- mcp_vector_search/parsers/base.py +30 -31
- mcp_vector_search/parsers/javascript.py +74 -48
- mcp_vector_search/parsers/python.py +57 -49
- mcp_vector_search/parsers/registry.py +47 -32
- mcp_vector_search/parsers/text.py +179 -0
- mcp_vector_search/utils/__init__.py +40 -0
- mcp_vector_search/utils/gitignore.py +229 -0
- mcp_vector_search/utils/timing.py +334 -0
- mcp_vector_search/utils/version.py +47 -0
- {mcp_vector_search-0.0.3.dist-info → mcp_vector_search-0.4.11.dist-info}/METADATA +173 -7
- mcp_vector_search-0.4.11.dist-info/RECORD +54 -0
- mcp_vector_search-0.0.3.dist-info/RECORD +0 -35
- {mcp_vector_search-0.0.3.dist-info → mcp_vector_search-0.4.11.dist-info}/WHEEL +0 -0
- {mcp_vector_search-0.0.3.dist-info → mcp_vector_search-0.4.11.dist-info}/entry_points.txt +0 -0
- {mcp_vector_search-0.0.3.dist-info → mcp_vector_search-0.4.11.dist-info}/licenses/LICENSE +0 -0
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
"""Install command for MCP Vector Search CLI."""
|
|
2
|
+
|
|
3
|
+
import asyncio
|
|
4
|
+
import subprocess
|
|
5
|
+
import sys
|
|
6
|
+
from pathlib import Path
|
|
7
|
+
|
|
8
|
+
import typer
|
|
9
|
+
from loguru import logger
|
|
10
|
+
from rich.console import Console
|
|
11
|
+
from rich.panel import Panel
|
|
12
|
+
|
|
13
|
+
from ...core.project import ProjectManager
|
|
14
|
+
from ..output import print_error, print_info, print_success, print_warning
|
|
15
|
+
|
|
16
|
+
# Create console for rich output
|
|
17
|
+
console = Console()
|
|
18
|
+
|
|
19
|
+
# Create install subcommand app
|
|
20
|
+
install_app = typer.Typer(help="Install mcp-vector-search in projects")
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
@install_app.command()
|
|
24
|
+
def main(
|
|
25
|
+
ctx: typer.Context,
|
|
26
|
+
target_directory: Path = typer.Argument(
|
|
27
|
+
None,
|
|
28
|
+
help="Target directory to install in (default: current directory)",
|
|
29
|
+
),
|
|
30
|
+
project_root: Path | None = typer.Option(
|
|
31
|
+
None,
|
|
32
|
+
"--project-root",
|
|
33
|
+
"-p",
|
|
34
|
+
help="Project root directory (auto-detected if not specified)",
|
|
35
|
+
exists=True,
|
|
36
|
+
file_okay=False,
|
|
37
|
+
dir_okay=True,
|
|
38
|
+
readable=True,
|
|
39
|
+
),
|
|
40
|
+
extensions: str | None = typer.Option(
|
|
41
|
+
None,
|
|
42
|
+
"--extensions",
|
|
43
|
+
"-e",
|
|
44
|
+
help="Comma-separated list of file extensions to index (e.g., '.py,.js,.ts,.txt,.md')",
|
|
45
|
+
),
|
|
46
|
+
embedding_model: str = typer.Option(
|
|
47
|
+
"sentence-transformers/all-MiniLM-L6-v2",
|
|
48
|
+
"--embedding-model",
|
|
49
|
+
"-m",
|
|
50
|
+
help="Embedding model to use for semantic search",
|
|
51
|
+
),
|
|
52
|
+
similarity_threshold: float = typer.Option(
|
|
53
|
+
0.5,
|
|
54
|
+
"--similarity-threshold",
|
|
55
|
+
"-s",
|
|
56
|
+
help="Similarity threshold for search results (0.0 to 1.0)",
|
|
57
|
+
min=0.0,
|
|
58
|
+
max=1.0,
|
|
59
|
+
),
|
|
60
|
+
no_mcp: bool = typer.Option(
|
|
61
|
+
False,
|
|
62
|
+
"--no-mcp",
|
|
63
|
+
help="Skip MCP integration setup",
|
|
64
|
+
),
|
|
65
|
+
no_auto_index: bool = typer.Option(
|
|
66
|
+
False,
|
|
67
|
+
"--no-auto-index",
|
|
68
|
+
help="Skip automatic indexing after setup",
|
|
69
|
+
),
|
|
70
|
+
force: bool = typer.Option(
|
|
71
|
+
False,
|
|
72
|
+
"--force",
|
|
73
|
+
"-f",
|
|
74
|
+
help="Force re-installation if project is already initialized",
|
|
75
|
+
),
|
|
76
|
+
) -> None:
|
|
77
|
+
"""Install mcp-vector-search in a project directory.
|
|
78
|
+
|
|
79
|
+
This command sets up mcp-vector-search in the specified directory (or current directory)
|
|
80
|
+
with full initialization, indexing, and optional MCP integration.
|
|
81
|
+
|
|
82
|
+
Examples:
|
|
83
|
+
mcp-vector-search install # Install in current directory
|
|
84
|
+
mcp-vector-search install ~/my-project # Install in specific directory
|
|
85
|
+
mcp-vector-search install --no-mcp # Install without MCP integration
|
|
86
|
+
mcp-vector-search install --force # Force re-installation
|
|
87
|
+
mcp-vector-search install --extensions .py,.js,.ts,.txt # Custom file extensions
|
|
88
|
+
"""
|
|
89
|
+
try:
|
|
90
|
+
# Determine target directory - prioritize target_directory, then project_root, then context, then cwd
|
|
91
|
+
target_dir = target_directory or project_root or ctx.obj.get("project_root") or Path.cwd()
|
|
92
|
+
target_dir = target_dir.resolve()
|
|
93
|
+
|
|
94
|
+
# Show installation header
|
|
95
|
+
console.print(Panel.fit(
|
|
96
|
+
f"[bold blue]🚀 MCP Vector Search - Project Installation[/bold blue]\n\n"
|
|
97
|
+
f"📁 Target project: [cyan]{target_dir}[/cyan]\n"
|
|
98
|
+
f"🔧 Installing with full setup and configuration",
|
|
99
|
+
border_style="blue"
|
|
100
|
+
))
|
|
101
|
+
|
|
102
|
+
# Check if target directory exists
|
|
103
|
+
if not target_dir.exists():
|
|
104
|
+
print_error(f"Target directory does not exist: {target_dir}")
|
|
105
|
+
raise typer.Exit(1)
|
|
106
|
+
|
|
107
|
+
# Check if already initialized
|
|
108
|
+
project_manager = ProjectManager(target_dir)
|
|
109
|
+
if project_manager.is_initialized() and not force:
|
|
110
|
+
print_success("Project is already initialized and ready to use!")
|
|
111
|
+
print_info("Your project has vector search capabilities enabled.")
|
|
112
|
+
print_info(f"Use --force to re-initialize or run 'mcp-vector-search --project-root {target_dir} status main' to see current configuration")
|
|
113
|
+
|
|
114
|
+
console.print("\n[bold green]🔍 Ready to use:[/bold green]")
|
|
115
|
+
console.print(f" • Search your code: [code]cd {target_dir} && mcp-vector-search search 'your query'[/code]")
|
|
116
|
+
console.print(f" • Check status: [code]cd {target_dir} && mcp-vector-search status main[/code]")
|
|
117
|
+
console.print(" • Use [code]--force[/code] to re-initialize if needed")
|
|
118
|
+
return
|
|
119
|
+
|
|
120
|
+
# Parse file extensions
|
|
121
|
+
file_extensions = None
|
|
122
|
+
if extensions:
|
|
123
|
+
file_extensions = [ext.strip() for ext in extensions.split(",")]
|
|
124
|
+
# Ensure extensions start with dot
|
|
125
|
+
file_extensions = [
|
|
126
|
+
ext if ext.startswith(".") else f".{ext}" for ext in file_extensions
|
|
127
|
+
]
|
|
128
|
+
|
|
129
|
+
# Run initialization
|
|
130
|
+
print_info("Initializing project...")
|
|
131
|
+
|
|
132
|
+
# Import init functionality
|
|
133
|
+
from .init import run_init_setup
|
|
134
|
+
|
|
135
|
+
asyncio.run(
|
|
136
|
+
run_init_setup(
|
|
137
|
+
project_root=target_dir,
|
|
138
|
+
file_extensions=file_extensions,
|
|
139
|
+
embedding_model=embedding_model,
|
|
140
|
+
similarity_threshold=similarity_threshold,
|
|
141
|
+
mcp=not no_mcp,
|
|
142
|
+
auto_index=not no_auto_index,
|
|
143
|
+
force=force,
|
|
144
|
+
)
|
|
145
|
+
)
|
|
146
|
+
|
|
147
|
+
# Show completion message
|
|
148
|
+
console.print(Panel.fit(
|
|
149
|
+
f"[bold green]🎉 Installation Complete![/bold green]\n\n"
|
|
150
|
+
f"✅ Project initialized at [cyan]{target_dir}[/cyan]\n"
|
|
151
|
+
f"✅ Vector database configured\n"
|
|
152
|
+
f"✅ {'Codebase indexed' if not no_auto_index else 'Ready for indexing'}\n"
|
|
153
|
+
f"✅ {'MCP integration enabled' if not no_mcp else 'MCP integration skipped'}\n\n"
|
|
154
|
+
f"[bold blue]🔍 Next steps:[/bold blue]\n"
|
|
155
|
+
f" • [code]cd {target_dir}[/code]\n"
|
|
156
|
+
f" • [code]mcp-vector-search search 'your query'[/code]\n"
|
|
157
|
+
f" • [code]mcp-vector-search status main[/code]",
|
|
158
|
+
border_style="green"
|
|
159
|
+
))
|
|
160
|
+
|
|
161
|
+
except Exception as e:
|
|
162
|
+
logger.error(f"Installation failed: {e}")
|
|
163
|
+
print_error(f"Installation failed: {e}")
|
|
164
|
+
raise typer.Exit(1)
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
@install_app.command("demo")
|
|
168
|
+
def demo(
|
|
169
|
+
project_root: Path | None = typer.Option(
|
|
170
|
+
None,
|
|
171
|
+
"--project-root",
|
|
172
|
+
"-p",
|
|
173
|
+
help="Project root directory (auto-detected if not specified)",
|
|
174
|
+
exists=True,
|
|
175
|
+
file_okay=False,
|
|
176
|
+
dir_okay=True,
|
|
177
|
+
readable=True,
|
|
178
|
+
),
|
|
179
|
+
) -> None:
|
|
180
|
+
"""Run installation demo with sample project."""
|
|
181
|
+
try:
|
|
182
|
+
import tempfile
|
|
183
|
+
import shutil
|
|
184
|
+
|
|
185
|
+
print_info("🎬 Running mcp-vector-search installation demo...")
|
|
186
|
+
|
|
187
|
+
# Create temporary demo directory
|
|
188
|
+
with tempfile.TemporaryDirectory(prefix="mcp-demo-") as temp_dir:
|
|
189
|
+
demo_dir = Path(temp_dir) / "demo-project"
|
|
190
|
+
demo_dir.mkdir()
|
|
191
|
+
|
|
192
|
+
# Create sample files
|
|
193
|
+
(demo_dir / "main.py").write_text("""
|
|
194
|
+
def main():
|
|
195
|
+
'''Main entry point for the application.'''
|
|
196
|
+
print("Hello, World!")
|
|
197
|
+
user_service = UserService()
|
|
198
|
+
user_service.create_user("Alice", "alice@example.com")
|
|
199
|
+
|
|
200
|
+
class UserService:
|
|
201
|
+
'''Service for managing users.'''
|
|
202
|
+
|
|
203
|
+
def create_user(self, name: str, email: str):
|
|
204
|
+
'''Create a new user with the given name and email.'''
|
|
205
|
+
print(f"Creating user: {name} ({email})")
|
|
206
|
+
return {"name": name, "email": email}
|
|
207
|
+
|
|
208
|
+
def authenticate_user(self, email: str, password: str):
|
|
209
|
+
'''Authenticate user with email and password.'''
|
|
210
|
+
# Simple authentication logic
|
|
211
|
+
return email.endswith("@example.com")
|
|
212
|
+
|
|
213
|
+
if __name__ == "__main__":
|
|
214
|
+
main()
|
|
215
|
+
""")
|
|
216
|
+
|
|
217
|
+
(demo_dir / "utils.py").write_text("""
|
|
218
|
+
import json
|
|
219
|
+
from typing import Dict, Any
|
|
220
|
+
|
|
221
|
+
def load_config(config_path: str) -> Dict[str, Any]:
|
|
222
|
+
'''Load configuration from JSON file.'''
|
|
223
|
+
with open(config_path, 'r') as f:
|
|
224
|
+
return json.load(f)
|
|
225
|
+
|
|
226
|
+
def validate_email(email: str) -> bool:
|
|
227
|
+
'''Validate email address format.'''
|
|
228
|
+
return "@" in email and "." in email.split("@")[1]
|
|
229
|
+
|
|
230
|
+
def hash_password(password: str) -> str:
|
|
231
|
+
'''Hash password for secure storage.'''
|
|
232
|
+
import hashlib
|
|
233
|
+
return hashlib.sha256(password.encode()).hexdigest()
|
|
234
|
+
""")
|
|
235
|
+
|
|
236
|
+
console.print(f"\n[bold blue]📁 Created demo project at:[/bold blue] {demo_dir}")
|
|
237
|
+
|
|
238
|
+
# Run installation
|
|
239
|
+
print_info("Installing mcp-vector-search in demo project...")
|
|
240
|
+
|
|
241
|
+
# Use subprocess to run the install command
|
|
242
|
+
result = subprocess.run([
|
|
243
|
+
sys.executable, "-m", "mcp_vector_search.cli.main",
|
|
244
|
+
"--project-root", str(demo_dir),
|
|
245
|
+
"install", str(demo_dir),
|
|
246
|
+
"--extensions", ".py",
|
|
247
|
+
"--no-mcp" # Skip MCP for demo
|
|
248
|
+
], capture_output=True, text=True)
|
|
249
|
+
|
|
250
|
+
if result.returncode == 0:
|
|
251
|
+
print_success("✅ Demo installation completed!")
|
|
252
|
+
|
|
253
|
+
# Run a sample search
|
|
254
|
+
print_info("Running sample search: 'user authentication'...")
|
|
255
|
+
|
|
256
|
+
search_result = subprocess.run([
|
|
257
|
+
sys.executable, "-m", "mcp_vector_search.cli.main",
|
|
258
|
+
"--project-root", str(demo_dir),
|
|
259
|
+
"search", "user authentication",
|
|
260
|
+
"--limit", "3"
|
|
261
|
+
], capture_output=True, text=True)
|
|
262
|
+
|
|
263
|
+
if search_result.returncode == 0:
|
|
264
|
+
console.print("\n[bold green]🔍 Sample search results:[/bold green]")
|
|
265
|
+
console.print(search_result.stdout)
|
|
266
|
+
else:
|
|
267
|
+
print_warning("Search demo failed, but installation was successful")
|
|
268
|
+
|
|
269
|
+
console.print(f"\n[bold blue]🎉 Demo completed![/bold blue]")
|
|
270
|
+
console.print(f"Demo project was created at: [cyan]{demo_dir}[/cyan]")
|
|
271
|
+
console.print("The temporary directory will be cleaned up automatically.")
|
|
272
|
+
|
|
273
|
+
else:
|
|
274
|
+
print_error(f"Demo installation failed: {result.stderr}")
|
|
275
|
+
raise typer.Exit(1)
|
|
276
|
+
|
|
277
|
+
except Exception as e:
|
|
278
|
+
logger.error(f"Demo failed: {e}")
|
|
279
|
+
print_error(f"Demo failed: {e}")
|
|
280
|
+
raise typer.Exit(1)
|
|
281
|
+
|
|
282
|
+
|
|
283
|
+
if __name__ == "__main__":
|
|
284
|
+
install_app()
|