mm-qa-mcp 0.2.0__tar.gz

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.
Files changed (35) hide show
  1. mm_qa_mcp-0.2.0/MANIFEST.in +19 -0
  2. mm_qa_mcp-0.2.0/PKG-INFO +167 -0
  3. mm_qa_mcp-0.2.0/README.md +97 -0
  4. mm_qa_mcp-0.2.0/minimax_qa_mcp/__init__.py +14 -0
  5. mm_qa_mcp-0.2.0/minimax_qa_mcp/conf/__init__.py +6 -0
  6. mm_qa_mcp-0.2.0/minimax_qa_mcp/conf/conf.ini +86 -0
  7. mm_qa_mcp-0.2.0/minimax_qa_mcp/server.py +184 -0
  8. mm_qa_mcp-0.2.0/minimax_qa_mcp/src/__init__.py +0 -0
  9. mm_qa_mcp-0.2.0/minimax_qa_mcp/src/demo_langchain/__init__.py +6 -0
  10. mm_qa_mcp-0.2.0/minimax_qa_mcp/src/demo_langchain/langchain_demo.py +1 -0
  11. mm_qa_mcp-0.2.0/minimax_qa_mcp/src/gateway_case/__init__.py +0 -0
  12. mm_qa_mcp-0.2.0/minimax_qa_mcp/src/gateway_case/get_case.py +608 -0
  13. mm_qa_mcp-0.2.0/minimax_qa_mcp/src/generator_case/__init__.py +6 -0
  14. mm_qa_mcp-0.2.0/minimax_qa_mcp/src/generator_case/generator_case.py +1187 -0
  15. mm_qa_mcp-0.2.0/minimax_qa_mcp/src/generator_case/generator_case_langchain.py +1078 -0
  16. mm_qa_mcp-0.2.0/minimax_qa_mcp/src/get_weaviate_info/__init__.py +6 -0
  17. mm_qa_mcp-0.2.0/minimax_qa_mcp/src/get_weaviate_info/get_weaviate_info.py +298 -0
  18. mm_qa_mcp-0.2.0/minimax_qa_mcp/src/grafana/__init__.py +0 -0
  19. mm_qa_mcp-0.2.0/minimax_qa_mcp/src/grafana/service.py +104 -0
  20. mm_qa_mcp-0.2.0/minimax_qa_mcp/src/query_segments/__init__.py +6 -0
  21. mm_qa_mcp-0.2.0/minimax_qa_mcp/src/query_segments/query_segments.py +2848 -0
  22. mm_qa_mcp-0.2.0/minimax_qa_mcp/src/xmind2markdown/__init__.py +6 -0
  23. mm_qa_mcp-0.2.0/minimax_qa_mcp/src/xmind2markdown/xmind_to_markdown.py +976 -0
  24. mm_qa_mcp-0.2.0/minimax_qa_mcp/utils/__init__.py +0 -0
  25. mm_qa_mcp-0.2.0/minimax_qa_mcp/utils/logger.py +38 -0
  26. mm_qa_mcp-0.2.0/minimax_qa_mcp/utils/utils.py +246 -0
  27. mm_qa_mcp-0.2.0/mm_qa_mcp.egg-info/PKG-INFO +167 -0
  28. mm_qa_mcp-0.2.0/mm_qa_mcp.egg-info/SOURCES.txt +33 -0
  29. mm_qa_mcp-0.2.0/mm_qa_mcp.egg-info/dependency_links.txt +1 -0
  30. mm_qa_mcp-0.2.0/mm_qa_mcp.egg-info/entry_points.txt +2 -0
  31. mm_qa_mcp-0.2.0/mm_qa_mcp.egg-info/requires.txt +57 -0
  32. mm_qa_mcp-0.2.0/mm_qa_mcp.egg-info/top_level.txt +1 -0
  33. mm_qa_mcp-0.2.0/pyproject.toml +93 -0
  34. mm_qa_mcp-0.2.0/setup.cfg +4 -0
  35. mm_qa_mcp-0.2.0/setup.py +41 -0
