
XiYan MCP Server
OfficialNatural-language queries to MySQL/PostgreSQL via XiYanSQL text-to-SQL
Add to your client
Copy the config for your MCP client and paste it into its config file.
pip install xiyan-mcp-serverPaste into ~/Library/Application Support/Claude/claude_desktop_config.json
{
"mcpServers": {
"xiyan-mcp-server": {
"command": "/xxx/python",
"args": [
"-m",
"xiyan_mcp_server"
],
"env": {
"YML": "PATH/TO/YML"
}
}
}
}Step-by-step guides: Add to Claude Desktop · Add to Cursor · Add to Windsurf
Before you start
- Python 3.11+
- A YAML config file (referenced via the YML env var) with model and database settings
- A MySQL or PostgreSQL database
- For PostgreSQL: pip install psycopg2
- For remote model mode: an API key from the model service provider (e.g. Modelscope, OpenAI, Alibaba Cloud DashScope)
About XiYan MCP Server
An MCP server that enables natural language queries to MySQL and PostgreSQL databases, powered by XiYanSQL (SOTA text-to-SQL). Input natural language is converted to SQL by a built-in/configured model, executed against the database, and the results are returned. Supports general LLMs, the XiYanSQL-QwenCoder SOTA model (remote, default), and a pure local mode for high security.
Tools & capabilities (1)
get_dataProvides a natural language interface for retrieving data from a database. Converts the input natural language into SQL using a built-in/configured model and calls the database to return the query results.
When to use it
- Querying a MySQL or PostgreSQL database using plain natural language instead of writing SQL
- Building a local data assistant that turns questions into database queries
- Letting an LLM client explore database tables and sample their contents as resources
- Running text-to-SQL fully locally (local model mode) when data security is a priority
Security notes
Configuration (including database credentials and the model API key) lives in a YAML file referenced by the YML env var. The default remote mode sends database schema/sample data to the configured model service provider and requires an API key. A pure local model mode is available for higher security and needs no API key. The Claude Desktop / Cursor config requires the full absolute path to the Python executable (e.g. from `which python`).
XiYan MCP Server FAQ
Which databases are supported?
MySQL and PostgreSQL. For PostgreSQL you must install psycopg2 and set dialect: "postgresql" in the YAML config. More dialects are planned.
Do I need an API key?
In the default remote mode you need an API key for the model service provider (e.g. Modelscope, OpenAI, or Alibaba Cloud DashScope). In pure local mode you deploy the model on your own server and no API key is required.
Which transports are supported?
stdio (default) and sse. The sse server runs on port 8000 by default (e.g. http://localhost:8000/sse). Note that Claude Desktop does not support the SSE transport.
Why does the config use a full path to Python?
The MCP client config requires the complete absolute path to the Python executable (e.g. /xxx/python from `which python`); otherwise the Python interpreter cannot be found. Database credentials and the model key are supplied via the YAML file referenced by the YML env var.
Alternatives to XiYan MCP Server
Compare all alternatives →Google's official MCP server with prebuilt BigQuery tools, querying datasets via Application Default Credentials.
Read/write Postgres access plus index tuning, EXPLAIN plans, and database health analysis for AI agents.
Official Supabase server: manage tables, run SQL, branches, configs and edge functions from your AI client.
Compare XiYan MCP Server with: