mm-qa-mcp 0.2.0__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/__init__.py +14 -0
- minimax_qa_mcp/conf/__init__.py +6 -0
- minimax_qa_mcp/conf/conf.ini +86 -0
- minimax_qa_mcp/server.py +184 -0
- minimax_qa_mcp/src/__init__.py +0 -0
- minimax_qa_mcp/src/demo_langchain/__init__.py +6 -0
- minimax_qa_mcp/src/demo_langchain/langchain_demo.py +1 -0
- minimax_qa_mcp/src/gateway_case/__init__.py +0 -0
- minimax_qa_mcp/src/gateway_case/get_case.py +608 -0
- minimax_qa_mcp/src/generator_case/__init__.py +6 -0
- minimax_qa_mcp/src/generator_case/generator_case.py +1187 -0
- minimax_qa_mcp/src/generator_case/generator_case_langchain.py +1078 -0
- minimax_qa_mcp/src/get_weaviate_info/__init__.py +6 -0
- minimax_qa_mcp/src/get_weaviate_info/get_weaviate_info.py +298 -0
- minimax_qa_mcp/src/grafana/__init__.py +0 -0
- minimax_qa_mcp/src/grafana/service.py +104 -0
- minimax_qa_mcp/src/query_segments/__init__.py +6 -0
- minimax_qa_mcp/src/query_segments/query_segments.py +2848 -0
- minimax_qa_mcp/src/xmind2markdown/__init__.py +6 -0
- minimax_qa_mcp/src/xmind2markdown/xmind_to_markdown.py +976 -0
- minimax_qa_mcp/utils/__init__.py +0 -0
- minimax_qa_mcp/utils/logger.py +38 -0
- minimax_qa_mcp/utils/utils.py +246 -0
- mm_qa_mcp-0.2.0.dist-info/METADATA +167 -0
- mm_qa_mcp-0.2.0.dist-info/RECORD +28 -0
- mm_qa_mcp-0.2.0.dist-info/WHEEL +5 -0
- mm_qa_mcp-0.2.0.dist-info/entry_points.txt +2 -0
- mm_qa_mcp-0.2.0.dist-info/top_level.txt +1 -0
@@ -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
|
+
|
minimax_qa_mcp/server.py
ADDED
@@ -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 @@
|
|
1
|
+
|
File without changes
|