Skip to content

Commit 74414b7

Browse files
feat: 更新 Dockerfile 并完善 README
- 将 Dockerfile 中的 Python 版本从 3.9 升级到 3.11 - 重构 README.md,增加配置说明和使用示例 - 新增 setup.py 文件,定义项目依赖和元数据- 更新 smithery.yaml,修改 MCP 启动命令
1 parent a528e05 commit 74414b7

File tree

4 files changed

+113
-56
lines changed

4 files changed

+113
-56
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# 使用Python 3.9作为基础镜像
2-
FROM python:3.9-slim
2+
FROM python:3.11-slim
33

44
# 设置工作目录
55
WORKDIR /app

README.md

Lines changed: 81 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
# XiYan MCP Server
44

5-
A Model Context Protocol (MCP) server that enables natural language queries to MySQL databases, power by XiYanSQL as text-to-sql technique.
5+
A Model Context Protocol (MCP) server that enables natural language queries to MySQL databases, power by XiYanSQL(https://github.com/XGenerationLab/XiYan-SQL) as text-to-sql technique.
66

77

88
## Features
@@ -12,74 +12,102 @@ A Model Context Protocol (MCP) server that enables natural language queries to M
1212

1313
## Installation
1414

15-
Python 3.11+ is required.
15+
Python 3.11+ is required.
16+
you can install the server by a pre-release verion
1617

1718
```bash
18-
pip install xiyan-mcp-server
19+
pip install xiyan_mcp_server-0.1.0-py3-none-any
1920
```
2021

21-
## Configuration
22-
23-
Set the following environment variables:
24-
22+
After that you can directly run the server by:
2523
```bash
26-
YML= # yml config file path
24+
python -m xiyan_mcp_server
25+
```
26+
But it does not provide any functions until you complete following config.
27+
You will get a yml file. After that you can run the server by:
28+
```yaml
29+
env YML=path/to/yml python -m xiyan_mcp_server
2730
```
2831

29-
see config_demo.yml for example
30-
31-
## Models
32-
33-
Any LLMs are supported as long as they support the `chat` API.
34-
We recommend using xiyansql-qwencoder-32b (https://github.com/XGenerationLab/XiYanSQL-QwenCoder) for best performance.
3532

36-
## Usage
33+
## Configuration
3734

38-
### With Claude Desktop
35+
You need a yml config file to configure the server.
36+
a default config file is provided in config_demo.yml which looks like this:
37+
38+
```yaml
39+
model:
40+
name: "pre-xiyan_multi_dialect_v3"
41+
key: ""
42+
url: "https://poc-dashscope.aliyuncs.com/compatible-mode/v1"
43+
44+
database:
45+
host: "localhost"
46+
port: 3306
47+
user: "root"
48+
password: ""
49+
database: ""
50+
```
3951
40-
Add this to your `claude_desktop_config.json`:
52+
### About LLM
53+
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.
54+
#### Using general LLMs
55+
if you want to use the general LLMs, e.g. gpt3.5, you can directly config like this:
56+
```yaml
57+
model:
58+
name: "gpt-3.5-turbo"
59+
key: "YOUR KEY "
60+
url: "https://api.openai.com/v1/chat/completions"
61+
database:
62+
```
4163
42-
```json
43-
{
44-
"mcpServers": {
45-
"xiyan": {
46-
"command": "uv",
47-
"args": [
48-
"--directory",
49-
"path/to/xiyan_mcp_server",
50-
"run",
51-
"xiyan_mcp_server"
52-
],
53-
"env": {
54-
"YML": "path/to/yml"
55-
}
56-
}
57-
}
58-
}
64+
if you want to use Qwen from alibaba, e.g. Qwen-max,
65+
```yaml
66+
model:
67+
name: "qwen-max"
68+
key: "YOUR KEY "
69+
url: "https://dashscope.aliyuncs.com/compatible-mode/v1"
70+
database:
71+
```
72+
#### Using Text-to-SQL SOTA model
73+
Last, we recommend the XiYanSQL-qwencoder-32B (https://github.com/XGenerationLab/XiYanSQL-QwenCoder), which is the SOTA model in text-to-sql.
74+
We deployed the model on DashScope, so you need to set the following environment variables:
75+
Contact us to get the key.
76+
```yaml
77+
model:
78+
name: "pre-xiyan_multi_dialect_v3"
79+
key: "KEY"
80+
url: "https://poc-dashscope.aliyuncs.com/compatible-mode/v1"
81+
database:
5982
```
6083
61-
### As a standalone server
84+
#### Local LLMs
85+
To support in the future.
6286
63-
```bash
64-
# Install dependencies
65-
pip install -r requirements.txt
87+
### About the database
88+
host, port, user, password, database are the connection information of the MySQL database.
6689
67-
# Run the server
68-
python -m xiyan_mcp_server
90+
You can use local or any remote databases. Currently we support MySQL (more dialects soon)
91+
```yaml
92+
database:
93+
host: "localhost"
94+
port: 3306
95+
user: "root"
96+
password: ""
97+
database: ""
6998
```
7099
71-
## Development
72-
73-
```bash
74-
# Clone the repository
75-
git clone https://github.com/XGenerationLab/xiyan_mcp_server.git
76-
cd xiyan_mcp_server
77-
78-
# Create virtual environment
79-
python -m venv venv
80-
source venv/bin/activate # or `venv\Scripts\activate` on Windows
100+
## Citation
101+
If you find our work helpful, feel free to give us a cite.
102+
```bib
103+
@article{xiyansql,
104+
title={A Preview of XiYan-SQL: A Multi-Generator Ensemble Framework for Text-to-SQL},
105+
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},
106+
year={2024},
107+
journal={arXiv preprint arXiv:2411.08599},
108+
url={https://arxiv.org/abs/2411.08599},
109+
primaryClass={cs.AI}
110+
}
111+
```
81112

82-
# Install development dependencies
83-
pip install -r requirements.txt
84113

85-
```

setup.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
from setuptools import setup, find_packages
2+
3+
setup(
4+
name='xiyan_mcp_server', # 包的名字
5+
version='0.1.0', # 版本号
6+
packages=find_packages(), # 自动找到项目中的包
7+
install_requires=[ # 必要的包依赖
8+
# 'numpy', # 示例:若有依赖包,将其列在此
9+
'mcp',
10+
'mysql-connector-python>=9.1.0',
11+
'sqlalchemy',
12+
'llama_index',
13+
'yaml',
14+
'pandas'
15+
],
16+
author='Bruce Luo', # 作者
17+
author_email='godot.lzl@alibaba-inc.com', # 作者邮箱
18+
description='A MCP server of natural language interface to Database', # 简短描述
19+
long_description=open('README.md').read(), # 从 README 文件读取详细描述
20+
long_description_content_type='text/markdown', # 描述内容类型
21+
url='https://github.com/XGenerationLab/xiyan_mcp_server', # 项目主页
22+
classifiers=[
23+
'Programming Language :: Python :: 3',
24+
'License :: OSI Approved :: MIT License',
25+
'Operating System :: OS Independent',
26+
],
27+
python_requires='>=3.11', # 支持的 Python 版本
28+
)

smithery.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@ startCommand:
88
# A function that produces the CLI command to start the MCP on stdio.
99
|-
1010
(config) => ({
11-
"command": "node",
11+
"command": "python",
1212
"args": [
13-
"dist/index.js"
13+
"-m",
14+
"xiyan-mcp-server"
1415
],
1516
"env": {
1617
}

0 commit comments

Comments
 (0)