mm-qa-mcp 3.0.3__py3-none-any.whl → 3.0.4__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.
- minimax_qa_mcp/conf/conf.ini +12 -0
- minimax_qa_mcp/server.py +148 -0
- minimax_qa_mcp/src/gitlab_branch_analyzer/__init__.py +11 -0
- minimax_qa_mcp/src/gitlab_branch_analyzer/gitlab_branch_service.py +1150 -0
- {mm_qa_mcp-3.0.3.dist-info → mm_qa_mcp-3.0.4.dist-info}/METADATA +1 -1
- {mm_qa_mcp-3.0.3.dist-info → mm_qa_mcp-3.0.4.dist-info}/RECORD +9 -7
- {mm_qa_mcp-3.0.3.dist-info → mm_qa_mcp-3.0.4.dist-info}/WHEEL +1 -1
- {mm_qa_mcp-3.0.3.dist-info → mm_qa_mcp-3.0.4.dist-info}/entry_points.txt +0 -0
- {mm_qa_mcp-3.0.3.dist-info → mm_qa_mcp-3.0.4.dist-info}/top_level.txt +0 -0
minimax_qa_mcp/conf/conf.ini
CHANGED
|
@@ -66,6 +66,18 @@ url = http://10.11.8.37
|
|
|
66
66
|
port = 8080
|
|
67
67
|
grpc_port = 50051
|
|
68
68
|
|
|
69
|
+
[git_info]
|
|
70
|
+
# GitLab服务器地址
|
|
71
|
+
gitlab_url = https://gitlab.xaminim.com
|
|
72
|
+
# GitLab API访问令牌(Private Token)
|
|
73
|
+
access_token = SrFXdGjtd3AtRVJCkpDn
|
|
74
|
+
|
|
75
|
+
[apollo_info]
|
|
76
|
+
# Apollo配置获取API基础URL
|
|
77
|
+
apollo_base_url = http://swing-babel-ali-prod.xaminim.com/swing/api/get_apollo_value_by_key
|
|
78
|
+
# 存储产品线与GitLab Group映射的Apollo Key
|
|
79
|
+
# Apollo中配置格式: {"qa_group": [{"group_id": 1117, "group_name": "qa"}]}
|
|
80
|
+
product_line_gitlab_key = product_line_gitlab_projects
|
|
69
81
|
|
|
70
82
|
[generator_case_conf]
|
|
71
83
|
# 模型API URL,用于ModuleClient类调用
|
minimax_qa_mcp/server.py
CHANGED
|
@@ -23,6 +23,7 @@ from minimax_qa_mcp.src.query_segments.query_segments import query_main, TYPE_AP
|
|
|
23
23
|
TYPE_FUNC_DETAIL
|
|
24
24
|
from minimax_qa_mcp.src.auto_case.case_write import PDFWeaviateInfo
|
|
25
25
|
from minimax_qa_mcp.src.get_full_api_call_chain.get_full_api_call_chain import GetFullApiCallChain
|
|
26
|
+
from minimax_qa_mcp.src.gitlab_branch_analyzer.gitlab_branch_service import GitlabBranchService, GitlabRepoTypeDetector, GitlabBedrockResolver
|
|
26
27
|
|
|
27
28
|
# Initialize FastMCP server
|
|
28
29
|
mcp = FastMCP("mcp")
|
|
@@ -202,6 +203,153 @@ async def get_full_api_call_chain(api_path: str) -> dict:
|
|
|
202
203
|
logger.info(f"===== The result of get_full_api_call_chain is :{result}")
|
|
203
204
|
return result
|
|
204
205
|
|
|
206
|
+
@mcp.tool()
|
|
207
|
+
async def git_repo_clone(repo_url: str, clone_path: str) -> str:
|
|
208
|
+
"""
|
|
209
|
+
克隆Git仓库到指定路径
|
|
210
|
+
|
|
211
|
+
Args:
|
|
212
|
+
repo_url: Git仓库的URL
|
|
213
|
+
clone_path: 本地克隆路径
|
|
214
|
+
|
|
215
|
+
Returns:
|
|
216
|
+
克隆结果的字符串信息
|
|
217
|
+
"""
|
|
218
|
+
import git
|
|
219
|
+
try:
|
|
220
|
+
git.Repo.clone_from(repo_url, clone_path)
|
|
221
|
+
return f"Successfully cloned {repo_url} to {clone_path}"
|
|
222
|
+
except Exception as e:
|
|
223
|
+
return f"Failed to clone repository: {str(e)}"
|
|
224
|
+
|
|
225
|
+
|
|
226
|
+
@mcp.tool()
|
|
227
|
+
async def get_recent_branches_by_product_line(product_line: str, days: int = 3) -> list:
|
|
228
|
+
"""
|
|
229
|
+
获取产品线最近N天新创建的分支列表
|
|
230
|
+
|
|
231
|
+
根据产品线名称,从Apollo获取对应的GitLab项目列表,然后查询这些项目最近N天内新创建的分支。
|
|
232
|
+
|
|
233
|
+
Args:
|
|
234
|
+
product_line: 产品线名称,如 xingye(星野), talkie, hailuo(海螺)等
|
|
235
|
+
days: 查询最近多少天的分支,默认3天
|
|
236
|
+
|
|
237
|
+
Returns:
|
|
238
|
+
列表,包含新分支信息:
|
|
239
|
+
[
|
|
240
|
+
{
|
|
241
|
+
"repo_url": "https://gitlab.xaminim.com/qa/project_name",
|
|
242
|
+
"project_name": "project_name",
|
|
243
|
+
"branch_name": "feature/xxx",
|
|
244
|
+
"created_at": "2026-02-03T10:30:00+08:00",
|
|
245
|
+
"author": "developer_name"
|
|
246
|
+
},
|
|
247
|
+
...
|
|
248
|
+
]
|
|
249
|
+
"""
|
|
250
|
+
import concurrent.futures
|
|
251
|
+
loop = asyncio.get_running_loop()
|
|
252
|
+
|
|
253
|
+
logger.info(f"===== 获取产品线 {product_line} 最近 {days} 天的新分支 =====")
|
|
254
|
+
|
|
255
|
+
with concurrent.futures.ThreadPoolExecutor() as pool:
|
|
256
|
+
service = GitlabBranchService(product_line)
|
|
257
|
+
result = await loop.run_in_executor(pool, service.analyze_all_projects, days)
|
|
258
|
+
|
|
259
|
+
logger.info(f"===== 产品线 {product_line} 共找到 {len(result)} 个新分支 =====")
|
|
260
|
+
return result
|
|
261
|
+
|
|
262
|
+
|
|
263
|
+
@mcp.tool()
|
|
264
|
+
async def detect_repo_type(project_id: int, branch: str = None) -> dict:
|
|
265
|
+
"""
|
|
266
|
+
检测GitLab仓库类型(Server/FE/混合)
|
|
267
|
+
|
|
268
|
+
通过分析仓库的文件结构和依赖,判断项目是后端服务(Server)还是前端项目(FE)。
|
|
269
|
+
|
|
270
|
+
检测规则:
|
|
271
|
+
- Server特征:go.mod, pom.xml, requirements.txt, Cargo.toml, cmd/, pkg/, internal/
|
|
272
|
+
- FE特征:package.json + react/vue/angular依赖, src/components/, pages/
|
|
273
|
+
|
|
274
|
+
Args:
|
|
275
|
+
project_id: GitLab项目ID,可以从分支查询结果中获取
|
|
276
|
+
branch: 分支名,可选,默认使用仓库默认分支
|
|
277
|
+
|
|
278
|
+
Returns:
|
|
279
|
+
字典,包含仓库类型信息:
|
|
280
|
+
{
|
|
281
|
+
"type": "server" | "fe" | "mixed" | "unknown",
|
|
282
|
+
"language": "go" | "java" | "python" | "react" | "vue" | ...,
|
|
283
|
+
"framework": 框架名称(FE项目会返回),
|
|
284
|
+
"confidence": 0.0-1.0 置信度,
|
|
285
|
+
"indicators": ["go.mod", "cmd/", ...] 检测到的特征
|
|
286
|
+
}
|
|
287
|
+
"""
|
|
288
|
+
import concurrent.futures
|
|
289
|
+
loop = asyncio.get_running_loop()
|
|
290
|
+
|
|
291
|
+
logger.info(f"===== 检测项目 {project_id} 的仓库类型 =====")
|
|
292
|
+
|
|
293
|
+
with concurrent.futures.ThreadPoolExecutor() as pool:
|
|
294
|
+
detector = GitlabRepoTypeDetector()
|
|
295
|
+
result = await loop.run_in_executor(pool, detector.detect_repo_type, project_id, branch)
|
|
296
|
+
|
|
297
|
+
logger.info(f"===== 项目 {project_id} 类型检测结果: {result['type']} =====")
|
|
298
|
+
return result
|
|
299
|
+
|
|
300
|
+
|
|
301
|
+
@mcp.tool()
|
|
302
|
+
async def get_bedrock_info_by_repo(project_id: int, branch: str = None) -> dict:
|
|
303
|
+
"""
|
|
304
|
+
获取Git仓库对应的Bedrock部署信息
|
|
305
|
+
|
|
306
|
+
通过解析仓库的配置文件(.gitlab-ci.yml、Makefile等),
|
|
307
|
+
自动提取Bedrock部署相关信息,包括PSM、项目名、应用名等。
|
|
308
|
+
|
|
309
|
+
解析优先级:
|
|
310
|
+
1. .gitlab-ci.yml(最可靠)
|
|
311
|
+
2. Makefile
|
|
312
|
+
3. deploy.yaml / bedrock.yaml
|
|
313
|
+
4. 根据项目名推断(兜底方案)
|
|
314
|
+
|
|
315
|
+
Args:
|
|
316
|
+
project_id: GitLab项目ID,可以从分支查询结果中获取
|
|
317
|
+
branch: 分支名,可选,默认使用仓库默认分支
|
|
318
|
+
|
|
319
|
+
Returns:
|
|
320
|
+
字典,包含Bedrock部署信息:
|
|
321
|
+
{
|
|
322
|
+
"found": true/false, # 是否找到配置
|
|
323
|
+
"source": "gitlab-ci" | "makefile" | "inferred", # 配置来源
|
|
324
|
+
"psm": "xxx.yyy.zzz", # PSM 服务标识
|
|
325
|
+
"bedrock_project": "project-name", # Bedrock 项目名
|
|
326
|
+
"bedrock_app": "app-name", # Bedrock 应用名
|
|
327
|
+
"image_repo": "txharbor.xaminim.com/...", # 镜像仓库地址
|
|
328
|
+
"deploy_stages": [...], # 部署阶段配置
|
|
329
|
+
"confidence": "high" | "medium" | "low", # 置信度
|
|
330
|
+
"project_info": { # 项目基本信息
|
|
331
|
+
"name": "项目名",
|
|
332
|
+
"path": "group/project",
|
|
333
|
+
"web_url": "https://..."
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
"""
|
|
337
|
+
import concurrent.futures
|
|
338
|
+
loop = asyncio.get_running_loop()
|
|
339
|
+
|
|
340
|
+
logger.info(f"===== 获取项目 {project_id} 的 Bedrock 部署信息 =====")
|
|
341
|
+
|
|
342
|
+
with concurrent.futures.ThreadPoolExecutor() as pool:
|
|
343
|
+
resolver = GitlabBedrockResolver()
|
|
344
|
+
result = await loop.run_in_executor(pool, resolver.get_bedrock_info, project_id, branch)
|
|
345
|
+
|
|
346
|
+
if result.get('found'):
|
|
347
|
+
logger.info(f"===== 项目 {project_id} 找到 Bedrock 配置: PSM={result.get('psm')}, App={result.get('bedrock_app')} =====")
|
|
348
|
+
else:
|
|
349
|
+
logger.warning(f"===== 项目 {project_id} 未找到 Bedrock 配置 =====")
|
|
350
|
+
|
|
351
|
+
return result
|
|
352
|
+
|
|
205
353
|
|
|
206
354
|
def main():
|
|
207
355
|
print("Starting Minimax QA MCP server")
|