@@ -0,0 +1,19 @@
1
+ include README.md
2
+ include pyproject.toml
3
+ include setup.py
4
+
5
+ # 包含所有配置文件
6
+ recursive-include minimax_qa_mcp *.ini
7
+ recursive-include minimax_qa_mcp *.json
8
+ recursive-include minimax_qa_mcp *.yaml
9
+ recursive-include minimax_qa_mcp *.yml
10
+ recursive-include minimax_qa_mcp *.txt
11
+
12
+ # 包含所有Python文件
13
+ recursive-include minimax_qa_mcp *.py
14
+
15
+ # 排除编译文件
16
+ global-exclude *.py[cod]
17
+ global-exclude __pycache__
18
+ global-exclude *.so
19
+ global-exclude .DS_Store
@@ -0,0 +1,167 @@
1
+ Metadata-Version: 2.4
2
+ Name: mm_qa_mcp
3
+ Version: 0.2.0
4
+ Summary: QA agent service 集合
5
+ Author-email: xingyun <xingyun@minimaxi.com>
6
+ License-Expression: MIT
7
+ Classifier: Development Status :: 4 - Beta
8
+ Classifier: Intended Audience :: Developers
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: Programming Language :: Python :: 3.9
11
+ Classifier: Programming Language :: Python :: 3.10
12
+ Requires-Python: >=3.10
13
+ Description-Content-Type: text/markdown
14
+ Requires-Dist: annotated-types>=0.7.0
15
+ Requires-Dist: anyio>=4.9.0
16
+ Requires-Dist: Authlib>=1.5.2
17
+ Requires-Dist: certifi>=2025.1.31
18
+ Requires-Dist: cffi>=1.17.1
19
+ Requires-Dist: charset-normalizer>=3.4.1
20
+ Requires-Dist: classes>=0.4.1
21
+ Requires-Dist: click>=8.1.8
22
+ Requires-Dist: cryptography>=44.0.2
23
+ Requires-Dist: h11>=0.14.0
24
+ Requires-Dist: httpcore>=1.0.7
25
+ Requires-Dist: httpx>=0.28.1
26
+ Requires-Dist: httpx-sse>=0.4.0
27
+ Requires-Dist: idna>=3.10
28
+ Requires-Dist: jsonpatch>=1.33
29
+ Requires-Dist: jsonpointer>=3.0.0
30
+ Requires-Dist: langchain-core>=0.3.51
31
+ Requires-Dist: langsmith>=0.3.27
32
+ Requires-Dist: mcp>=1.6.0
33
+ Requires-Dist: numpy>=2.2.4
34
+ Requires-Dist: orjson>=3.10.16
35
+ Requires-Dist: packaging>=24.2
36
+ Requires-Dist: pandas>=2.2.3
37
+ Requires-Dist: prettytable>=3.16.0
38
+ Requires-Dist: pycparser>=2.22
39
+ Requires-Dist: pydantic>=2.11.3
40
+ Requires-Dist: pydantic-settings>=2.8.1
41
+ Requires-Dist: pydantic_core>=2.33.1
42
+ Requires-Dist: python-dateutil>=2.9.0.post0
43
+ Requires-Dist: python-dotenv>=1.1.0
44
+ Requires-Dist: pytz>=2025.2
45
+ Requires-Dist: PyYAML>=6.0.2
46
+ Requires-Dist: requests>=2.32.3
47
+ Requires-Dist: requests-toolbelt>=1.0.0
48
+ Requires-Dist: six>=1.17.0
49
+ Requires-Dist: sniffio>=1.3.1
50
+ Requires-Dist: sse-starlette>=2.2.1
51
+ Requires-Dist: starlette>=0.46.1
52
+ Requires-Dist: tabulate>=0.9.0
53
+ Requires-Dist: tenacity>=9.1.2
54
+ Requires-Dist: typing-inspection>=0.4.0
55
+ Requires-Dist: typing_extensions>=4.13.1
56
+ Requires-Dist: tzdata>=2025.2
57
+ Requires-Dist: urllib3>=2.3.0
58
+ Requires-Dist: uvicorn>=0.34.0
59
+ Requires-Dist: validators>=0.34.0
60
+ Requires-Dist: wcwidth>=0.2.13
61
+ Requires-Dist: weaviate>=0.1.2
62
+ Requires-Dist: weaviate-client>=3.26.7
63
+ Requires-Dist: zstandard>=0.23.0
64
+ Provides-Extra: dev
65
+ Requires-Dist: pytest>=7.0.0; extra == "dev"
66
+ Requires-Dist: mypy>=1.0.0; extra == "dev"
67
+ Requires-Dist: black>=23.0.0; extra == "dev"
68
+ Requires-Dist: isort>=5.12.0; extra == "dev"
69
+ Requires-Dist: twine>=4.0.0; extra == "dev"
70
+
71
+ # QA - agent service 集合
72
+
73
+ ## 项目结构
74
+ - `server.py`: MCP接口定义和服务启动入口
75
+ - `src/`: 核心功能模块实现
76
+ - `conf/`: 配置文件
77
+ - `utils/`: 工具函数
78
+ - `logs/`: 日志文件夹
79
+
80
+ ## 功能特性
81
+ 1. 天气服务(demo):
82
+ - 获取美国各州天气警报信息
83
+ - 基于经纬度获取天气预报
84
+
85
+ 2. 日志检索服务:
86
+ - 从Grafana获取各业务服务的日志
87
+ - 支持按关键字、时间等条件筛选
88
+ - 支持获取服务接口列表
89
+
90
+ ## 环境配置与启动
91
+
92
+ 项目现在使用ux进行构建和打包,提供了多种安装运行方式。
93
+
94
+ ### 1. 从PyPI安装
95
+
96
+ ```shell
97
+ # 直接从PyPI安装
98
+ pip install minimax-qa-mcp
99
+
100
+ # 运行服务
101
+ minimax-qa-mcp
102
+ ```
103
+
104
+ ### 2. 开发模式
105
+
106
+ ```shell
107
+ # 安装依赖
108
+ pip install ux
109
+ pip install -r requirements.txt
110
+
111
+ # 开发模式运行
112
+ bash run.sh
113
+ # 或
114
+ ux run
115
+ ```
116
+
117
+ ### 3. 构建与发布
118
+
119
+ ```shell
120
+ # 构建项目
121
+ bash build.sh
122
+
123
+ # 发布到PyPI
124
+ bash publish.sh
125
+ ```
126
+
127
+ ### 4. 查看启动
128
+ ```
129
+ 本地生成 log/agent_log.log文件,且打印
130
+ INFO: Uvicorn running on http://0.0.0.0:8888 (Press CTRL+C to quit)
131
+ ```
132
+
133
+ ### 5. 集成到MCP客户端
134
+
135
+ #### curl
136
+ ```shell
137
+ http://0.0.0.0:8888/sse
138
+ ```
139
+
140
+ #### Python模块方式
141
+ ```shell
142
+ python -m minimax_qa_mcp.server
143
+ ```
144
+
145
+ #### Claude Desktop 配置
146
+ ```json
147
+ {
148
+ "agent_name": {
149
+ "command": "minimax-qa-mcp",
150
+ "args": ["--host", "0.0.0.0", "--port", "8888"]
151
+ }
152
+ }
153
+ ```
154
+
155
+ ## API 说明
156
+
157
+ ### 天气服务(demo)
158
+ - `get_alerts(state)`: 获取指定州的天气警报
159
+ - `get_forecast(latitude, longitude)`: 获取指定位置的天气预报
160
+
161
+ ### 日志服务
162
+ - `get_grafana_data(scene, psm, msg, from_time, to_time)`: 获取业务的grafana日志
163
+ - `get_top_methods(scene, psm)`: 获取服务存在调用的接口列表
164
+ - `get_http_data(scene, psm, api_path, from_time, to_time)`: 获取业务http接口流量日志
165
+ - `query_code_segments(query, query_type, limit, exact, advanced, depth, direction, output)`: 查询代码片段
166
+ - `gen_case(input_data, pwd)`: 生成link_case
167
+ - `get_weaviate_info(input_data)`: 获取业务相关信息
@@ -0,0 +1,97 @@
1
+ # QA - agent service 集合
2
+
3
+ ## 项目结构
4
+ - `server.py`: MCP接口定义和服务启动入口
5
+ - `src/`: 核心功能模块实现
6
+ - `conf/`: 配置文件
7
+ - `utils/`: 工具函数
8
+ - `logs/`: 日志文件夹
9
+
10
+ ## 功能特性
11
+ 1. 天气服务(demo):
12
+ - 获取美国各州天气警报信息
13
+ - 基于经纬度获取天气预报
14
+
15
+ 2. 日志检索服务:
16
+ - 从Grafana获取各业务服务的日志
17
+ - 支持按关键字、时间等条件筛选
18
+ - 支持获取服务接口列表
19
+
20
+ ## 环境配置与启动
21
+
22
+ 项目现在使用ux进行构建和打包,提供了多种安装运行方式。
23
+
24
+ ### 1. 从PyPI安装
25
+
26
+ ```shell
27
+ # 直接从PyPI安装
28
+ pip install minimax-qa-mcp
29
+
30
+ # 运行服务
31
+ minimax-qa-mcp
32
+ ```
33
+
34
+ ### 2. 开发模式
35
+
36
+ ```shell
37
+ # 安装依赖
38
+ pip install ux
39
+ pip install -r requirements.txt
40
+
41
+ # 开发模式运行
42
+ bash run.sh
43
+ # 或
44
+ ux run
45
+ ```
46
+
47
+ ### 3. 构建与发布
48
+
49
+ ```shell
50
+ # 构建项目
51
+ bash build.sh
52
+
53
+ # 发布到PyPI
54
+ bash publish.sh
55
+ ```
56
+
57
+ ### 4. 查看启动
58
+ ```
59
+ 本地生成 log/agent_log.log文件,且打印
60
+ INFO: Uvicorn running on http://0.0.0.0:8888 (Press CTRL+C to quit)
61
+ ```
62
+
63
+ ### 5. 集成到MCP客户端
64
+
65
+ #### curl
66
+ ```shell
67
+ http://0.0.0.0:8888/sse
68
+ ```
69
+
70
+ #### Python模块方式
71
+ ```shell
72
+ python -m minimax_qa_mcp.server
73
+ ```
74
+
75
+ #### Claude Desktop 配置
76
+ ```json
77
+ {
78
+ "agent_name": {
79
+ "command": "minimax-qa-mcp",
80
+ "args": ["--host", "0.0.0.0", "--port", "8888"]
81
+ }
82
+ }
83
+ ```
84
+
85
+ ## API 说明
86
+
87
+ ### 天气服务(demo)
88
+ - `get_alerts(state)`: 获取指定州的天气警报
89
+ - `get_forecast(latitude, longitude)`: 获取指定位置的天气预报
90
+
91
+ ### 日志服务
92
+ - `get_grafana_data(scene, psm, msg, from_time, to_time)`: 获取业务的grafana日志
93
+ - `get_top_methods(scene, psm)`: 获取服务存在调用的接口列表
94
+ - `get_http_data(scene, psm, api_path, from_time, to_time)`: 获取业务http接口流量日志
95
+ - `query_code_segments(query, query_type, limit, exact, advanced, depth, direction, output)`: 查询代码片段
96
+ - `gen_case(input_data, pwd)`: 生成link_case
97
+ - `get_weaviate_info(input_data)`: 获取业务相关信息
@@ -0,0 +1,14 @@
1
+ """
2
+ coding:utf-8
3
+ @Software: PyCharm
4
+ @Time: 2025/5/9 18:17
5
+ @Author: xingyun
6
+ """
7
+
8
+ """
9
+ minimax_qa_mcp - QA agent service 集合
10
+ """
11
+
12
+ __version__ = "0.1.0"
13
+ __author__ = "xingyun"
14
+ __all__ = []
@@ -0,0 +1,6 @@
1
+ """
2
+ coding:utf-8
3
+ @Software: PyCharm
4
+ @Time: 2024/8/20 下午5:54
5
+ @Author: xingyun
6
+ """
@@ -0,0 +1,86 @@
1
+ [common]
2
+ env = [test, prod]
3
+ business = [xingye, talkie]
4
+ grafana_url = https://mlogs.xaminim.com/api/v1/query
5
+ swing_url = http://swing-babel-ali-prod.xaminim.com/
6
+
7
+ [xingye_http_prod_business_info]
8
+ grafana_cluster = ali-shanghai-prod-01
9
+ grafana_name_space = kube-system
10
+
11
+ [talkie_http_prod_business_info]
12
+ grafana_cluster = ali-shanghai-prod-01
13
+ grafana_name_space = kube-system
14
+
15
+ [xingye_prod_business_info]
16
+ grafana_cluster = ali-shanghai-prod-01
17
+ grafana_name_space = xingye-prod
18
+
19
+ [xingye_test_business_info]
20
+ grafana_cluster = ali-shanghai-test-01
21
+ grafana_name_space = xingye-test
22
+
23
+ [talkie_prod_business_info]
24
+ grafana_cluster = ali-virginia-test-01
25
+ grafana_name_space = weaver
26
+
27
+ [talkie_test_business_info]
28
+ grafana_cluster = ali-virginia-prod-01
29
+ grafana_name_space = weaver
30
+
31
+ [hailuo_video_cn_pre_business_info]
32
+ grafana_cluster = ali-wulan-prod-01
33
+ grafana_name_space = inspo-pre
34
+
35
+ [hailuo_video_cn_prod_business_info]
36
+ grafana_cluster = ali-wulan-prod-01
37
+ grafana_name_space = inspo-prod
38
+
39
+ [hailuo_video_us_test_business_info]
40
+ grafana_cluster = ali-virginia-prod-01
41
+ grafana_name_space = moss-test
42
+
43
+ [hailuo_video_us_prod_business_info]
44
+ grafana_cluster = ali-virginia-prod-01
45
+ grafana_name_space = moss-prod
46
+
47
+ [open_platform_cn_prod_business_info]
48
+ grafana_cluster = ali-wulan-prod-01
49
+ grafana_name_space = algeng-prod
50
+
51
+ [open_platform_us_prod_business_info]
52
+ grafana_cluster = ali-virginia-prod-01
53
+ grafana_name_space = algeng-prod
54
+
55
+ [open_platform_cn_pre_business_info]
56
+ grafana_cluster = ali-wulan-prod-01
57
+ grafana_name_space = algeng-prod
58
+
59
+ [open_platform_us_pre_business_info]
60
+ grafana_cluster = ali-virginia-prod-01
61
+ grafana_name_space = algeng-prod
62
+
63
+ [weaviate_url]
64
+ url_port = http://10.11.8.37:8080
65
+ url = http://10.11.8.37
66
+ port = 8080
67
+ grpc_port = 50051
68
+
69
+
70
+ [generator_case_conf]
71
+ # 模型API URL,用于ModuleClient类调用
72
+ module_api_url = http://swing-babel-ali-prod.xaminim.com/swing/api/get_module_result
73
+ git_access_token = SrFXdGjtd3AtRVJCkpDn
74
+
75
+ # 模型超时重视
76
+ model_timeout = 200
77
+ max_workers = 10
78
+
79
+ # 各业务代码仓库地址
80
+ xingye_git_url = https://gitlab.xaminim.com/qa/apicase_generate_tool.git
81
+ xingye_branch = feat/link_case_demo
82
+
83
+ # 各业务demo case路径
84
+ xingye_link_case_demo_path = link_cases/xingye/comment/客态正常查看评论区/test_客态正常查看评论区.py
85
+ xingye_pre_demo_case_path = link_cases/xingye/comment/客态正常查看评论区/pre_客态正常查看评论区.py
86
+
@@ -0,0 +1,184 @@
1
+ # 标准库导入
2
+ import asyncio
3
+ import sys
4
+ import os
5
+
6
+ # 将项目根目录添加到Python路径中
7
+ current_dir = os.path.dirname(os.path.abspath(__file__))
8
+ project_root = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
9
+ sys.path.append(project_root)
10
+
11
+ # MCP相关导入
12
+ from mcp.server.fastmcp import FastMCP
13
+
14
+ # 本地模块导入
15
+ from minimax_qa_mcp.utils.logger import logger
16
+
17
+ from minimax_qa_mcp.src.generator_case.generator_case import GeneratorCase
18
+ from minimax_qa_mcp.src.get_weaviate_info.get_weaviate_info import GetWeaviateInfo
19
+ from minimax_qa_mcp.src.grafana.service import GetFromGrafana, GetApiFromGrafana
20
+ from minimax_qa_mcp.src.gateway_case.get_case import CaseGrafanaService
21
+ from minimax_qa_mcp.src.query_segments.query_segments import main, TYPE_API, TYPE_FUNC, TYPE_CODE, TYPE_ANY, TYPE_FUNC_DETAIL
22
+
23
+ # Initialize FastMCP server
24
+ mcp = FastMCP("mcp")
25
+
26
+
27
+ @mcp.tool()
28
+ async def get_grafana_data(scene: str, psm: str = "", msg: list = [], from_time: str = None,
29
+ to_time: str = None) -> str:
30
+ """ 获取业务的grafana日志
31
+
32
+ Args:
33
+ scene: 枚举值,可选为[xingye_prod、xingye_test、talkie_prod、talkie_test、hailuo_video_cn_pre、hailuo_video_cn_prod、hailuo_video_us_test、hailuo_video_us_prod]其中xingye为星野业务、talkie为talkie业务、hailuo_video为海螺视频业务分国内(cn)和海外(us),prod代表线上环境,test/pre代表线下环境
34
+ psm: 服务名称,可选
35
+ msg: 筛选关键字,可以是多个值的list,需要按照文本(比如trace_id)筛选日志时使用
36
+ from_time: 可选,但用户提到时间则必填,日志筛选时间区间-开始时间,时间是UTC+8标准格式,如:2025-03-17T15:22:42.885430+08:00
37
+ to_time: 可选,但用户提到时间则必填,日志筛选时间区间-结束时间,时间是UTC+8标准格式,如:2025-03-17T15:22:42.885430+08:00
38
+ """
39
+ # First get the forecast grid endpoint
40
+ resp = GetFromGrafana(scene, psm, from_time, to_time).post_grafana(msg)
41
+
42
+ return resp
43
+
44
+
45
+ @mcp.tool()
46
+ async def get_top_methods(scene: str, psm: str = "") -> list:
47
+ """ 获取服务存在调用的接口列表,以及接口基本说明
48
+
49
+ Args:
50
+ scene: 枚举值,选项列表为[xingye_rpc、talkie_rpc、xingye_http、talkie_http、hailuo_video_cn_http、hailuo_video_us_http]其中xingye为星野业务、talkie为talkie业务、hailuo_video为海螺视频业务分国内(cn)和海外(us),默认http,用户显示要求时再拼接rpc
51
+ psm: 服务名称,可选,在用户显示指定时传递
52
+ """
53
+ # First get the forecast grid endpoint
54
+ resp = GetApiFromGrafana(scene, psm).get_need_method()
55
+
56
+ return resp
57
+
58
+
59
+ @mcp.tool()
60
+ async def get_http_data(scene: str, psm: str = "", api_path: str = "", from_time: str = None,
61
+ to_time: str = None) -> str:
62
+ """ 获取业务http接口流量日志,包含req、resp等信息,会存为csv文件,返回文件访问地址
63
+
64
+ Args:
65
+ scene: 枚举值,可选为[xingye_http_prod、talkie_http_prod、hailuo_video_cn_pre、hailuo_video_cn_prod、hailuo_video_us_test、hailuo_video_us_prod]其中xingye为星野业务、talkie为talkie业务、hailuo_video为海螺视频业务分国内(cn)和海外(us),prod代表线上环境,test/pre代表线下环境
66
+ psm: 需要查询的具体服务名称,可选参数
67
+ api_path: 需要查询的接口路径,必填参数
68
+ from_time: 日志筛选时间区间-开始时间,时间是UTC+8标准格式,如:2025-03-17T15:22:42.885430+08:00
69
+ to_time: 日志筛选时间区间-结束时间,时间是UTC+8标准格式,如:2025-03-17T15:22:42.885430+08:00
70
+ """
71
+
72
+ # 调用并行处理方法
73
+ results = CaseGrafanaService(scene, psm, from_time, to_time).process_qps_file(api_path)
74
+ return {"file_path": results}
75
+
76
+
77
+ @mcp.tool()
78
+ async def query_code_segments(query: str, query_type: str = None, limit: int = 10, exact: bool = False,
79
+ advanced: bool = False,
80
+ depth: int = 1, direction: str = "both", output: str = None) -> dict:
81
+ """ 查询代码片段,支持多种查询模式
82
+
83
+ Args:
84
+ query: 查询的内容,可以是API路径、函数名、包名、文件路径或其他代码内容
85
+ query_type: 查询类型,可选值:API(接口定义), FUNC(函数调用关系), CODE(代码变动的影响), FUNC_DETAIL(函数详情), ANY(所有类型,默认)
86
+ -- API:接口定义的说明
87
+ -- FUNC:函数之间的调用关系
88
+ -- CODE:代码变动带来的影响
89
+ -- FUNC_DETAIL:函数的具体实现
90
+ -- ANY:模糊匹配,所有可能的结果返回
91
+
92
+ limit: 返回结果的最大数量,默认10条
93
+ exact: 是否精确匹配,默认False表示模糊匹配
94
+ advanced: 使用高级代码影响分析,仅在查询类型为CODE时有效
95
+ depth: 调用链深度,默认为1层,仅在查询类型为FUNC时有效
96
+ direction: 调用链方向,可选值:caller(调用者), callee(被调用者), both(双向),仅在查询类型为FUNC时有效
97
+ output: 输出文件路径,用于保存函数调用图谱,仅在查询类型为FUNC时有效
98
+
99
+ 返回值说明:
100
+ - 当查询API时: 返回API的路径、入参、出参和实现逻辑
101
+ - 当查询函数时: 返回函数的调用链关系,谁调用了此函数,此函数调用了谁
102
+ - 当查询代码片段时: 返回代码影响的函数列表
103
+ - 当模糊查询时: 返回按类型分组的查询结果
104
+ - 当查询函数详情时(FUNC_DETAIL): 返回函数的详细实现代码、所在文件位置及调用关系
105
+ """
106
+ # 转换query_type参数
107
+ if query_type:
108
+ query_type = query_type.upper()
109
+ # 确保query_type是有效值
110
+ if query_type not in [TYPE_API, TYPE_FUNC, TYPE_CODE, TYPE_ANY, TYPE_FUNC_DETAIL]:
111
+ query_type = None
112
+
113
+ # 调用main函数处理查询
114
+ result = main(
115
+ input_content=query,
116
+ input_type=query_type,
117
+ limit=limit,
118
+ exact=exact,
119
+ depth=depth,
120
+ direction=direction,
121
+ advanced=advanced,
122
+ output=output
123
+ )
124
+
125
+ return result
126
+
127
+
128
+ @mcp.tool()
129
+ async def gen_case(input_data: dict, pwd: str) -> list:
130
+ """
131
+ link_case 生成
132
+ Args:
133
+ input_data: JSON格式的输入数据,包含Business、API和Case信息
134
+ pwd: 用户当前的目录地址
135
+ Return:
136
+ 列表,模型返回的具体信息以及具体需要保存的路径地址,[{"pre_case_dir": "xxxxx", "pre_case_result", "case_dir": "xxx", "case_result": "xxx"}]
137
+ pre_case_dir:前置case需要保存的地址,你需要创建这个文件并写入:pre_case_result的内容
138
+ case_dir:真正case需要保存的地址,你需要创建这个文件并写入:case_result的内容
139
+ """
140
+ # 在线程池中执行阻塞操作
141
+ import concurrent.futures
142
+ loop = asyncio.get_running_loop()
143
+ with concurrent.futures.ThreadPoolExecutor() as pool:
144
+ generator = GeneratorCase(input_data, pwd)
145
+ logger.info(f"===== The input params is :{input_data}, pwd is :{pwd}")
146
+ result = await loop.run_in_executor(pool, generator.generator_case)
147
+ return result
148
+
149
+
150
+ @mcp.tool()
151
+ async def get_weaviate_info(input_data: str) -> dict:
152
+ """
153
+ 检索知识库 获取业务相关信息
154
+ Args:
155
+ input_data: str,用户问题
156
+ Return:
157
+ 业务信息
158
+ """
159
+ weaviate_client = GetWeaviateInfo(input_data)
160
+ result = weaviate_client.get_knowledge()
161
+ return result
162
+
163
+
164
+ def main():
165
+ print("Starting Minimax QA MCP server")
166
+ """Run the Minimax QA MCP server"""
167
+ mcp.run()
168
+
169
+
170
+ def run_server():
171
+ """命令行入口点函数,用于PyPI包安装后的命令行调用"""
172
+ # 确保当前工作目录在sys.path中
173
+ if os.getcwd() not in sys.path:
174
+ sys.path.insert(0, os.getcwd())
175
+
176
+ # 输出启动信息
177
+ print("Starting Minimax QA MCP server from CLI")
178
+
179
+ # 调用主函数
180
+ main()
181
+
182
+
183
+ if __name__ == "__main__":
184
+ main()
File without changes
@@ -0,0 +1,6 @@
1
+ """
2
+ coding:utf-8
3
+ @Software: PyCharm
4
+ @Time: 2025/4/10 15:12
5
+ @Author: xingyun
6
+ """