1
- <h1 align =" center " >XiYan MCP Server </h1 >
1
+ <h1 align =" center " >XiYan MCP 服务器 </h1 >
2
2
<p align =" center " >
3
3
<a href =" https://github.com/XGenerationLab/XiYan-SQL " ><img alt =" MCP Playwright " src =" https://raw.githubusercontent.com/XGenerationLab/XiYan-SQL/main/xiyanGBI.png " height =" 60 " /></a >
4
4
</p >
5
5
<p align =" center " >
6
- <b >一个模型上下文协议 (MCP) 服务器,支持自然语言查询数据库 </b ></br >
7
- <sub >由 <a href =" https://github.com/XGenerationLab/XiYan-SQL " >XiYan-SQL</a > 提供支持,Test-to-SQL公开基准上的SOTA </sub >
6
+ <b >一个允许自然语言查询数据库的模型上下文协议 (MCP) 服务器</b ></br >
7
+ <sub >基于 <a href =" https://github.com/XGenerationLab/XiYan-SQL " >XiYan-SQL</a >,在开放基准上达到文本到 SQL 的最新技术水平 </sub >
8
8
</p >
9
9
10
10
<p align =" center " >
11
11
💻 <a href =" https://github.com/XGenerationLab/xiyan_mcp_server " >XiYan-mcp-server</a > |
12
- 🌐 <a href =" https://github.com/XGenerationLab/XiYan-SQL " >XiYan-SQL</a > |
12
+ 🌐 <a href =" https://github.com/XGenerationLab/https://github.com/XGenerationLab/ XiYan-SQL " >XiYan-SQL</a > |
13
13
📖 <a href =" https://arxiv.org/abs/2411.08599 " > Arxiv</a > |
14
14
📄 <a href =" https://paperswithcode.com/paper/xiyan-sql-a-multi-generator-ensemble " >PapersWithCode</a > |
15
15
💻 <a href =" https://huggingface.co/collections/XGenerationLab/xiyansql-models-67c9844307b49f87436808fc " >HuggingFace</a > |
20
20
<img src =" https://img.shields.io/badge/License-Apache%202.0-blue.svg " alt =" License: Apache 2.0 " />
21
21
</a >
22
22
<a href =" https://pepy.tech/projects/xiyan-mcp-server " ><img src =" https://static.pepy.tech/badge/xiyan-mcp-server " alt =" PyPI 下载量 " ></a >
23
- <a href =" https://smithery.ai/server/@XGenerationLab/xiyan_mcp_server " ><img alt =" Smithery 安装量 " src =" https://smithery.ai/badge/@XGenerationLab/xiyan_mcp_server " height =" 20 " /></a >
23
+ <a href =" https://smithery.ai/server/@XGenerationLab/xiyan_mcp_server " ><img alt =" Smithery 安装次数 " src =" https://smithery.ai/badge/@XGenerationLab/xiyan_mcp_server " height =" 20 " /></a >
24
24
<a href =" https://github.com/XGenerationLab/xiyan_mcp_server " target =" _blank " >
25
25
<img src="https://img.shields.io/github/stars/XGenerationLab/xiyan_mcp_server?style=social" alt="GitHub stars" />
26
26
</a >
27
27
<br />
28
- <a href =" https://github.com/XGenerationLab/xiyan_mcp_server " >English</a > | <a href =" https://github.com/XGenerationLab/xiyan_mcp_server/blob/main/README_zh.md " > 中文 </a ><br />
28
+ <a href =" https://github.com/XGenerationLab/xiyan_mcp_server " >English</a > | <a href =" https://github.com/XGenerationLab/xiyan_mcp_server/blob/main/README_zh.md " >中文 </a ><br />
29
29
<a href =" https://github.com/XGenerationLab/xiyan_mcp_server/blob/main/imgs/dinggroup_out.png " >钉钉群</a >|
30
- <a href =" https://weibo.com/u/2540915670 " target =" _blank " >在微博上关注我 </a >
30
+ <a href =" https://weibo.com/u/2540915670 " target =" _blank " >在微博关注我 </a >
31
31
</p >
32
32
33
33
## 目录
45
45
- [ 数据库配置] ( #database-configuration )
46
46
- [ 启动] ( #launch )
47
47
- [ Claude 桌面] ( #claude-desktop )
48
+ - [ Cline] ( #cline )
48
49
- [ Goose] ( #goose )
50
+ - [ Cursor] ( #cursor )
49
51
- [ 引用] ( #citation )
50
52
51
53
## 功能
52
- - 🌐 通过 [ XiYanSQL] ( https://github.com/XGenerationLab/XiYan-SQL ) 以自然语言提取数据
54
+ - 🌐 通过 [ XiYanSQL] ( https://github.com/XGenerationLab/XiYan-SQL ) 以自然语言获取数据
53
55
- 🖱️ 列出可用的 MySQL 表作为资源
54
56
- 🔧 读取表内容
55
57
56
58
## 工具预览
57
- - 工具 `` get_data_via_natural_language `` 提供从数据库检索数据的自然语言接口 。该服务器将输入的自然语言转换为 SQL,并调用数据库返回查询结果 。
59
+ - 工具 `` get_data_via_natural_language `` 提供了一个自然语言接口,用于从数据库中检索数据 。该服务器将输入的自然语言转换为 SQL,使用内置模型并调用数据库返回查询结果 。
58
60
59
- - `` mysql://{table_name} `` 资源允许在指定特定的表名时,从数据库获取一部分样本数据以供模型参考 。
60
- - `` mysql:// `` 资源将列出当前数据库的名称
61
+ - `` mysql://{table_name} `` 资源允许在指定特定表名时,从数据库获取部分示例数据以供模型参考 。
62
+ - `` mysql:// `` 资源将列出当前数据库的名称。
61
63
62
64
## 安装
63
65
### 通过 pip 安装
64
66
65
- 需要 Python 3.11 及以上版本 。
67
+ 需要 Python 3.11 或更高版本 。
66
68
您可以通过 pip 安装服务器,它将安装最新版本。
67
69
68
70
``` bash
69
71
pip install xiyan-mcp-server
70
72
```
71
73
72
- 之后您可以直接运行服务器 :
74
+ 然后您可以直接运行服务器 :
73
75
``` bash
74
76
python -m xiyan_mcp_server
75
77
```
76
- 但是在您完成后续配置之前,它不会提供任何功能 。
77
- 您将获得一个 yml 文件。之后您可以通过以下命令运行服务器 :
78
+ 但在完成以下配置之前,它不提供任何功能 。
79
+ 您将获得一个 yml 文件。之后,您可以通过以下方式运行服务器 :
78
80
``` yaml
79
81
env YML=path/to/yml python -m xiyan_mcp_server
80
82
```
81
83
82
84
### 通过 Smithery.ai 安装
83
85
请参见 [ @XGenerationLab /xiyan_mcp_server] ( https://smithery.ai/server/@XGenerationLab/xiyan_mcp_server )
84
86
85
- 尚未全面测试 。
87
+ 未完全测试 。
86
88
87
89
## 配置
88
90
89
91
您需要一个 yml 配置文件来配置服务器。
90
- 在 config_demo.yml 中提供了一个默认配置文件,内容如下 :
92
+ 提供了一个默认配置文件 config_demo.yml,格式如下 :
91
93
92
94
``` yaml
93
95
model :
94
- name : " pre-xiyansql-qwencoder-32b "
96
+ name : " XGenerationLab/XiYanSQL-QwenCoder-32B-2412 "
95
97
key : " "
96
- url : " https://pre-xiyan-stream.biz.aliyun.com/service/api/xiyan-sql "
98
+ url : " https://api-inference.modelscope.cn/v1/ "
97
99
98
100
database :
99
101
host : " localhost"
@@ -104,57 +106,83 @@ database:
104
106
` ` `
105
107
106
108
### LLM 配置
107
- ` ` Name` ` 是要使用的模型的名称,` ` key` ` 是模型的 API 密钥,` ` url` ` 是模型的 API 地址。我们支持以下模型。
109
+ ` ` Name` ` 是要使用的模型名称, ` ` key` ` 是该模型的 API 密钥, ` ` url` ` 是该模型的 API 地址。我们支持以下模型。
110
+
111
+ | 版本 | 通用 LLM(GPT,qwenmax) | Modelscope 的 SOTA 模型 | Dashscope 的 SOTA 模型 |
112
+ |----------|-------------------------------|--------------------------------------------|-----------------------------------------------------------|
113
+ | 描述 | 基本,易于使用 | 性能最佳,稳定,推荐 | 性能最佳,供试用 |
114
+ | 名称 | 官方模型名称(例如 gpt-3.5-turbo,qwen-max) | XGenerationLab/XiYanSQL-QwenCoder-32B-2412 | xiyansql-qwencoder-32b |
115
+ | 密钥 | 服务提供商的 API 密钥(例如 OpenAI,阿里云) | Modelscope 的 API 密钥 | 通过邮件获得的 API 密钥 |
116
+ | url | 服务提供商的端点(例如 "https://api.openai.com/v1") | https://api-inference.modelscope.cn/v1/ | https://xiyan-stream.biz.aliyun.com/service/api/xiyan-sql |
117
+
108
118
#### 通用 LLM
109
- 如果您想使用通用 LLM,比如 gpt3.5,您可以直接配置如下:
119
+ 如果您想使用通用 LLM,例如 gpt3.5,您可以直接配置如下:
110
120
` ` ` yaml
111
121
model :
112
122
name : " gpt-3.5-turbo"
113
- key : " 您的密钥 "
123
+ key : " YOUR KEY "
114
124
url : " https://api.openai.com/v1"
115
125
database :
116
126
` ` `
117
127
118
- 如果您想使用阿里巴巴的 Qwen,例如 Qwen-max,您可以使用以下配置。
128
+ 如果您想使用来自阿里巴巴的 Qwen,例如 Qwen-max,您可以使用以下配置。
119
129
` ` ` yaml
120
130
model :
121
131
name : " qwen-max"
122
- key : " 您的密钥 "
132
+ key : " YOUR KEY "
123
133
url : " https://dashscope.aliyuncs.com/compatible-mode/v1"
124
134
database :
125
135
` ` `
136
+
126
137
#### 文本到 SQL SOTA 模型
127
- 最后,我们推荐使用 XiYanSQL-qwencoder-32B (https://github.com/XGenerationLab/XiYanSQL-QwenCoder),这是文本到 SQL 的 SOTA 模型,见 [Bird benchmark](https://bird-bench.github.io/)。
138
+ 我们推荐 XiYanSQL-qwencoder-32B (https://github.com/XGenerationLab/XiYanSQL-QwenCoder),这是文本到 SQL 的 SOTA 模型,参见 [Bird benchmark](https://bird-bench.github.io/)。
139
+ 使用该模型有两种方式。您可以使用任一个。
140
+ (1) [Modelscope](https://www.modelscope.cn/models/XGenerationLab/XiYanSQL-QwenCoder-32B-2412),(2) 阿里云 DashScope。
141
+
142
+ ##### (1) Modelscope 版本
143
+ 您需要从 Modelscope 申请 ` ` key` ` 用于 API推断,网址:https://www.modelscope.cn/docs/model-service/API-Inference/intro。
144
+ 然后可以使用以下配置:
145
+ ` ` ` yaml
146
+ model :
147
+ name : " XGenerationLab/XiYanSQL-QwenCoder-32B-2412"
148
+ key : " "
149
+ url : " https://api-inference.modelscope.cn/v1/"
150
+ ` ` `
151
+
152
+ 阅读我们的 [模型描述](https://www.modelscope.cn/models/XGenerationLab/XiYanSQL-QwenCoder-32B-2412) 获取更多细节。
153
+
154
+ ##### (2) Dashscope 版本
155
+
128
156
我们在阿里云 DashScope 上部署了该模型,因此您需要设置以下环境变量:
129
- 请发送您的电子邮件以获取 ` ` key` ` 。 ( godot.lzl@alibaba-inc.com )
130
- 在电子邮件中 ,请附上以下信息:
157
+ 请发送您的电子邮件以获取 ` ` key` ` 。 (godot.lzl@alibaba-inc.com)
158
+ 在邮件中 ,请附上以下信息:
131
159
` ` ` yaml
132
- name : " 您的姓名 " ,
133
- email : " 您的电子邮件 " ,
134
- organization : " 您所在的学校或公司或组织 "
160
+ name : " YOUR NAME " ,
161
+ email : " YOUR EMAIL " ,
162
+ organization : " 您的学院或公司或组织 "
135
163
` ` `
136
- 我们将根据您的电子邮件发送给您一个 ` ` key` ` 。您可以将该 ` ` key` ` 填写在 yml 文件中。
137
- 该 ` ` key` ` 将在一个月或 200 查询或其他法律限制下过期 。
164
+ 我们将根据您的电子邮件发送给您一个 ` ` key` ` 。您可以将 ` ` key` ` 填入 yml 文件中。
165
+ 该 ` ` key` ` 将在 1 个月或 200 次查询或其他法律限制后过期 。
138
166
139
167
` ` ` yaml
140
168
model :
141
- name : " pre- xiyansql-qwencoder-32b"
142
- key : " 密钥 "
143
- url : " https://pre- xiyan-stream.biz.aliyun.com/service/api/xiyan-sql"
169
+ name : " xiyansql-qwencoder-32b"
170
+ key : " KEY "
171
+ url : " https://xiyan-stream.biz.aliyun.com/service/api/xiyan-sql"
144
172
database :
145
173
` ` `
146
174
147
175
注意:该模型服务仅供试用,如果您需要在生产环境中使用,请与我们联系。
148
176
149
- 或者,您也可以在自己的服务器上部署模型 [XiYanSQL-qwencoder-32B](https://github.com/XGenerationLab/XiYanSQL-QwenCoder)。
177
+ 另外,您也可以在自己的服务器上部署 [XiYanSQL-qwencoder-32B](https://github.com/XGenerationLab/XiYanSQL-QwenCoder)。
150
178
151
179
#### 本地 LLM
152
- 未来将支持 。
180
+ 将来支持 。
153
181
154
182
### 数据库配置
155
- ` ` host` ` , ` ` port` ` , ` ` user` ` , ` ` password` ` , ` ` database` ` 是 MySQL 数据库的连接信息。
183
+ ` ` host` ` 、 ` ` port` ` 、 ` ` user` ` 、 ` ` password` ` 、 ` ` database` ` 是 MySQL 数据库的连接信息。
156
184
157
- 您可以使用本地或任何远程数据库。现在我们支持 MySQL(更多方言将在不久的将来支持 )。
185
+ 您可以使用本地或任何远程数据库。现在我们支持 MySQL(更多方言即将推出 )。
158
186
159
187
` ` ` yaml
160
188
database :
@@ -184,15 +212,21 @@ database:
184
212
}
185
213
}
186
214
```
215
+ ### Cline
216
+ 准备与 [ Claude 桌面] ( #claude-desktop ) 类似的配置。
217
+
187
218
### Goose
188
- 在配置中添加以下命令。
219
+ 在配置中添加以下命令:
189
220
190
221
``` yaml
191
222
env YML=path/to/yml python -m xiyan_mcp_server
192
223
```
193
224
225
+ ### Cursor
226
+ 使用与 [ Goose] ( #goose ) 相同的命令。
227
+
194
228
## 引用
195
- 如果您觉得我们的工作对您有帮助 ,请随时引用我们。
229
+ 如果您发现我们的工作对您有帮助 ,请随时引用我们。
196
230
``` bib
197
231
@article{xiyansql,
198
232
title={A Preview of XiYan-SQL: A Multi-Generator Ensemble Framework for Text-to-SQL},
0 commit comments