Lists all available tables in the connected database
Retrieves schema information for a specific table
Executes a SQL query on the connected database and returns the results
Converts natural language to SQL and executes the query on the database
XiYan MCP Server enables natural language queries to databases, powered by XiYan-SQL, a state-of-the-art text-to-SQL model. It allows users to interact with MySQL and PostgreSQL databases using plain English, eliminating the need to write complex SQL queries manually. The server supports both remote mode with API-based models and a secure local mode for enhanced privacy.
XiYan MCP Server provides a natural language interface to your databases, allowing you to query data using plain English instead of writing SQL. Powered by XiYan-SQL, which achieves state-of-the-art performance on text-to-SQL benchmarks, this server bridges the gap between natural language processing and database management.
The simplest way to install XiYan MCP Server is through pip:
pip install xiyan-mcp-server
You can also install using Smithery:
smithery install @XGenerationLab/xiyan_mcp_server
XiYan MCP Server supports multiple LLM options:
OPENAI_API_KEY
environment variableDASHSCOPE_API_KEY
environment variableFor best performance, use the XiYanSQL model:
MODELSCOPE_API_KEY
environment variable (get from ModelScope)For enhanced security, you can run in local mode:
LOCAL_MODEL_PATH
to your downloaded model pathThe server requires database connection information:
export DB_TYPE=mysql
export DB_HOST=your_mysql_host
export DB_PORT=3306
export DB_USER=your_username
export DB_PASSWORD=your_password
export DB_NAME=your_database_name
export DB_TYPE=postgresql
export DB_HOST=your_postgresql_host
export DB_PORT=5432
export DB_USER=your_username
export DB_PASSWORD=your_password
export DB_NAME=your_database_name
After configuration, start the server:
xiyan-mcp-server
By default, the server runs on port 8080. You can specify a different port:
xiyan-mcp-server --port 8081
For streaming responses (recommended):
xiyan-mcp-server --sse
XiYan MCP Server works with various AI assistants that support the Model Context Protocol:
Add the following to your ~/.config/cline/config.json
:
"mcpServers": {
"xiyan-sql": {
"url": "http://localhost:8080"
}
}
Add the following to your configuration:
"mcpServers": {
"xiyan-sql": {
"url": "http://localhost:8080"
}
}
Add the following to your settings:
"mcpServers": {
"xiyan-sql": {
"url": "http://localhost:8080"
}
}
If you encounter issues:
For more information, visit the GitHub repository or refer to the XiYan-SQL documentation.