XiYan
๐ โ๏ธ โ An MCP server that supports fetching data from a database using natural language queries, powered by XiyanSQL as the text-to-SQL LLM.
What is XiYan?
XiYan is a Model Context Protocol (MCP) server that allows AI assistants like Claude, Cursor, and VS Code to ๐ โ๏ธ โ an mcp server that supports fetching data from a database using natural language queries, powered by xiyansql as the text-to-sql llm.
๐ โ๏ธ โ An MCP server that supports fetching data from a database using natural language queries, powered by XiyanSQL as the text-to-SQL LLM.
This server falls under the Databases category on MCPgee, the world's largest MCP server directory with 33,000+ servers.
Features
- ๐ โ๏ธ โ An MCP server that supports fetching data from a data
Use Cases
Maintainer
Works with
Installation
Manual Installation
npx xiyan-mcp-serverConfiguration
Configuration Details
claude_desktop_config.json
Performance
Response Metrics
Resource Usage
How to Set Up and Use XiYan
XiYan MCP Server lets AI assistants query MySQL and PostgreSQL databases using plain natural language, powered by XiYanSQL, the state-of-the-art text-to-SQL model that ranks at the top of the BIRD benchmark. The server converts a natural language question into a SQL query, executes it against your configured database, and returns the results โ without requiring the user to know SQL. Data analysts, business users, and developers who want conversational database access without exposing query syntax use this server in Claude Desktop, Cursor, Cline, or Goose.
Prerequisites
- Python 3.11 or higher
- pip or uv package manager
- A running MySQL or PostgreSQL database accessible from your machine
- An API key for a supported LLM (Modelscope, Alibaba DashScope, or OpenAI-compatible endpoint) or a locally running XiYanSQL model
- An MCP-capable client such as Claude Desktop, Cursor, Cline, or Goose
Install the package from PyPI
Install xiyan-mcp-server into your Python environment. Python 3.11+ is required.
pip install xiyan-mcp-serverCreate the YAML configuration file
Copy the demo config and fill in your LLM credentials and database connection details. The model name, key, and url select which text-to-SQL backend to use.
cat config_demo.ymlConfigure the YAML with your credentials
Edit the config file with your actual values. Using the Modelscope-hosted XiYanSQL-QwenCoder-32B model gives the best accuracy. Set database.host, port, user, password, and database to match your setup.
mcp:
transport: "stdio"
model:
name: "XGenerationLab/XiYanSQL-QwenCoder-32B-2412"
key: "YOUR_MODELSCOPE_API_KEY"
url: "https://api-inference.modelscope.cn/v1/"
database:
host: "localhost"
port: 3306
user: "root"
password: "your_password"
database: "your_database_name"Add to Claude Desktop configuration
Open ~/Library/Application Support/Claude/claude_desktop_config.json and add a mcpServers entry that launches the server with your config file.
{
"mcpServers": {
"xiyan-mcp": {
"command": "python",
"args": ["-m", "xiyan_mcp_server", "--config", "/path/to/your/config.yml"]
}
}
}Verify table resources are visible
The server exposes your database tables as MCP resources using the pattern mysql://table_name or postgresql://table_name. Ask your AI assistant to list available tables to confirm the connection is working.
Query data with natural language
Use the get_data tool by asking questions in plain language. The server translates your question to SQL using XiYanSQL, executes it, and returns results.
XiYan Examples
Claude Desktop configuration
MCP config block using the installed xiyan_mcp_server module with a local YAML config file.
{
"mcpServers": {
"xiyan-mcp": {
"command": "python",
"args": ["-m", "xiyan_mcp_server", "--config", "/Users/you/xiyan/config.yml"]
}
}
}Prompts to try
Example natural language queries that the server converts to SQL and executes against your database.
- "Show me the top 10 customers by total order value this year"
- "How many new users signed up each month in 2025?"
- "Which products have inventory below 50 units?"
- "List all orders that haven't shipped yet, sorted by order date"
- "What is the average session duration by country last week?"Troubleshooting XiYan
Connection refused when the server tries to reach the database
Verify that host, port, user, password, and database in your YAML config match your actual database. For MySQL the default port is 3306; for PostgreSQL it is 5432. Ensure the database user has SELECT privileges.
Model API key error or 401 Unauthorized from the LLM endpoint
Check that the 'key' field in config.yml is a valid API key for the chosen provider. For Modelscope, generate a key at modelscope.cn. For OpenAI-compatible endpoints, ensure the 'url' matches the provider's base URL exactly.
Generated SQL returns wrong results or fails to execute
The XiYanSQL model performs best when table and column names are descriptive. If results are inaccurate, try rephrasing with column names that match your schema, or switch from a general LLM (gpt-3.5-turbo) to the specialist XiYanSQL-QwenCoder-32B model.
Frequently Asked Questions about XiYan
What is XiYan?
XiYan is a Model Context Protocol (MCP) server that ๐ โ๏ธ โ an mcp server that supports fetching data from a database using natural language queries, powered by xiyansql as the text-to-sql llm. It connects AI assistants to external tools and data sources through a standardized interface.
How do I install XiYan?
Follow the installation instructions on the XiYan GitHub repository. Clone the repo, install dependencies, and add the server config to your AI client.
Which AI clients work with XiYan?
XiYan works with all major MCP-compatible AI clients including Claude Desktop, Claude Code, Cursor, VS Code (GitHub Copilot), Windsurf, and Cline.
Is XiYan free to use?
Yes, XiYan is open source and available under the Apache 2.0 license. You can use it freely in both personal and commercial projects.
XiYan Alternatives โ Similar Databases Servers
Looking for alternatives to XiYan? Here are other popular databases servers you can use with Claude, Cursor, and VS Code.
Excelize
โ 20.6kGo language library for reading and writing Microsoft Excelโข (XLAM / XLSM / XLSX / XLTM / XLTX) spreadsheets
MCP Toolbox for Databases
โ 15.3kOpen source MCP server specializing in easy, fast, and secure tools for Databases.
DBHub
โ 2.8kA universal database gateway MCP server that enables AI assistants to connect to and query multiple databases (PostgreSQL, MySQL, MariaDB, SQL Server, SQLite) with support for schema exploration, SQL execution, and secure connections via SSH tunnels.
Tabularis
โ 2.1kA lightweight, cross-platform database client for developers. Supports MySQL, PostgreSQL and SQLite. Hackable with plugins. Built for speed, security, and aesthetics.
Postgres AI Guide
โ 1.7kMCP server and Claude plugin for Postgres skills and documentation. Helps AI coding tools generate better PostgreSQL code.
Anyquery
โ 1.7k๐๏ธ ๐ โ๏ธ - Query more than 40 apps with one binary using SQL. It can also connect to your PostgreSQL, MySQL, or SQLite compatible database. Local-first and private by design.
Browse More Databases MCP Servers
Explore all databases servers available in the MCPgee directory. Each server includes setup guides for Claude, Cursor, and VS Code.
Set Up XiYan in Your Editor
Choose your AI client for step-by-step setup instructions.
Quick Config Preview
Add this to your claude_desktop_config.json or .cursor/mcp.json
Ready to use XiYan?
Browse our complete directory of 33,000+ MCP servers, read setup guides for your editor, and start building with the Model Context Protocol.