Skip to main content
Glama

XiYan MCP Server

Apache 2.0
114
  • Linux
  • Apple

目录

特征

  • 🌐 通过XiYanSQL获取自然语言数据
  • 🤖 支持通用 LLM(GPT、qwenmax)、Text-to-SQL SOTA 模型
  • 💻支持纯本地模式(安全性高!)
  • 📝 支持 MySQL 和 PostgreSQL。
  • 🖱️ 将可用表列为资源
  • 🔧 读取表格内容

预览

建筑学

在您的项目中集成此服务器有两种方式,如下图所示:左侧为远程模式,为默认模式,需要 API key 才能从服务商处访问 xiyanSQL-qwencoder-32B 模型(参见配置)。右侧为本地模式,更安全,无需 API key。

建筑.png

最佳实践和报告

“使用 MCP + Modelscope API-Inference 构建本地数据助手,无需编写任何代码”

“Xiyan MCP 在 Modelscope 上”

MCPBench 评估

下图展示了 XiYan MCP 服务器在 MCPBench 基准测试中的性能表现。XiYan MCP 服务器相比 MySQL MCP 服务器和 PostgreSQL MCP 服务器均表现出色,领先幅度达 2-22 个百分点。详细实验结果可参见MCPBench《MCP 服务器评测报告》

exp\_mcpbench.png

工具预览

  • get_data工具提供了从数据库检索数据的自然语言接口。该服务器将使用内置模型将输入的自然语言转换为 SQL,并调用数据库返回查询结果。
  • 当指定特定的 table_name 时{dialect}://{table_name}资源允许从数据库中获取一部分样本数据以供模型参考。
  • {dialect}://资源将列出当前数据库的名称

安装

从 pip 安装

需要 Python 3.11+ 版本。您可以通过 pip 安装服务器,它将安装最新版本:

pip install xiyan-mcp-server

如果您想从源代码安装开发版本,您可以从 github 上的源代码安装:

pip install git+https://github.com/XGenerationLab/xiyan_mcp_server.git

从 Smithery.ai 安装

参见@XGenerationLab/xiyan_mcp_server

未经过全面测试。

配置

您需要一个 YAML 配置文件来配置服务器。config_demo.yml 中提供了一个默认配置文件,如下所示:

mcp: transport: "stdio" model: name: "XGenerationLab/XiYanSQL-QwenCoder-32B-2412" key: "" url: "https://api-inference.modelscope.cn/v1/" database: host: "localhost" port: 3306 user: "root" password: "" database: ""

MCP 配置

您可以将传输协议设置为stdiosse

标准输出

对于 stdio 协议,您可以像这样设置:

mcp: transport: "stdio"
上交所

对于 sse 协议,您可以按如下方式设置 mcp 配置:

mcp: transport: "sse" port: 8000 log_level: "INFO"

默认端口为8000 。您可以根据需要更改端口。默认日志级别为ERROR 。我们建议将日志级别设置为INFO以获取更详细的信息。

其他配置如debughostsse_pathmessage_path也可以自定义,但通常不需要修改它们。

LLM 配置

Name是要使用的模型的名称, key是模型的 API Key, url是模型的 API URL。我们支持以下模型。

