📇 ☁️ - Fetch data from databases with natural-language queries, using XiyanSQL as the text-to-SQL model
XiYan MCP Server
以下摘录自该仓库的 README(片段) · 在 GitHub 读完整 README →
A Model Context Protocol (MCP) server that enables natural language queries to databases
powered by XiYan-SQL , SOTA of text-to-sql on open benchmarks
💻 XiYan-mcp-server |
🌐 XiYan-SQL |
📖 Arxiv |
🏆 XiYanSQL Model |
📄 PapersWithCode
🤗 HuggingFace |
🤖 ModelScope |
🌕 析言GBI
English | 中文 | 日本語
Ding Group钉钉群 |
Follow me on Weibo
Table of Contents
- Features
- Preview
- Architecture
- Best Practice
- Tools Preview
- Installation
- Installing from pip
- Installing from Smithery.ai
- Configuration
- LLM Configuration
- General LLMs
- Text-to-SQL SOTA model
- Local Model
- Database Configuration
- MySQL
- PostgreSQL
- Launch
- Claude Desktop
- Cline
- Goose
- Cursor
- It Does Not Work
- Citation
Features
- 🌐 Fetch data by natural language through XiYanSQL
- 🤖 Support general LLMs (GPT,qwenmax), Text-to-SQL SOTA model
- 💻 Support pure local mode (high security!)
- 📝 Support MySQL and PostgreSQL.
- 🖱️ List available tables as resources
- 🔧 Read table contents
Preview
Architecture
There are two ways to integrate this server in your project, as shown below:
The left is remote mode, which is the default mode. It requires an API key to access the xiyanSQL-qwencoder-32B model from service provider (see Configuration).
Another mode is local mode, which is more secure. It does not require the API key.
Best practice and reports
"Build a local data assistant using MCP + Modelscope API-Inference without writing a single line of code"
"Xiyan MCP on Modelscope"
Evaluation on MCPBench
The following figure illustrates the performance of the XiYan MCP server as measured by the MCPBench benchmark. The XiYan MCP server demonstrates superior performance compared to both the MySQL MCP server and the PostgreSQL MCP server, achieving a lead of 2-22 percentage points. The detailed experiment results can be found at MCPBench and the report "Evaluation Report on MCP Servers".
Tools Preview
- The tool get_data provides a natural language interface for retrieving data from a database. This server will convert the input natural language into SQL using a built-in model and call the database to return the query results.
- The {dialect}://{table_name} resource allows obtaining a portion of sample data from the database for model reference when a specific table_name is specified.
- The {dialect}:// resource will list the names of the current databases
Installation
Installing from pip
Python 3.11+ is required.
You can install the server through pip, and it will install the latest version:
If you want to install the development version from source, you can install from source code on github:
Installing from Smithery.ai
See @XGenerationLab/xiyan_mcp_server
Not fully tested.
Configuration
You need a YAML config file to configure the server.
A default config file is provided in config_demo.yml which looks like this:
MCP Configuration
You can set the transport protocol to stdio or sse.
STDIO
For stdio protocol, you can set just like this:
SSE
For sse protocol, you can set mcp config as below:
The default port is 8000. You can change the port if needed.
The default log level is ERROR. We recommend to set log level to INFO for more detailed information.
Other configurations like debug, host, sse_path, message_path can be customized as well, but normally you don't need to modify them.
LLM Configuration
Name is the name of the model to use, key is the API key of the model, url is the API url of the model. We support following models.
| versions | general LLMs(GPT,qwenmax) | SOTA model by Modelscope | SOTA model by Dashscope | Local LLMs |