|
| 1 | +[💻 XiYan-mcp-server](https://github.com/XGenerationLab/xiyan_mcp_server) | |
| 2 | +[💻 XiYan-SQL](https://github.com/XGenerationLab/XiYan-SQL) | |
| 3 | +[📖 Arxiv](https://arxiv.org/abs/2411.08599) | |
| 4 | +[📄 PapersWithCode](https://paperswithcode.com/paper/xiyan-sql-a-multi-generator-ensemble) |
| 5 | + |
| 6 | +[](https://smithery.ai/server/@XGenerationLab/xiyan_mcp_server) |
| 7 | + |
| 8 | +[English](https://github.com/XGenerationLab/xiyan_mcp_server) | [中文](https://github.com/XGenerationLab/xiyan_mcp_server/README_zh.md) |
| 9 | + |
| 10 | +# XiYan MCP 服务器 |
| 11 | + |
| 12 | +一个模型上下文协议(MCP)服务器,支持通过自然语言查询数据库,使用 [XiYanSQL](https://github.com/XGenerationLab/XiYan-SQL) 作为文本到 SQL 的技术。 |
| 13 | + |
| 14 | +我们目前支持 MySQL 数据库,更多方言即将推出。 |
| 15 | + |
| 16 | +## 特性 |
| 17 | +- 通过 [XiYanSQL](https://github.com/XGenerationLab/XiYan-SQL) 以自然语言获取数据 |
| 18 | +- 列出可用的 MySQL 表作为资源 |
| 19 | +- 读取表内容 |
| 20 | + |
| 21 | +## 安装 |
| 22 | + |
| 23 | +需要 Python 3.11 或更高版本。 |
| 24 | +您可以通过 pip 安装该服务器,它将安装最新版本。 |
| 25 | + |
| 26 | +```bash |
| 27 | +pip install xiyan-mcp-server |
| 28 | +``` |
| 29 | + |
| 30 | +安装后,您可以直接运行服务器: |
| 31 | +```bash |
| 32 | +python -m xiyan-mcp-server |
| 33 | +``` |
| 34 | +但在完成以下配置之前,它将不提供任何功能。您将获得一个 yml 文件。之后,您可以通过以下方式运行服务器: |
| 35 | +```yaml |
| 36 | +env YML=path/to/yml python -m xiyan-mcp-server |
| 37 | +``` |
| 38 | + |
| 39 | +## 配置 |
| 40 | + |
| 41 | +您需要一个 yml 配置文件来配置服务器。 |
| 42 | +默认配置文件在 `config_demo.yml` 中提供,其内容如下: |
| 43 | + |
| 44 | +```yaml |
| 45 | +model: |
| 46 | + name: "pre-xiyan_multi_dialect_v3" |
| 47 | + key: "" |
| 48 | + url: "https://poc-dashscope.aliyuncs.com/compatible-mode/v1" |
| 49 | + |
| 50 | +database: |
| 51 | + host: "localhost" |
| 52 | + port: 3306 |
| 53 | + user: "root" |
| 54 | + password: "" |
| 55 | + database: "" |
| 56 | +``` |
| 57 | +
|
| 58 | +### 关于 LLM |
| 59 | +``Name`` 是要使用的模型名称,``key`` 是模型的 API 密钥,``url`` 是模型的 API 地址。我们支持以下模型。 |
| 60 | +#### 使用通用 LLM |
| 61 | +如果您想使用通用 LLM,例如 gpt3.5,您可以直接如下配置: |
| 62 | +```yaml |
| 63 | +model: |
| 64 | + name: "gpt-3.5-turbo" |
| 65 | + key: "YOUR KEY" |
| 66 | + url: "https://api.openai.com/v1/chat/completions" |
| 67 | +database: |
| 68 | +``` |
| 69 | +
|
| 70 | +如果您想使用阿里巴巴的 Qwen,例如 Qwen-max: |
| 71 | +```yaml |
| 72 | +model: |
| 73 | + name: "qwen-max" |
| 74 | + key: "YOUR KEY" |
| 75 | + url: "https://dashscope.aliyuncs.com/compatible-mode/v1" |
| 76 | +database: |
| 77 | +``` |
| 78 | +
|
| 79 | +#### 使用文本到 SQL 的 SOTA 模型 |
| 80 | +最后,我们推荐使用 XiYanSQL-qwencoder-32B (https://github.com/XGenerationLab/XiYanSQL-QwenCoder),这是text-to-SQL 的 SOTA 模型。 |
| 81 | +我们将模型部署在 DashScope 上,因此您需要设置以下环境变量: |
| 82 | +请联系我们以获取 ``key``。 |
| 83 | +```yaml |
| 84 | +model: |
| 85 | + name: "pre-xiyan_multi_dialect_v3" |
| 86 | + key: "KEY" |
| 87 | + url: "https://poc-dashscope.aliyuncs.com/compatible-mode/v1" |
| 88 | +database: |
| 89 | +``` |
| 90 | +
|
| 91 | +#### 本地 LLM |
| 92 | +
|
| 93 | +未来将支持。 |
| 94 | +
|
| 95 | +### 关于数据库 |
| 96 | +``host``, ``port``, ``user``, ``password``, ``database`` 是 MySQL 数据库的连接信息。 |
| 97 | +
|
| 98 | +您可以使用本地或任何远程数据库。现在我们支持 MySQL(即将支持更多方言)。 |
| 99 | +
|
| 100 | +```yaml |
| 101 | +database: |
| 102 | + host: "localhost" |
| 103 | + port: 3306 |
| 104 | + user: "root" |
| 105 | + password: "" |
| 106 | + database: "" |
| 107 | +``` |
| 108 | +
|
| 109 | +## 引用 |
| 110 | +如果您觉得我们的工作有帮助,请随意引用我们。 |
| 111 | +```bib |
| 112 | +@article{xiyansql, |
| 113 | + title={A Preview of XiYan-SQL: A Multi-Generator Ensemble Framework for Text-to-SQL}, |
| 114 | + author={Yingqi Gao and Yifu Liu and Xiaoxia Li and Xiaorong Shi and Yin Zhu and Yiming Wang and Shiqi Li and Wei Li and Yuntao Hong and Zhiling Luo and Jinyang Gao and Liyu Mou and Yu Li}, |
| 115 | + year={2024}, |
| 116 | + journal={arXiv preprint arXiv:2411.08599}, |
| 117 | + url={https://arxiv.org/abs/2411.08599}, |
| 118 | + primaryClass={cs.AI} |
| 119 | +} |
| 120 | +``` |
0 commit comments