{"id":29113848,"url":"https://github.com/xgenerationlab/xiyan_mcp_server","last_synced_at":"2026-01-14T17:27:42.485Z","repository":{"id":282184808,"uuid":"947753431","full_name":"XGenerationLab/xiyan_mcp_server","owner":"XGenerationLab","description":"A Model Context Protocol (MCP) server that enables natural language queries to databases","archived":false,"fork":false,"pushed_at":"2025-05-07T11:06:19.000Z","size":2267,"stargazers_count":151,"open_issues_count":9,"forks_count":28,"subscribers_count":8,"default_branch":"main","last_synced_at":"2025-06-09T08:14:26.698Z","etag":null,"topics":["database","mcp","text-to-sql"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/XGenerationLab.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-03-13T07:39:00.000Z","updated_at":"2025-06-06T13:26:20.000Z","dependencies_parsed_at":"2025-03-28T07:28:09.647Z","dependency_job_id":"ac0262b8-a459-4071-a21d-9fd82e5de616","html_url":"https://github.com/XGenerationLab/xiyan_mcp_server","commit_stats":null,"previous_names":["xgenerationlab/xiyan_mcp_server"],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/XGenerationLab/xiyan_mcp_server","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/XGenerationLab%2Fxiyan_mcp_server","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/XGenerationLab%2Fxiyan_mcp_server/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/XGenerationLab%2Fxiyan_mcp_server/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/XGenerationLab%2Fxiyan_mcp_server/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/XGenerationLab","download_url":"https://codeload.github.com/XGenerationLab/xiyan_mcp_server/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/XGenerationLab%2Fxiyan_mcp_server/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262581388,"owners_count":23331913,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["database","mcp","text-to-sql"],"created_at":"2025-06-29T11:05:52.435Z","updated_at":"2026-01-14T17:27:42.446Z","avatar_url":"https://github.com/XGenerationLab.png","language":"Python","funding_links":[],"categories":["Databases"],"sub_categories":["How to Submit"],"readme":"\n\u003ch1 align=\"center\"\u003eXiYan MCP Server\u003c/h1\u003e\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://github.com/XGenerationLab/XiYan-SQL\"\u003e\u003cimg alt=\"MCP Playwright\" src=\"https://raw.githubusercontent.com/XGenerationLab/XiYan-SQL/main/xiyanGBI.png\" height=\"60\"/\u003e\u003c/a\u003e\n\u003c/p\u003e\n\u003cp align=\"center\"\u003e\n  \u003cb\u003eA Model Context Protocol (MCP) server that enables natural language queries to databases\u003c/b\u003e\u003cbr/\u003e\n  \u003csub\u003epowered by \u003ca href=\"https://github.com/XGenerationLab/XiYan-SQL\" \u003eXiYan-SQL\u003c/a\u003e, SOTA of text-to-sql on open benchmarks\u003c/sub\u003e\n\u003c/p\u003e\n\u003cp align=\"center\"\u003e\n💻 \u003ca href=\"https://github.com/XGenerationLab/xiyan_mcp_server\" \u003eXiYan-mcp-server\u003c/a\u003e | \n🌐 \u003ca href=\"https://github.com/XGenerationLab/XiYan-SQL\" \u003eXiYan-SQL\u003c/a\u003e |\n📖 \u003ca href=\"https://arxiv.org/abs/2411.08599\"\u003e Arxiv\u003c/a\u003e | \n📄 \u003ca href=\"https://paperswithcode.com/paper/xiyan-sql-a-multi-generator-ensemble\" \u003ePapersWithCode\u003c/a\u003e\n🤗 \u003ca href=\"https://huggingface.co/collections/XGenerationLab/xiyansql-models-67c9844307b49f87436808fc\"\u003eHuggingFace\u003c/a\u003e |\n🤖 \u003ca href=\"https://modelscope.cn/collections/XiYanSQL-Models-4483337b614241\" \u003eModelScope\u003c/a\u003e |\n🌕 \u003ca href=\"https://bailian.console.aliyun.com/xiyan\"\u003e析言GBI\u003c/a\u003e \n\u003cbr /\u003e\n\u003cimg src=\"https://badge.mcpx.dev/?type=server%20%27MCP%20Server%27\" alt=\"MCP Server\" /\u003e\n\u003ca href=\"https://arxiv.org/abs/2411.08599\"\u003e\u003cimg src=\"imgs/Paper-Arxiv-orange.svg\" \u003e\u003c/a\u003e\n\u003ca href=\"https://opensource.org/licenses/Apache-2.0\"\u003e\n  \u003cimg src=\"https://img.shields.io/badge/License-Apache%202.0-blue.svg\" alt=\"License: Apache 2.0\" /\u003e\n\u003c/a\u003e\n\u003ca href=\"https://pepy.tech/projects/xiyan-mcp-server\"\u003e\u003cimg src=\"https://static.pepy.tech/badge/xiyan-mcp-server\" alt=\"PyPI Downloads\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://smithery.ai/server/@XGenerationLab/xiyan_mcp_server\"\u003e\u003cimg alt=\"Smithery Installs\" src=\"https://smithery.ai/badge/@XGenerationLab/xiyan_mcp_server\" height=\"20\"/\u003e\u003c/a\u003e\n\u003ca href=\"https://github.com/XGenerationLab/xiyan_mcp_server\" target=\"_blank\"\u003e\n    \u003cimg src=\"https://img.shields.io/github/stars/XGenerationLab/xiyan_mcp_server?style=social\" alt=\"GitHub stars\" /\u003e\n\u003c/a\u003e\n\u003cbr /\u003e\n\u003ca href=\"https://github.com/XGenerationLab/xiyan_mcp_server\" \u003eEnglish\u003c/a\u003e | \u003ca href=\"https://github.com/XGenerationLab/xiyan_mcp_server/blob/main/README_zh.md\"\u003e 中文 \u003c/a\u003e | \u003ca href=\"https://github.com/XGenerationLab/xiyan_mcp_server/blob/main/README_ja.md\"\u003e 日本語 \u003c/a\u003e\u003cbr /\u003e\n\u003ca href=\"https://github.com/XGenerationLab/xiyan_mcp_server/blob/main/imgs/dinggroup_out.png\"\u003eDing Group钉钉群\u003c/a\u003e｜ \n\u003ca href=\"https://weibo.com/u/2540915670\" target=\"_blank\"\u003eFollow me on Weibo\u003c/a\u003e\n\u003c/p\u003e\n\n\n## Table of Contents\n\n- [Features](#features)\n- [Preview](#preview)\n  - [Architecture](#architecture)\n  - [Best Practice](#best-practice)\n  - [Tools Preview](#tools-preview)\n- [Installation](#installation)\n  - [Installing from pip](#installing-from-pip)\n  - [Installing from Smithery.ai](#installing-from-smitheryai)\n- [Configuration](#configuration)\n  - [LLM Configuration](#llm-configuration)\n    - [General LLMs](#general-llms)\n    - [Text-to-SQL SOTA model](#text-to-sql-sota-model)\n    - [Local Model](#local-model)\n  - [Database Configuration](#database-configuration)\n    - [MySQL](#mysql)\n    - [PostgreSQL](#postgresql)\n- [Launch](#launch)\n  - [Claude Desktop](#claude-desktop)\n  - [Cline](#cline)\n  - [Goose](#goose)\n  - [Cursor](#cursor)\n- [It Does Not Work](#it-does-not-work)\n- [Citation](#citation)\n\n\n## Features\n- 🌐 Fetch data by natural language through [XiYanSQL](https://github.com/XGenerationLab/XiYan-SQL)\n- 🤖 Support general LLMs (GPT,qwenmax), Text-to-SQL SOTA model\n- 💻 Support pure local mode (high security!)\n- 📝 Support MySQL and PostgreSQL. \n- 🖱️ List available tables as resources\n- 🔧 Read table contents\n\n## Preview\n### Architecture\nThere are two ways to integrate this server in your project, as shown below:\nThe 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](#Configuration)).\nAnother mode is local mode, which is more secure. It does not require the API key.\n\n![architecture.png](imgs/architecture.png)\n### Best practice and reports\n\n[\"Build a local data assistant using MCP + Modelscope API-Inference without writing a single line of code\"](https://mp.weixin.qq.com/s/tzDelu0W4w6t9C0_yYRbHA)\n\n[\"Xiyan MCP on Modelscope\"](https://modelscope.cn/headlines/article/1142)\n\n### Evaluation on MCPBench\nThe 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](https://github.com/modelscope/MCPBench) and the report [\"Evaluation Report on MCP Servers\"](https://arxiv.org/abs/2504.11094).\n\n![exp_mcpbench.png](imgs/exp_mcpbench.png)\n\n### Tools Preview\n - 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.\n\n - 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. \n- The ``{dialect}://`` resource will list the names of the current databases\n\n## Installation\n### Installing from pip\n\nPython 3.11+ is required. \nYou can install the server through pip, and it will install the latest version:\n\n```shell\npip install xiyan-mcp-server\n```\n\nIf you want to install the development version from source, you can install from source code on github:\n```shell\npip install git+https://github.com/XGenerationLab/xiyan_mcp_server.git\n```\n\n### Installing from Smithery.ai\nSee [@XGenerationLab/xiyan_mcp_server](https://smithery.ai/server/@XGenerationLab/xiyan_mcp_server)\n\nNot fully tested.\n\n## Configuration\n\nYou need a YAML config file to configure the server.\nA default config file is provided in config_demo.yml which looks like this:\n\n```yaml\nmcp:\n  transport: \"stdio\"\nmodel:\n  name: \"XGenerationLab/XiYanSQL-QwenCoder-32B-2412\"\n  key: \"\"\n  url: \"https://api-inference.modelscope.cn/v1/\"\ndatabase:\n  host: \"localhost\"\n  port: 3306\n  user: \"root\"\n  password: \"\"\n  database: \"\"\n```\n\n### MCP Configuration\nYou can set the transport protocol to ``stdio`` or ``sse``.\n#### STDIO\nFor stdio protocol, you can set just like this:\n```yaml\nmcp:\n  transport: \"stdio\"\n```\n#### SSE\nFor sse protocol, you can set mcp config as below:\n```yaml\nmcp:\n  transport: \"sse\"\n  port: 8000\n  log_level: \"INFO\"\n```\nThe default port is `8000`. You can change the port if needed. \nThe default log level is `ERROR`. We recommend to set log level to `INFO` for more detailed information.\n\nOther configurations like `debug`, `host`, `sse_path`, `message_path` can be customized as well, but normally you don't need to modify them.\n\n### LLM Configuration\n``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.\n\n| versions | general LLMs(GPT,qwenmax)                                             | SOTA model by Modelscope                   | SOTA model by Dashscope                                   | Local LLMs            |\n|----------|-------------------------------|--------------------------------------------|-----------------------------------------------------------|-----------------------|\n| description| basic, easy to use | best performance, stable, recommand        | best performance, for trial                               | slow, high-security   |\n| name     | the official model name (e.g. gpt-3.5-turbo,qwen-max)                 | XGenerationLab/XiYanSQL-QwenCoder-32B-2412 | xiyansql-qwencoder-32b                                    | xiyansql-qwencoder-3b |\n| key      | the API key of the service provider (e.g. OpenAI, Alibaba Cloud)      | the API key of modelscope                  | the API key via email                                     | \"\"                    |\n| 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 |\n\n#### General LLMs\nIf you want to use the general LLMs, e.g. gpt3.5, you can directly config like this:\n```yaml\nmodel:\n  name: \"gpt-3.5-turbo\"\n  key: \"YOUR KEY \"\n  url: \"https://api.openai.com/v1\"\ndatabase:\n```\n\nIf you want to use Qwen from Alibaba, e.g. Qwen-max, you can use following config:\n```yaml\nmodel:\n  name: \"qwen-max\"\n  key: \"YOUR KEY \"\n  url: \"https://dashscope.aliyuncs.com/compatible-mode/v1\"\ndatabase:\n```\n#### Text-to-SQL SOTA model\nWe recommend the XiYanSQL-qwencoder-32B (https://github.com/XGenerationLab/XiYanSQL-QwenCoder), which is the SOTA model in text-to-sql, see [Bird benchmark](https://bird-bench.github.io/).\nThere are two ways to use the model. You can use either of them.\n(1) [Modelscope](https://www.modelscope.cn/models/XGenerationLab/XiYanSQL-QwenCoder-32B-2412),  (2) Alibaba Cloud DashScope.\n\n\n##### (1) Modelscope version\nYou need to apply a ``key`` of API-inference from Modelscope, https://www.modelscope.cn/docs/model-service/API-Inference/intro\nThen you can use the following config:\n```yaml\nmodel:\n  name: \"XGenerationLab/XiYanSQL-QwenCoder-32B-2412\"\n  key: \"\"\n  url: \"https://api-inference.modelscope.cn/v1/\"\n```\n\nRead our [model description](https://www.modelscope.cn/models/XGenerationLab/XiYanSQL-QwenCoder-32B-2412) for more details. \n\n##### (2) Dashscope version\n\nWe deployed the model on Alibaba Cloud DashScope, so you need to set the following environment variables:\nSend me your email to get the ``key``. ( godot.lzl@alibaba-inc.com )\nIn the email, please attach the following information:\n```yaml\nname: \"YOUR NAME\",\nemail: \"YOUR EMAIL\",\norganization: \"your college or Company or Organization\"\n```\nWe will send you a ``key`` according to your email. And you can fill the ``key`` in the yml file.\nThe ``key`` will be expired by  1 month or 200 queries or other legal restrictions.\n\n\n```yaml\nmodel:\n  name: \"xiyansql-qwencoder-32b\"\n  key: \"KEY\"\n  url: \"https://xiyan-stream.biz.aliyun.com/service/api/xiyan-sql\"\n```\n\nNote: this model service is just for trial, if you need to use it in production, please contact us.\n\n##### (3) Local version\nAlternatively, you can also deploy the model [XiYanSQL-qwencoder-32B](https://github.com/XGenerationLab/XiYanSQL-QwenCoder) on your own server.\nSee [Local Model](src/xiyan_mcp_server/local_model/README.md) for more details.\n\n\n### Database Configuration\n``host``, ``port``, ``user``, ``password``, ``database`` are the connection information of the database.\n\nYou can use local or any remote databases. Now we support MySQL and PostgreSQL(more dialects soon).\n\n#### MySQL\n\n```yaml\ndatabase:\n  host: \"localhost\"\n  port: 3306\n  user: \"root\"\n  password: \"\"\n  database: \"\"\n```\n#### PostgreSQL\nStep 1: Install Python packages\n```bash\npip install psycopg2\n```\nStep 2: prepare the config.yml like this:\n```yaml\ndatabase:\n  dialect: \"postgresql\"\n  host: \"localhost\"\n  port: 5432\n  user: \"\"\n  password: \"\"\n  database: \"\"\n```\n\nNote that ``dialect`` should be ``postgresql`` for postgresql.\n## Launch\n\n### Server Launch\n\nIf you want to launch server with `sse`, you have to run the following command in a terminal:\n```shell\nYML=path/to/yml python -m xiyan_mcp_server\n```\nThen you should see the information on http://localhost:8000/sse in your browser. (Defaultly, change if your mcp server runs on other host/port)\n\nOtherwise, if you use `stdio` transport protocol, you usually declare the mcp server command in specific mcp application instead of launching it in a terminal.\nHowever, you can still debug with this command if needed.\n\n### Client Setting\n\n#### Claude Desktop\nAdd this in your Claude Desktop config file, ref \u003ca href=\"https://github.com/XGenerationLab/xiyan_mcp_server/blob/main/imgs/claude_desktop.jpg\"\u003eClaude Desktop config example\u003c/a\u003e\n```json\n{\n    \"mcpServers\": {\n        \"xiyan-mcp-server\": {\n            \"command\": \"/xxx/python\",\n            \"args\": [\n                \"-m\",\n                \"xiyan_mcp_server\"\n            ],\n            \"env\": {\n                \"YML\": \"PATH/TO/YML\"\n            }\n        }\n    }\n}\n```\n**Please note that the Python command here requires the complete path to the Python executable (`/xxx/python`); otherwise, the Python interpreter cannot be found. You can determine this path by using the command `which python`. The same applies to other applications as well.**\n\nClaude Desktop currently does not support the SSE transport protocol.\n\n#### Cline\nPrepare the config like [Claude Desktop](#claude-desktop)\n\n#### Goose\nIf you use `stdio`, add following command in the config, ref \u003ca href=\"https://github.com/XGenerationLab/xiyan_mcp_server/blob/main/imgs/goose.jpg\"\u003eGoose config example\u003c/a\u003e\n```shell\nenv YML=path/to/yml /xxx/python -m xiyan_mcp_server\n```\nOtherwise, if you use `sse`, change Type to `SSE` and set the endpoint to `http://127.0.0.1:8000/sse`\n#### Cursor\nUse the similar command as follows.\n\nFor `stdio`:\n```json\n{\n  \"mcpServers\": {\n    \"xiyan-mcp-server\": {\n      \"command\": \"/xxx/python\",\n      \"args\": [\n        \"-m\",\n        \"xiyan_mcp_server\"\n      ],\n      \"env\": {\n        \"YML\": \"path/to/yml\"\n      }\n    }\n  }\n}\n```\nFor `sse`:\n```json\n{\n  \"mcpServers\": {\n    \"xiyan_mcp_server_1\": {\n      \"url\": \"http://localhost:8000/sse\"\n    }\n  }\n}\n```\n\n\n#### Witsy\nAdd following in command:\n```shell\n/xxx/python -m xiyan_mcp_server\n```\nAdd an env: key is YML and value is the path to your yml file.\nRef \u003ca href=\"https://github.com/XGenerationLab/xiyan_mcp_server/blob/main/imgs/witsy.jpg\"\u003eWitsy config example\u003c/a\u003e\n\n\n## It Does Not Work!\nContact us:\n\u003ca href=\"https://github.com/XGenerationLab/xiyan_mcp_server/blob/main/imgs/dinggroup_out.png\"\u003eDing Group钉钉群\u003c/a\u003e｜ \n\u003ca href=\"https://weibo.com/u/2540915670\" target=\"_blank\"\u003eFollow me on Weibo\u003c/a\u003e\n\n\n## Other Related Links\n\n[![MseeP.ai Security Assessment Badge](https://mseep.net/pr/xgenerationlab-xiyan-mcp-server-badge.png)](https://mseep.ai/app/xgenerationlab-xiyan-mcp-server)\n\n\n\n\n## Citation\nIf you find our work helpful, feel free to give us a cite.\n```bib\n@article{xiyansql,\n      title={A Preview of XiYan-SQL: A Multi-Generator Ensemble Framework for Text-to-SQL}, \n      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},\n      year={2024},\n      journal={arXiv preprint arXiv:2411.08599},\n      url={https://arxiv.org/abs/2411.08599},\n      primaryClass={cs.AI}\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxgenerationlab%2Fxiyan_mcp_server","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxgenerationlab%2Fxiyan_mcp_server","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxgenerationlab%2Fxiyan_mcp_server/lists"}