|
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>A Model Context Protocol (MCP) server that enables natural language queries to databases</b></br> |
| 6 | + <b>A Model Context Protocol (MCP) server that enables natural language queries to databases</b><br/> |
7 | 7 | <sub>powered by <a href="https://github.com/XGenerationLab/XiYan-SQL" >XiYan-SQL</a>, SOTA of text-to-sql on open benchmarks</sub>
|
8 | 8 | </p>
|
9 | 9 |
|
|
42 | 42 | - [LLM Configuration](#llm-configuration)
|
43 | 43 | - [General LLMs](#general-llms)
|
44 | 44 | - [Text-to-SQL SOTA model](#text-to-sql-sota-model)
|
45 |
| - - [Local LLMs](#local-llms) |
| 45 | + - [Local Model](#local-model) |
46 | 46 | - [Database Configuration](#database-configuration)
|
47 | 47 | - [Launch](#launch)
|
48 | 48 | - [Claude Desktop](#claude-desktop)
|
|
55 | 55 |
|
56 | 56 | ## Features
|
57 | 57 | - 🌐 Fetch data by natural language through [XiYanSQL](https://github.com/XGenerationLab/XiYan-SQL)
|
| 58 | +- 🤖 Support general LLMs (GPT,qwenmax), Text-to-SQL SOTA model |
| 59 | +- 💻 Support pure local mode (high security!) |
58 | 60 | - 🖱️ List available MySQL tables as resources
|
59 | 61 | - 🔧 Read table contents
|
60 | 62 |
|
@@ -111,14 +113,14 @@ database:
|
111 | 113 | ### LLM Configuration
|
112 | 114 | ``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.
|
113 | 115 |
|
114 |
| -| versions | general LLMs(GPT,qwenmax) | SOTA model by Modelscope | SOTA model by Dashscope | |
115 |
| -|----------|-------------------------------|--------------------------------------------|-----------------------------------------------------------| |
116 |
| -| description| basic, easy to use | best performance, stable, recommand | best performance, for trial | |
117 |
| -| name | the official model name (e.g. gpt-3.5-turbo,qwen-max) | XGenerationLab/XiYanSQL-QwenCoder-32B-2412 | xiyansql-qwencoder-32b | |
118 |
| -| key | the API key of the service provider (e.g. OpenAI, Alibaba Cloud) | the API key of modelscope | the API key via email | |
119 |
| -| url | the endpoint of the service provider (e.g."https://api.openai.com/v1") | https://api-inference.modelscope.cn/v1/ | https://xiyan-stream.biz.aliyun.com/service/api/xiyan-sql | |
| 116 | +| versions | general LLMs(GPT,qwenmax) | SOTA model by Modelscope | SOTA model by Dashscope | Local LLMs | |
| 117 | +|----------|-------------------------------|--------------------------------------------|-----------------------------------------------------------|-----------------------| |
| 118 | +| description| basic, easy to use | best performance, stable, recommand | best performance, for trial | slow, high-security | |
| 119 | +| name | the official model name (e.g. gpt-3.5-turbo,qwen-max) | XGenerationLab/XiYanSQL-QwenCoder-32B-2412 | xiyansql-qwencoder-32b | xiyansql-qwencoder-3b | |
| 120 | +| key | the API key of the service provider (e.g. OpenAI, Alibaba Cloud) | the API key of modelscope | the API key via email | "" | |
| 121 | +| url | the endpoint of the service provider (e.g."https://api.openai.com/v1") | https://api-inference.modelscope.cn/v1/ | https://xiyan-stream.biz.aliyun.com/service/api/xiyan-sql | http://localhost:5090 | |
120 | 122 |
|
121 |
| -#### general LLMs |
| 123 | +#### General LLMs |
122 | 124 | if you want to use the general LLMs, e.g. gpt3.5, you can directly config like this:
|
123 | 125 | ```yaml
|
124 | 126 | model:
|
@@ -180,8 +182,46 @@ Note: this model service is just for trial, if you need to use it in production,
|
180 | 182 |
|
181 | 183 | Alternatively, you can also deploy the model [XiYanSQL-qwencoder-32B](https://github.com/XGenerationLab/XiYanSQL-QwenCoder) on your own server.
|
182 | 184 |
|
183 |
| -#### Local LLMs |
184 |
| -To support in the future. |
| 185 | +#### Local Model |
| 186 | +Note: local model is slow (about 12 seconds per query on my macbook). |
| 187 | +If your need stable and fast service, we still recommend to use the modelscope version. |
| 188 | +
|
| 189 | +To run xiyan_mcp_server on local mode, you need |
| 190 | +1) a PC/Mac with at least 16GB RAM |
| 191 | +2) 6GB disk space |
| 192 | +
|
| 193 | +step1: Install additional python packages |
| 194 | +```bash |
| 195 | +pip install flask modelscope torch==2.2.2 accelerate>=0.26.0 numpy=2.2.3 |
| 196 | +``` |
| 197 | + |
| 198 | +step2: (optional) manully download the model |
| 199 | +We recommand [xiyansql-qwencoder-3b](https://www.modelscope.cn/models/XGenerationLab/XiYanSQL-QwenCoder-3B-2502/). |
| 200 | +You can manully download the model by |
| 201 | +```bash |
| 202 | +modelscope download --model XGenerationLab/XiYanSQL-QwenCoder-3B-2502 |
| 203 | +``` |
| 204 | +It will take you 6GB disk space. |
| 205 | + |
| 206 | +step4: download the script and run server. src/xiyan_mcp_server/local_xiyan_server.py |
| 207 | + |
| 208 | + |
| 209 | + |
| 210 | +```bash |
| 211 | +python local_xiyan_server.py |
| 212 | +``` |
| 213 | +The server will be running on http://localhost:5090/ |
| 214 | + |
| 215 | +step4: prepare config and run xiyan_mcp_server |
| 216 | +the config.yml should be like: |
| 217 | +```yml |
| 218 | +model: |
| 219 | + name: "xiyansql-qwencoder-3b" |
| 220 | + key: "KEY" |
| 221 | + url: "http://127.0.0.1:5090" |
| 222 | +``` |
| 223 | +
|
| 224 | +Til now the local mode is ready. |
185 | 225 |
|
186 | 226 | ### Database Configuration
|
187 | 227 | ``host``, ``port``, ``user``, ``password``, ``database`` are the connection information of the MySQL database.
|
|
0 commit comments