mcp-vector-search 0.15.7__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 +10 -0
- mcp_vector_search/cli/__init__.py +1 -0
- mcp_vector_search/cli/commands/__init__.py +1 -0
- mcp_vector_search/cli/commands/auto_index.py +397 -0
- mcp_vector_search/cli/commands/chat.py +534 -0
- mcp_vector_search/cli/commands/config.py +393 -0
- mcp_vector_search/cli/commands/demo.py +358 -0
- mcp_vector_search/cli/commands/index.py +762 -0
- mcp_vector_search/cli/commands/init.py +658 -0
- mcp_vector_search/cli/commands/install.py +869 -0
- mcp_vector_search/cli/commands/install_old.py +700 -0
- mcp_vector_search/cli/commands/mcp.py +1254 -0
- mcp_vector_search/cli/commands/reset.py +393 -0
- mcp_vector_search/cli/commands/search.py +796 -0
- mcp_vector_search/cli/commands/setup.py +1133 -0
- mcp_vector_search/cli/commands/status.py +584 -0
- mcp_vector_search/cli/commands/uninstall.py +404 -0
- mcp_vector_search/cli/commands/visualize/__init__.py +39 -0
- mcp_vector_search/cli/commands/visualize/cli.py +265 -0
- mcp_vector_search/cli/commands/visualize/exporters/__init__.py +12 -0
- mcp_vector_search/cli/commands/visualize/exporters/html_exporter.py +33 -0
- mcp_vector_search/cli/commands/visualize/exporters/json_exporter.py +29 -0
- mcp_vector_search/cli/commands/visualize/graph_builder.py +709 -0
- mcp_vector_search/cli/commands/visualize/layout_engine.py +469 -0
- mcp_vector_search/cli/commands/visualize/server.py +201 -0
- mcp_vector_search/cli/commands/visualize/state_manager.py +428 -0
- mcp_vector_search/cli/commands/visualize/templates/__init__.py +16 -0
- mcp_vector_search/cli/commands/visualize/templates/base.py +218 -0
- mcp_vector_search/cli/commands/visualize/templates/scripts.py +3670 -0
- mcp_vector_search/cli/commands/visualize/templates/styles.py +779 -0
- mcp_vector_search/cli/commands/visualize.py.original +2536 -0
- mcp_vector_search/cli/commands/watch.py +287 -0
- mcp_vector_search/cli/didyoumean.py +520 -0
- mcp_vector_search/cli/export.py +320 -0
- mcp_vector_search/cli/history.py +295 -0
- mcp_vector_search/cli/interactive.py +342 -0
- mcp_vector_search/cli/main.py +484 -0
- mcp_vector_search/cli/output.py +414 -0
- mcp_vector_search/cli/suggestions.py +375 -0
- mcp_vector_search/config/__init__.py +1 -0
- mcp_vector_search/config/constants.py +24 -0
- mcp_vector_search/config/defaults.py +200 -0
- mcp_vector_search/config/settings.py +146 -0
- mcp_vector_search/core/__init__.py +1 -0
- mcp_vector_search/core/auto_indexer.py +298 -0
- mcp_vector_search/core/config_utils.py +394 -0
- mcp_vector_search/core/connection_pool.py +360 -0
- mcp_vector_search/core/database.py +1237 -0
- mcp_vector_search/core/directory_index.py +318 -0
- mcp_vector_search/core/embeddings.py +294 -0
- mcp_vector_search/core/exceptions.py +89 -0
- mcp_vector_search/core/factory.py +318 -0
- mcp_vector_search/core/git_hooks.py +345 -0
- mcp_vector_search/core/indexer.py +1002 -0
- mcp_vector_search/core/llm_client.py +453 -0
- mcp_vector_search/core/models.py +294 -0
- mcp_vector_search/core/project.py +350 -0
- mcp_vector_search/core/scheduler.py +330 -0
- mcp_vector_search/core/search.py +952 -0
- mcp_vector_search/core/watcher.py +322 -0
- mcp_vector_search/mcp/__init__.py +5 -0
- mcp_vector_search/mcp/__main__.py +25 -0
- mcp_vector_search/mcp/server.py +752 -0
- mcp_vector_search/parsers/__init__.py +8 -0
- mcp_vector_search/parsers/base.py +296 -0
- mcp_vector_search/parsers/dart.py +605 -0
- mcp_vector_search/parsers/html.py +413 -0
- mcp_vector_search/parsers/javascript.py +643 -0
- mcp_vector_search/parsers/php.py +694 -0
- mcp_vector_search/parsers/python.py +502 -0
- mcp_vector_search/parsers/registry.py +223 -0
- mcp_vector_search/parsers/ruby.py +678 -0
- mcp_vector_search/parsers/text.py +186 -0
- mcp_vector_search/parsers/utils.py +265 -0
- mcp_vector_search/py.typed +1 -0
- mcp_vector_search/utils/__init__.py +42 -0
- mcp_vector_search/utils/gitignore.py +250 -0
- mcp_vector_search/utils/gitignore_updater.py +212 -0
- mcp_vector_search/utils/monorepo.py +339 -0
- mcp_vector_search/utils/timing.py +338 -0
- mcp_vector_search/utils/version.py +47 -0
- mcp_vector_search-0.15.7.dist-info/METADATA +884 -0
- mcp_vector_search-0.15.7.dist-info/RECORD +86 -0
- mcp_vector_search-0.15.7.dist-info/WHEEL +4 -0
- mcp_vector_search-0.15.7.dist-info/entry_points.txt +3 -0
- mcp_vector_search-0.15.7.dist-info/licenses/LICENSE +21 -0
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
"""Parser registry for MCP Vector Search."""
|
|
2
|
+
|
|
3
|
+
from pathlib import Path
|
|
4
|
+
|
|
5
|
+
from loguru import logger
|
|
6
|
+
|
|
7
|
+
from .base import BaseParser, FallbackParser
|
|
8
|
+
from .dart import DartParser
|
|
9
|
+
from .html import HTMLParser
|
|
10
|
+
from .javascript import JavaScriptParser, TypeScriptParser
|
|
11
|
+
from .php import PHPParser
|
|
12
|
+
from .python import PythonParser
|
|
13
|
+
from .ruby import RubyParser
|
|
14
|
+
from .text import TextParser
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class ParserRegistry:
|
|
18
|
+
"""Registry for managing language parsers."""
|
|
19
|
+
|
|
20
|
+
def __init__(self) -> None:
|
|
21
|
+
"""Initialize parser registry."""
|
|
22
|
+
self._parsers: dict[str, BaseParser] = {}
|
|
23
|
+
self._extension_map: dict[str, str] = {}
|
|
24
|
+
self._fallback_parser = FallbackParser()
|
|
25
|
+
self._initialized = False
|
|
26
|
+
|
|
27
|
+
def _ensure_initialized(self) -> None:
|
|
28
|
+
"""Ensure parsers are initialized (lazy initialization)."""
|
|
29
|
+
if not self._initialized:
|
|
30
|
+
self._register_default_parsers()
|
|
31
|
+
self._initialized = True
|
|
32
|
+
|
|
33
|
+
def _register_default_parsers(self) -> None:
|
|
34
|
+
"""Register default parsers for supported languages."""
|
|
35
|
+
# Register Python parser
|
|
36
|
+
python_parser = PythonParser()
|
|
37
|
+
self.register_parser("python", python_parser)
|
|
38
|
+
|
|
39
|
+
# Register JavaScript parser
|
|
40
|
+
javascript_parser = JavaScriptParser()
|
|
41
|
+
self.register_parser("javascript", javascript_parser)
|
|
42
|
+
|
|
43
|
+
# Register TypeScript parser
|
|
44
|
+
typescript_parser = TypeScriptParser()
|
|
45
|
+
self.register_parser("typescript", typescript_parser)
|
|
46
|
+
|
|
47
|
+
# Register Dart parser
|
|
48
|
+
dart_parser = DartParser()
|
|
49
|
+
self.register_parser("dart", dart_parser)
|
|
50
|
+
|
|
51
|
+
# Register PHP parser
|
|
52
|
+
php_parser = PHPParser()
|
|
53
|
+
self.register_parser("php", php_parser)
|
|
54
|
+
|
|
55
|
+
# Register Ruby parser
|
|
56
|
+
ruby_parser = RubyParser()
|
|
57
|
+
self.register_parser("ruby", ruby_parser)
|
|
58
|
+
|
|
59
|
+
# Register Text parser for .txt files
|
|
60
|
+
text_parser = TextParser()
|
|
61
|
+
self.register_parser("text", text_parser)
|
|
62
|
+
|
|
63
|
+
# Register HTML parser for .html files
|
|
64
|
+
html_parser = HTMLParser()
|
|
65
|
+
self.register_parser("html", html_parser)
|
|
66
|
+
|
|
67
|
+
def register_parser(self, language: str, parser: BaseParser) -> None:
|
|
68
|
+
"""Register a parser for a specific language.
|
|
69
|
+
|
|
70
|
+
Args:
|
|
71
|
+
language: Language name
|
|
72
|
+
parser: Parser instance
|
|
73
|
+
"""
|
|
74
|
+
self._parsers[language] = parser
|
|
75
|
+
|
|
76
|
+
# Map file extensions to language
|
|
77
|
+
for ext in parser.get_supported_extensions():
|
|
78
|
+
if ext != "*": # Skip fallback marker
|
|
79
|
+
self._extension_map[ext.lower()] = language
|
|
80
|
+
|
|
81
|
+
logger.debug(f"Registered parser for {language}: {parser.__class__.__name__}")
|
|
82
|
+
|
|
83
|
+
def get_parser(self, file_extension: str) -> BaseParser:
|
|
84
|
+
"""Get parser for a file extension.
|
|
85
|
+
|
|
86
|
+
Args:
|
|
87
|
+
file_extension: File extension (including dot)
|
|
88
|
+
|
|
89
|
+
Returns:
|
|
90
|
+
Parser instance (fallback parser if no specific parser found)
|
|
91
|
+
"""
|
|
92
|
+
self._ensure_initialized()
|
|
93
|
+
language = self._extension_map.get(file_extension.lower())
|
|
94
|
+
if language and language in self._parsers:
|
|
95
|
+
return self._parsers[language]
|
|
96
|
+
|
|
97
|
+
# Return fallback parser for unsupported extensions
|
|
98
|
+
return self._fallback_parser
|
|
99
|
+
|
|
100
|
+
def get_parser_for_file(self, file_path: Path) -> BaseParser:
|
|
101
|
+
"""Get parser for a specific file.
|
|
102
|
+
|
|
103
|
+
Args:
|
|
104
|
+
file_path: Path to the file
|
|
105
|
+
|
|
106
|
+
Returns:
|
|
107
|
+
Parser instance
|
|
108
|
+
"""
|
|
109
|
+
return self.get_parser(file_path.suffix)
|
|
110
|
+
|
|
111
|
+
def get_supported_languages(self) -> list[str]:
|
|
112
|
+
"""Get list of supported languages.
|
|
113
|
+
|
|
114
|
+
Returns:
|
|
115
|
+
List of language names
|
|
116
|
+
"""
|
|
117
|
+
self._ensure_initialized()
|
|
118
|
+
return list(self._parsers.keys())
|
|
119
|
+
|
|
120
|
+
def get_supported_extensions(self) -> list[str]:
|
|
121
|
+
"""Get list of supported file extensions.
|
|
122
|
+
|
|
123
|
+
Returns:
|
|
124
|
+
List of file extensions
|
|
125
|
+
"""
|
|
126
|
+
self._ensure_initialized()
|
|
127
|
+
return list(self._extension_map.keys())
|
|
128
|
+
|
|
129
|
+
def is_supported(self, file_extension: str) -> bool:
|
|
130
|
+
"""Check if a file extension is supported.
|
|
131
|
+
|
|
132
|
+
Args:
|
|
133
|
+
file_extension: File extension to check
|
|
134
|
+
|
|
135
|
+
Returns:
|
|
136
|
+
True if supported (always True due to fallback parser)
|
|
137
|
+
"""
|
|
138
|
+
return True # Always supported due to fallback parser
|
|
139
|
+
|
|
140
|
+
def get_language_for_extension(self, file_extension: str) -> str:
|
|
141
|
+
"""Get language name for a file extension.
|
|
142
|
+
|
|
143
|
+
Args:
|
|
144
|
+
file_extension: File extension
|
|
145
|
+
|
|
146
|
+
Returns:
|
|
147
|
+
Language name (or "text" for unsupported extensions)
|
|
148
|
+
"""
|
|
149
|
+
self._ensure_initialized()
|
|
150
|
+
return self._extension_map.get(file_extension.lower(), "text")
|
|
151
|
+
|
|
152
|
+
def get_parser_info(self) -> dict[str, dict[str, any]]:
|
|
153
|
+
"""Get information about registered parsers.
|
|
154
|
+
|
|
155
|
+
Returns:
|
|
156
|
+
Dictionary with parser information
|
|
157
|
+
"""
|
|
158
|
+
self._ensure_initialized()
|
|
159
|
+
info = {}
|
|
160
|
+
|
|
161
|
+
for language, parser in self._parsers.items():
|
|
162
|
+
info[language] = {
|
|
163
|
+
"class": parser.__class__.__name__,
|
|
164
|
+
"extensions": parser.get_supported_extensions(),
|
|
165
|
+
"language": getattr(parser, "language", None) or language,
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
# Add fallback parser info
|
|
169
|
+
fallback_lang = getattr(self._fallback_parser, "language", None) or "unknown"
|
|
170
|
+
info["fallback"] = {
|
|
171
|
+
"class": self._fallback_parser.__class__.__name__,
|
|
172
|
+
"extensions": ["*"],
|
|
173
|
+
"language": fallback_lang,
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
return info
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
# Global parser registry instance
|
|
180
|
+
_registry = ParserRegistry()
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
def get_parser_registry() -> ParserRegistry:
|
|
184
|
+
"""Get the global parser registry instance.
|
|
185
|
+
|
|
186
|
+
Returns:
|
|
187
|
+
Parser registry instance
|
|
188
|
+
"""
|
|
189
|
+
return _registry
|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
def register_parser(language: str, parser: BaseParser) -> None:
|
|
193
|
+
"""Register a parser in the global registry.
|
|
194
|
+
|
|
195
|
+
Args:
|
|
196
|
+
language: Language name
|
|
197
|
+
parser: Parser instance
|
|
198
|
+
"""
|
|
199
|
+
_registry.register_parser(language, parser)
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
def get_parser(file_extension: str) -> BaseParser:
|
|
203
|
+
"""Get parser for a file extension from the global registry.
|
|
204
|
+
|
|
205
|
+
Args:
|
|
206
|
+
file_extension: File extension
|
|
207
|
+
|
|
208
|
+
Returns:
|
|
209
|
+
Parser instance
|
|
210
|
+
"""
|
|
211
|
+
return _registry.get_parser(file_extension)
|
|
212
|
+
|
|
213
|
+
|
|
214
|
+
def get_parser_for_file(file_path: Path) -> BaseParser:
|
|
215
|
+
"""Get parser for a file from the global registry.
|
|
216
|
+
|
|
217
|
+
Args:
|
|
218
|
+
file_path: File path
|
|
219
|
+
|
|
220
|
+
Returns:
|
|
221
|
+
Parser instance
|
|
222
|
+
"""
|
|
223
|
+
return _registry.get_parser_for_file(file_path)
|