版本普通法学硕士(GPT、qwenmax)Modelscope 的 SOTA 模型Dashscope 的 SOTA 模型本地法学硕士
描述基础、易用性能最佳,稳定,推荐最佳性能,试用速度慢,安全性高
姓名官方型号名称(例如 gpt-3.5-turbo、qwen-max)XGenerationLab/XiYanSQL-QwenCoder-32B-2412xiyansql-qwencoder-32bxiyansql-qwencoder-3b
钥匙服务提供商的 API 密钥(例如 OpenAI、阿里云)modelscope 的 API 密钥通过电子邮件获取 API 密钥“”
网址服务提供商的端点(例如“ https://api.openai.com/v1 ”)https://api-inference.modelscope.cn/v1/https://xiyan-stream.biz.aliyun.com/service/api/xiyan-sqlhttp://localhost:5090
普通法学硕士

如果要使用通用的LLM,例如gpt3.5,可以直接这样配置:

model: name: "gpt-3.5-turbo" key: "YOUR KEY " url: "https://api.openai.com/v1" database:

如果您想使用阿里巴巴的 Qwen,例如 Qwen-max,您可以使用以下配置:

model: name: "qwen-max" key: "YOUR KEY " url: "https://dashscope.aliyuncs.com/compatible-mode/v1" database:
文本到 SQL SOTA 模型

我们推荐 XiYanSQL-qwencoder-32B ( https://github.com/XGenerationLab/XiYanSQL-QwenCoder ),它是 Text-to-SQL 领域目前最优秀的模型,具体可以参考Bird benchmark 。该模型有两种使用方式,大家可以自行选择。(1) Modelscope ,(2) 阿里云 DashScope 。

(1)Modelscope版本

您需要从 Modelscope 申请一个 API-inference 的keyhttps://www.modelscope.cn/docs/model-service/API-Inference/intro然后您可以使用以下配置:

model: name: "XGenerationLab/XiYanSQL-QwenCoder-32B-2412" key: "" url: "https://api-inference.modelscope.cn/v1/"

阅读我们的模型描述以了解更多详细信息。

(2)Dashscope 版本

我们将模型部署在阿里云 DashScope 上,因此您需要设置以下环境变量: 请将您的邮箱发送给我以获取key 。( godot.lzl@alibaba-inc.com ) 在邮件中,请附上以下信息:

name: "YOUR NAME", email: "YOUR EMAIL", organization: "your college or Company or Organization"

我们会根据您的邮箱发送key 。您可以将key填写在 yml 文件中。 key有效期为 1 个月、200 次查询或其他法律限制。

model: name: "xiyansql-qwencoder-32b" key: "KEY" url: "https://xiyan-stream.biz.aliyun.com/service/api/xiyan-sql"

注:此模型服务仅供试用,如需在生产中使用,请联系我们。

(3)本地版本

或者,您也可以将模型XiYanSQL-qwencoder-32B部署到您自己的服务器上。更多详情,请参阅本地模型

数据库配置

hostportuserpassworddatabase是数据库的连接信息。

您可以使用本地或任何远程数据库。目前我们支持 MySQL 和 PostgreSQL(更多方言即将推出)。

MySQL
database: host: "localhost" port: 3306 user: "root" password: "" database: ""
PostgreSQL

步骤 1:安装 Python 包

pip install psycopg2

第 2 步:准备 config.yml,如下所示:

database: dialect: "postgresql" host: "localhost" port: 5432 user: "" password: "" database: ""

请注意,对于 postgresql, dialect应该是postgresql

发射

服务器启动

如果您想使用sse启动服务器,您必须在终端中运行以下命令:

YML=path/to/yml python -m xiyan_mcp_server

然后你就可以在浏览器中访问http://localhost:8000/sse来查看信息了。(默认设置,如果你的 mcp 服务器运行在其他主机/端口,则需要更改设置)

另外,如果您使用stdio传输协议,通常需要在具体的 mcp 应用程序中声明 mcp 服务器命令,而不是在终端中启动它。不过,如果需要,您仍然可以使用此命令进行调试。

客户端设置

克劳德桌面

将其添加到您的 Claude Desktop 配置文件中,参考 Claude Desktop 配置示例

{ "mcpServers": { "xiyan-mcp-server": { "command": "/xxx/python", "args": [ "-m", "xiyan_mcp_server" ], "env": { "YML": "PATH/TO/YML" } } } }

请注意,此处的 Python 命令需要 Python 可执行文件的完整路径 ( /xxx/python );否则,将无法找到 Python 解释器。您可以使用命令which python确定此路径。其他应用程序也一样。

Claude Desktop 目前不支持 SSE 传输协议。

克莱恩

Claude Desktop一样准备配置

如果你使用stdio ,请在配置中添加以下命令,参考 Goose 配置示例

env YML=path/to/yml /xxx/python -m xiyan_mcp_server

否则,如果您使用sse ,请将 Type 更改为SSE并将端点设置为http://127.0.0.1:8000/sse

光标

使用类似的命令如下。

对于stdio

{ "mcpServers": { "xiyan-mcp-server": { "command": "/xxx/python", "args": [ "-m", "xiyan_mcp_server" ], "env": { "YML": "path/to/yml" } } } }

对于sse

{ "mcpServers": { "xiyan_mcp_server_1": { "url": "http://localhost:8000/sse" } } }
机智

在命令中添加以下内容:

/xxx/python -m xiyan_mcp_server

添加一个环境变量:键为 YML,值是 yml 文件的路径。参考 Witsy 配置示例

它不起作用!

联系我们:鼎集团钉钉群|关注我微博

其他相关链接

引文

如果您发现我们的工作有帮助,请随时引用我们。

@article{xiyansql, title={A Preview of XiYan-SQL: A Multi-Generator Ensemble Framework for Text-to-SQL}, 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}, year={2024}, journal={arXiv preprint arXiv:2411.08599}, url={https://arxiv.org/abs/2411.08599}, primaryClass={cs.AI} }
-
security - not tested
A
license - permissive license
-
quality - not tested

hybrid server

The server is able to function both locally and remotely, depending on the configuration or use case.

模型上下文协议服务器,支持对 MySQL 数据库进行自然语言查询,由 XiYanSQL 文本到 SQL 技术提供支持。

  1. 特征
    1. 预览
      1. 建筑学
      2. 最佳实践和报告
      3. MCPBench 评估
      4. 工具预览
    2. 安装
      1. 从 pip 安装
      2. 从 Smithery.ai 安装
    3. 配置
      1. MCP 配置
      2. LLM 配置
      3. 数据库配置
    4. 发射
      1. 服务器启动
      2. 客户端设置
    5. 它不起作用!
      1. 其他相关链接
        1. 引文

          Related MCP Servers

          • -
            security
            F
            license
            -
            quality
            A Model Context Protocol server that enables SQL query execution, database management, and business intelligence capabilities through MySQL connections.
            Last updated -
            JavaScript
          • -
            security
            -
            license
            -
            quality
            A Model Context Protocol server that enables AI models to interact with MySQL databases, providing tools for querying, executing statements, listing tables, and describing table structures.
            Last updated -
            MIT License
          • -
            security
            -
            license
            -
            quality
            A Model Context Protocol server that enables AI models to interact with MySQL databases through a standardized interface, providing tools for querying, executing commands, and managing database schemas.
            Last updated -
            JavaScript
          • -
            security
            F
            license
            -
            quality
            A Model Context Protocol server that enables AI models to interact with MySQL databases through natural language, supporting SQL queries, table creation, and schema exploration.
            Last updated -
            1
            Python
            • Linux
            • Apple

          View all related MCP servers

          MCP directory API

          We provide all the information about MCP servers via our MCP API.

          curl -X GET 'https://glama.ai/api/mcp/v1/servers/XGenerationLab/xiyan_mcp_server'

          If you have feedback or need assistance with the MCP directory API, please join our Discord server