1- <h1 align =" center " >XiYan MCP Server </h1 >
1+ <h1 align =" center " >XiYan MCP 服务器 </h1 >
22<p align =" center " >
33 <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 >
44</p >
55<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 >
88</p >
99
1010<p align =" center " >
1111💻 <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 > |
1313📖 <a href =" https://arxiv.org/abs/2411.08599 " > Arxiv</a > |
1414📄 <a href =" https://paperswithcode.com/paper/xiyan-sql-a-multi-generator-ensemble " >PapersWithCode</a > |
1515💻 <a href =" https://huggingface.co/collections/XGenerationLab/xiyansql-models-67c9844307b49f87436808fc " >HuggingFace</a > |
2020 <img src =" https://img.shields.io/badge/License-Apache%202.0-blue.svg " alt =" License: Apache 2.0 " />
2121</a >
2222<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 >
2424<a href =" https://github.com/XGenerationLab/xiyan_mcp_server " target =" _blank " >
2525 <img src="https://img.shields.io/github/stars/XGenerationLab/xiyan_mcp_server?style=social" alt="GitHub stars" />
2626</a >
2727<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 />
2929<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 >
3131</p >
3232
3333## 目录
4545 - [ 数据库配置] ( #database-configuration )
4646- [ 启动] ( #launch )
4747 - [ Claude 桌面] ( #claude-desktop )
48+ - [ Cline] ( #cline )
4849 - [ Goose] ( #goose )
50+ - [ Cursor] ( #cursor )
4951- [ 引用] ( #citation )
5052
5153## 功能
52- - 🌐 通过 [ XiYanSQL] ( https://github.com/XGenerationLab/XiYan-SQL ) 以自然语言提取数据
54+ - 🌐 通过 [ XiYanSQL] ( https://github.com/XGenerationLab/XiYan-SQL ) 以自然语言获取数据
5355- 🖱️ 列出可用的 MySQL 表作为资源
5456- 🔧 读取表内容
5557
5658## 工具预览
57- - 工具 `` get_data_via_natural_language `` 提供从数据库检索数据的自然语言接口 。该服务器将输入的自然语言转换为 SQL,并调用数据库返回查询结果 。
59+ - 工具 `` get_data_via_natural_language `` 提供了一个自然语言接口,用于从数据库中检索数据 。该服务器将输入的自然语言转换为 SQL,使用内置模型并调用数据库返回查询结果 。
5860
59- - `` mysql://{table_name} `` 资源允许在指定特定的表名时,从数据库获取一部分样本数据以供模型参考 。
60- - `` mysql:// `` 资源将列出当前数据库的名称
61+ - `` mysql://{table_name} `` 资源允许在指定特定表名时,从数据库获取部分示例数据以供模型参考 。
62+ - `` mysql:// `` 资源将列出当前数据库的名称。
6163
6264## 安装
6365### 通过 pip 安装
6466
65- 需要 Python 3.11 及以上版本 。
67+ 需要 Python 3.11 或更高版本 。
6668您可以通过 pip 安装服务器,它将安装最新版本。
6769
6870``` bash
6971pip install xiyan-mcp-server
7072```
7173
72- 之后您可以直接运行服务器 :
74+ 然后您可以直接运行服务器 :
7375``` bash
7476python -m xiyan_mcp_server
7577```
76- 但是在您完成后续配置之前,它不会提供任何功能 。
77- 您将获得一个 yml 文件。之后您可以通过以下命令运行服务器 :
78+ 但在完成以下配置之前,它不提供任何功能 。
79+ 您将获得一个 yml 文件。之后,您可以通过以下方式运行服务器 :
7880``` yaml
7981env YML=path/to/yml python -m xiyan_mcp_server
8082```
8183
8284### 通过 Smithery.ai 安装
8385请参见 [ @XGenerationLab /xiyan_mcp_server] ( https://smithery.ai/server/@XGenerationLab/xiyan_mcp_server )
8486
85- 尚未全面测试 。
87+ 未完全测试 。
8688
8789## 配置
8890
8991您需要一个 yml 配置文件来配置服务器。
90- 在 config_demo.yml 中提供了一个默认配置文件,内容如下 :
92+ 提供了一个默认配置文件 config_demo.yml,格式如下 :
9193
9294``` yaml
9395model :
94- name : " pre-xiyansql-qwencoder-32b "
96+ name : " XGenerationLab/XiYanSQL-QwenCoder-32B-2412 "
9597 key : " "
96- url : " https://pre-xiyan-stream.biz.aliyun.com/service/api/xiyan-sql "
98+ url : " https://api-inference.modelscope.cn/v1/ "
9799
98100database :
99101 host : " localhost"
@@ -104,57 +106,83 @@ database:
104106` ` `
105107
106108### 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+
108118#### 通用 LLM
109- 如果您想使用通用 LLM,比如 gpt3.5,您可以直接配置如下:
119+ 如果您想使用通用 LLM,例如 gpt3.5,您可以直接配置如下:
110120` ` ` yaml
111121model :
112122 name : " gpt-3.5-turbo"
113- key : " 您的密钥 "
123+ key : " YOUR KEY "
114124 url : " https://api.openai.com/v1"
115125database :
116126` ` `
117127
118- 如果您想使用阿里巴巴的 Qwen,例如 Qwen-max,您可以使用以下配置。
128+ 如果您想使用来自阿里巴巴的 Qwen,例如 Qwen-max,您可以使用以下配置。
119129` ` ` yaml
120130model :
121131 name : " qwen-max"
122- key : " 您的密钥 "
132+ key : " YOUR KEY "
123133 url : " https://dashscope.aliyuncs.com/compatible-mode/v1"
124134database :
125135` ` `
136+
126137#### 文本到 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+
128156我们在阿里云 DashScope 上部署了该模型,因此您需要设置以下环境变量:
129- 请发送您的电子邮件以获取 ` ` key` ` 。 ( godot.lzl@alibaba-inc.com )
130- 在电子邮件中 ,请附上以下信息:
157+ 请发送您的电子邮件以获取 ` ` key` ` 。 (godot.lzl@alibaba-inc.com)
158+ 在邮件中 ,请附上以下信息:
131159` ` ` yaml
132- name : " 您的姓名 " ,
133- email : " 您的电子邮件 " ,
134- organization : " 您所在的学校或公司或组织 "
160+ name : " YOUR NAME " ,
161+ email : " YOUR EMAIL " ,
162+ organization : " 您的学院或公司或组织 "
135163` ` `
136- 我们将根据您的电子邮件发送给您一个 ` ` key` ` 。您可以将该 ` ` key` ` 填写在 yml 文件中。
137- 该 ` ` key` ` 将在一个月或 200 查询或其他法律限制下过期 。
164+ 我们将根据您的电子邮件发送给您一个 ` ` key` ` 。您可以将 ` ` key` ` 填入 yml 文件中。
165+ 该 ` ` key` ` 将在 1 个月或 200 次查询或其他法律限制后过期 。
138166
139167` ` ` yaml
140168model :
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"
144172database :
145173` ` `
146174
147175注意:该模型服务仅供试用,如果您需要在生产环境中使用,请与我们联系。
148176
149- 或者,您也可以在自己的服务器上部署模型 [XiYanSQL-qwencoder-32B](https://github.com/XGenerationLab/XiYanSQL-QwenCoder)。
177+ 另外,您也可以在自己的服务器上部署 [XiYanSQL-qwencoder-32B](https://github.com/XGenerationLab/XiYanSQL-QwenCoder)。
150178
151179#### 本地 LLM
152- 未来将支持 。
180+ 将来支持 。
153181
154182### 数据库配置
155- ` ` host` ` , ` ` port` ` , ` ` user` ` , ` ` password` ` , ` ` database` ` 是 MySQL 数据库的连接信息。
183+ ` ` host` ` 、 ` ` port` ` 、 ` ` user` ` 、 ` ` password` ` 、 ` ` database` ` 是 MySQL 数据库的连接信息。
156184
157- 您可以使用本地或任何远程数据库。现在我们支持 MySQL(更多方言将在不久的将来支持 )。
185+ 您可以使用本地或任何远程数据库。现在我们支持 MySQL(更多方言即将推出 )。
158186
159187` ` ` yaml
160188database :
@@ -184,15 +212,21 @@ database:
184212 }
185213}
186214```
215+ ### Cline
216+ 准备与 [ Claude 桌面] ( #claude-desktop ) 类似的配置。
217+
187218### Goose
188- 在配置中添加以下命令。
219+ 在配置中添加以下命令:
189220
190221``` yaml
191222env YML=path/to/yml python -m xiyan_mcp_server
192223```
193224
225+ ### Cursor
226+ 使用与 [ Goose] ( #goose ) 相同的命令。
227+
194228## 引用
195- 如果您觉得我们的工作对您有帮助 ,请随时引用我们。
229+ 如果您发现我们的工作对您有帮助 ,请随时引用我们。
196230``` bib
197231@article{xiyansql,
198232 title={A Preview of XiYan-SQL: A Multi-Generator Ensemble Framework for Text-to-SQL},
0 commit comments