xiyan_mcp_server
A Model Context Protocol (MCP) server that enables natural language queries to databases
claude mcp add --transport stdio xgenerationlab-xiyan_mcp_server python -m xiyan_mcp_server \ --env LOG_LEVEL="INFO" \ --env MODEL_KEY="" \ --env DATABASE_PASSWORD=""
How to use
XiYan MCP Server enables natural language questions to be translated into SQL queries and executed against your database via XiYan-SQL. The server supports a local or remote configuration and can operate over standard IO (stdio) or SSE transports, making it flexible to integrate into your existing tooling. The built-in tool preview includes get_data, which converts NL requests into SQL to fetch results, and a {dialect}://{table_name} style resource that helps you inspect sample data or list database tables for model reference. You can run the server in local mode for higher security, or use the remote mode with an API-backed model for broader capabilities.
To use it, install the server, configure the database and LLM options in a YAML config, then start the MCP server. Once running, you can send NL queries like “show me customers from last quarter” or “get the names and emails from users where signup_date after 2023-01-01” and the server will translate them into SQL via XiYanSQL and return results. You can also inspect available tables and sample data using the dialect://table_name resources to help the model reference the schema without exposing raw schema details.
How to install
Prerequisites:
- Python 3.11 or newer
- pip (Python package manager)
Installation steps:
- Install the MCP server from PyPI:
pip install xiyan-mcp-server
- (Optional) Install from source for development:
pip install git+https://github.com/XGenerationLab/xiyan_mcp_server.git
- Prepare a YAML configuration file (config.yml) with your transport, model, and database settings. A minimal example:
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: ""
- Run the MCP server using Python:
python -m xiyan_mcp_server
- (Optional) If you use a different transport (e.g., SSE), adjust the mcp config accordingly and restart the server.
Additional notes
Tips and common issues:
- Ensure your database is reachable from the server host and that the credentials in the config.yml are correct.
- If using the local (non-remote) mode for security, prefer the local LLM configuration and disable API keys as needed.
- The server supports both stdio and SSE transports; pick stdio for simple piping and SSE for web-like streaming.
- You can list and inspect database tables via the {dialect}://resource syntax to aid prompt construction.
- For debugging, set log_level to INFO or DEBUG and examine the generated SQL against your database.
Related MCP Servers
mcp-neo4j
Neo4j Labs Model Context Protocol servers
mcp-redis
The official Redis MCP Server is a natural language interface designed for agentic applications to manage and search data in Redis efficiently
MCPBench
The evaluation benchmark on MCP servers
ReActMCP
ReActMCP is a reactive MCP client that empowers AI assistants to instantly respond with real-time, Markdown-formatted web search insights powered by the Exa API.
legion
A server that helps people access and query data in databases using the Legion Query Runner with Model Context Protocol (MCP) in Python.
pfsense
pfSense MCP Server enables security administrators to manage their pfSense firewalls using natural language through AI assistants like Claude Desktop. Simply ask "Show me blocked IPs" or "Run a PCI compliance check" instead of navigating complex interfaces. Supports REST/XML-RPC/SSH connections, and includes built-in complian