awslabs.git-repo-research-mcp-server 0.0.1__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.
awslabs/__init__.py ADDED
@@ -0,0 +1,12 @@
1
+ # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance
4
+ # with the License. A copy of the License is located at
5
+ #
6
+ # http://www.apache.org/licenses/LICENSE-2.0
7
+ #
8
+ # or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES
9
+ # OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions
10
+ # and limitations under the License.
11
+ # This file is part of the awslabs namespace.
12
+ # It is intentionally minimal to support PEP 420 namespace packages.
@@ -0,0 +1,13 @@
1
+ # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance
4
+ # with the License. A copy of the License is located at
5
+ #
6
+ # http://www.apache.org/licenses/LICENSE-2.0
7
+ #
8
+ # or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES
9
+ # OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions
10
+ # and limitations under the License.
11
+ """awslabs.git-repo-research-mcp-server"""
12
+
13
+ __version__ = '0.0.0'
@@ -0,0 +1,347 @@
1
+ # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance
4
+ # with the License. A copy of the License is located at
5
+ #
6
+ # http://www.apache.org/licenses/LICENSE-2.0
7
+ #
8
+ # or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES
9
+ # OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions
10
+ # and limitations under the License.
11
+ """Default constants for Git Repository Research MCP Server."""
12
+
13
+
14
+ class Constants:
15
+ """Constants used throughout the Git Repository Research MCP Server."""
16
+
17
+ # Text file patterns for repository file filtering
18
+ TEXT_FILE_INCLUDE_PATTERNS = [
19
+ '*.py',
20
+ '*.js',
21
+ '*.ts',
22
+ '*.jsx',
23
+ '*.tsx',
24
+ '*.html',
25
+ '*.htm',
26
+ '*.css',
27
+ '*.scss',
28
+ '*.sass',
29
+ '*.less',
30
+ '*.json',
31
+ '*.xml',
32
+ '*.yaml',
33
+ '*.yml',
34
+ '*.md',
35
+ '*.rst',
36
+ '*.txt',
37
+ '*.java',
38
+ '*.c',
39
+ '*.cpp',
40
+ '*.h',
41
+ '*.hpp',
42
+ '*.cs',
43
+ '*.rb',
44
+ '*.php',
45
+ '*.go',
46
+ '*.rs',
47
+ '*.swift',
48
+ '*.sh',
49
+ '*.bash',
50
+ '*.zsh',
51
+ '*.sql',
52
+ '*.kt',
53
+ '*.kts',
54
+ '*.dart',
55
+ '*.lua',
56
+ '*.r',
57
+ '*.pl',
58
+ '*.ps1',
59
+ '*.config',
60
+ '*.conf',
61
+ '*.cfg',
62
+ '*.ini',
63
+ '*.toml',
64
+ '*.graphql',
65
+ '*.proto',
66
+ 'Dockerfile',
67
+ 'docker-compose.yml',
68
+ 'Makefile',
69
+ 'README*',
70
+ 'LICENSE*',
71
+ 'CONTRIBUTING*',
72
+ ]
73
+
74
+ TEXT_FILE_EXCLUDE_PATTERNS = [
75
+ # Binary image files
76
+ '*.jpg',
77
+ '*.jpeg',
78
+ '*.png',
79
+ '*.gif',
80
+ '*.bmp',
81
+ '*.tiff',
82
+ '*.ico',
83
+ '*.svg',
84
+ '*.webp',
85
+ # Document and media files
86
+ '*.pdf',
87
+ '*.docx',
88
+ '*.xlsx',
89
+ '*.pptx',
90
+ '*.doc',
91
+ '*.xls',
92
+ '*.ppt',
93
+ '*.mp3',
94
+ '*.mp4',
95
+ '*.wav',
96
+ '*.avi',
97
+ '*.mov',
98
+ '*.ogg',
99
+ '*.flac',
100
+ # Archive files
101
+ '*.zip',
102
+ '*.tar',
103
+ '*.gz',
104
+ '*.rar',
105
+ '*.7z',
106
+ '*.bz2',
107
+ '*.xz',
108
+ '*.tgz',
109
+ # Binary executable, object and library files
110
+ '*.exe',
111
+ '*.dll',
112
+ '*.so',
113
+ '*.dylib',
114
+ '*.class',
115
+ '*.jar',
116
+ '*.war',
117
+ '*.ear',
118
+ '*.pyc',
119
+ '*.pyo',
120
+ '*.o',
121
+ '*.obj',
122
+ '*.a',
123
+ '*.lib',
124
+ '*.bin',
125
+ '*.whl',
126
+ # Data files
127
+ '*.dat',
128
+ '*.db',
129
+ '*.sqlite',
130
+ '*.sqlite3',
131
+ '*.mdb',
132
+ '*.ldb',
133
+ '*.frm',
134
+ # Lock files and package-specific files
135
+ '*.lock',
136
+ 'package-lock.json',
137
+ 'yarn.lock',
138
+ 'poetry.lock',
139
+ # Common dependency directories
140
+ 'node_modules/**',
141
+ 'bower_components/**',
142
+ 'jspm_packages/**',
143
+ 'vendor/**',
144
+ '.gradle/**',
145
+ '.maven/**',
146
+ '.nuget/**',
147
+ # Virtual environments
148
+ '.venv/**',
149
+ 'venv/**',
150
+ 'env/**',
151
+ 'virtualenv/**',
152
+ 'ENV/**',
153
+ '.env/**',
154
+ '.tox/**',
155
+ # Build and distribution directories
156
+ 'dist/**',
157
+ 'build/**',
158
+ 'target/**',
159
+ 'bin/**',
160
+ 'obj/**',
161
+ '__pycache__/**',
162
+ '.pytest_cache/**',
163
+ '*.egg-info/**',
164
+ '.eggs/**',
165
+ '.coverage/**',
166
+ # Git and version control
167
+ '.git/**',
168
+ '.github/**',
169
+ '.hg/**',
170
+ '.svn/**',
171
+ 'CVS/**',
172
+ # IDE and editor directories
173
+ '.vscode/**',
174
+ '.idea/**',
175
+ '.vs/**',
176
+ '.settings/**',
177
+ '.project/**',
178
+ '.classpath/**',
179
+ '*.sublime-*',
180
+ # Minified files
181
+ '*.min.js',
182
+ '*.min.css',
183
+ '*.map',
184
+ # Various config directories
185
+ '.cache/**',
186
+ '.config/**',
187
+ # Logs and temporary files
188
+ 'logs/**',
189
+ '*.log',
190
+ '*.tmp',
191
+ '*.temp',
192
+ # OS specific files
193
+ '.DS_Store',
194
+ 'Thumbs.db',
195
+ 'desktop.ini',
196
+ # Large data files
197
+ '*.csv',
198
+ '*.tsv', # Consider including these if needed for analysis
199
+ '*.parquet',
200
+ '*.avro',
201
+ '*.orc',
202
+ # Machine learning specific
203
+ '*.onnx',
204
+ '*.pb',
205
+ '*.pt',
206
+ '*.pth',
207
+ '*.h5',
208
+ '*.hdf5',
209
+ '*.pkl',
210
+ '*.pickle',
211
+ ]
212
+
213
+ # Default directory for storing indices
214
+ DEFAULT_INDEX_DIR = '.git_repo_research'
215
+
216
+ # Default patterns for file inclusion
217
+ DEFAULT_INCLUDE_PATTERNS = [
218
+ '**/*.md',
219
+ '**/*.py',
220
+ '**/*.js',
221
+ '**/*.ts',
222
+ '**/*.java',
223
+ '**/*.go',
224
+ '**/*.rs',
225
+ '**/*.c',
226
+ '**/*.cpp',
227
+ '**/*.h',
228
+ '**/*.hpp',
229
+ '**/*.cs',
230
+ '**/*.rb',
231
+ '**/*.php',
232
+ '**/*.scala',
233
+ '**/*.swift',
234
+ '**/*.kt',
235
+ '**/*.groovy',
236
+ '**/*.sh',
237
+ '**/*.bash',
238
+ '**/*.ps1',
239
+ '**/*.md',
240
+ '**/*.rst',
241
+ '**/*.txt',
242
+ '**/*.html',
243
+ '**/*.css',
244
+ '**/*.scss',
245
+ '**/*.sass',
246
+ '**/*.less',
247
+ '**/*.json',
248
+ '**/*.yml',
249
+ '**/*.yaml',
250
+ '**/*.xml',
251
+ '**/*.toml',
252
+ '**/*.ini',
253
+ '**/*.cfg',
254
+ '**/*.conf',
255
+ '**/*.properties',
256
+ '**/*.tf',
257
+ '**/*.tfvars',
258
+ '**/*.cdk.ts',
259
+ '**/*.jsx',
260
+ '**/*.tsx',
261
+ '**/*.vue',
262
+ '**/*.sql',
263
+ '**/*.graphql',
264
+ '**/*.proto',
265
+ '**/*.dockerfile',
266
+ 'Dockerfile',
267
+ 'docker-compose.yml',
268
+ 'Makefile',
269
+ 'CMakeLists.txt',
270
+ '**/*.gradle',
271
+ 'LICENSE',
272
+ 'README*',
273
+ 'CHANGELOG*',
274
+ 'CONTRIBUTING*',
275
+ 'CODE_OF_CONDUCT*',
276
+ ]
277
+
278
+ # Default patterns for file exclusion
279
+ DEFAULT_EXCLUDE_PATTERNS = [
280
+ '**/.git/**',
281
+ '**/.github/**',
282
+ '**/.svn/**',
283
+ '**/.hg/**',
284
+ '**/.bzr/**',
285
+ '**/node_modules/**',
286
+ '**/venv/**',
287
+ '**/.venv/**',
288
+ '**/env/**',
289
+ '**/.env/**',
290
+ '**/__pycache__/**',
291
+ '**/.pytest_cache/**',
292
+ '**/.coverage/**',
293
+ '**/coverage/**',
294
+ '**/dist/**',
295
+ '**/build/**',
296
+ '**/.DS_Store',
297
+ '**/*.pyc',
298
+ '**/*.pyo',
299
+ '**/*.pyd',
300
+ '**/*.so',
301
+ '**/*.dll',
302
+ '**/*.exe',
303
+ '**/*.bin',
304
+ '**/*.obj',
305
+ '**/*.o',
306
+ '**/*.a',
307
+ '**/*.lib',
308
+ '**/*.dylib',
309
+ '**/*.ncb',
310
+ '**/*.sdf',
311
+ '**/*.suo',
312
+ '**/*.pdb',
313
+ '**/*.idb',
314
+ '**/*.jpg',
315
+ '**/*.jpeg',
316
+ '**/*.png',
317
+ '**/*.gif',
318
+ '**/*.svg',
319
+ '**/*.ico',
320
+ '**/*.mp4',
321
+ '**/*.mov',
322
+ '**/*.wmv',
323
+ '**/*.flv',
324
+ '**/*.avi',
325
+ '**/*.mkv',
326
+ '**/*.mp3',
327
+ '**/*.wav',
328
+ '**/*.flac',
329
+ '**/*.zip',
330
+ '**/*.tar.gz',
331
+ '**/*.tar',
332
+ '**/*.rar',
333
+ '**/*.7z',
334
+ '**/*.pdf',
335
+ '**/*.docx',
336
+ '**/*.xlsx',
337
+ '**/*.pptx',
338
+ '**/logs/**',
339
+ '**/log/**',
340
+ '**/.idea/**',
341
+ '**/.vscode/**',
342
+ '**/.classpath',
343
+ '**/.project',
344
+ '**/.settings/**',
345
+ '**/.gradle/**',
346
+ '**/target/**',
347
+ ]
@@ -0,0 +1,66 @@
1
+ # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance
4
+ # with the License. A copy of the License is located at
5
+ #
6
+ # http://www.apache.org/licenses/LICENSE-2.0
7
+ #
8
+ # or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES
9
+ # OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions
10
+ # and limitations under the License.
11
+ """Embeddings generation for Git Repository Research MCP Server.
12
+
13
+ This module provides functionality for generating embeddings from text
14
+ using Amazon Bedrock models via LangChain.
15
+ """
16
+
17
+ import os
18
+ from awslabs.git_repo_research_mcp_server.models import EmbeddingModel
19
+ from langchain_aws import BedrockEmbeddings
20
+ from langchain_core.embeddings.embeddings import Embeddings
21
+ from loguru import logger
22
+ from typing import Optional
23
+
24
+
25
+ def create_bedrock_embeddings(
26
+ model_id: str = EmbeddingModel.AMAZON_TITAN_EMBED_TEXT_V2,
27
+ aws_region: Optional[str] = None,
28
+ aws_profile: Optional[str] = None,
29
+ ) -> Embeddings:
30
+ """Create and return an instance of BedrockEmbeddings.
31
+
32
+ Args:
33
+ model_id: ID of the embedding model to use
34
+ aws_region: AWS region to use (optional, uses default if not provided)
35
+ aws_profile: AWS profile to use (optional, uses default if not provided)
36
+
37
+ Returns:
38
+ BedrockEmbeddings: An instance of BedrockEmbeddings
39
+ """
40
+ aws_region = aws_region or os.environ.get('AWS_REGION', 'us-west-2')
41
+
42
+ bedrock_embeddings = BedrockEmbeddings(
43
+ model_id=model_id,
44
+ region_name=aws_region,
45
+ credentials_profile_name=aws_profile,
46
+ )
47
+ logger.info(f'Created BedrockEmbeddings with model: {model_id}')
48
+ return bedrock_embeddings
49
+
50
+
51
+ def get_embedding_model(
52
+ model_id: str = EmbeddingModel.AMAZON_TITAN_EMBED_TEXT_V2,
53
+ aws_region: Optional[str] = None,
54
+ aws_profile: Optional[str] = None,
55
+ ) -> Embeddings:
56
+ """Factory method to return a LangChain embedding model.
57
+
58
+ Args:
59
+ model_id: ID of the embedding model to use
60
+ aws_region: AWS region to use (optional, uses default if not provided)
61
+ aws_profile: AWS profile to use (optional, uses default if not provided)
62
+
63
+ Returns:
64
+ Embeddings instance
65
+ """
66
+ return create_bedrock_embeddings(model_id, aws_region, aws_profile)