Back to MCP Catalog

XiYan SQL MCP Server

DatabasesPython
Natural language interface for database queries
Available Tools

list_tables

Lists all available tables in the connected database

get_table_info

Retrieves schema information for a specific table

execute_sql

Executes a SQL query on the connected database and returns the results

natural_language_query

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.

Overview

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.

Installation Options

Option 1: Install via pip

The simplest way to install XiYan MCP Server is through pip:

pip install xiyan-mcp-server

Option 2: Install via Smithery.ai

You can also install using Smithery:

smithery install @XGenerationLab/xiyan_mcp_server

Configuration

LLM Configuration

XiYan MCP Server supports multiple LLM options:

General LLMs

  • OpenAI GPT models: Set OPENAI_API_KEY environment variable
  • Qwen models: Set DASHSCOPE_API_KEY environment variable

Text-to-SQL SOTA Model

For best performance, use the XiYanSQL model:

  • Set MODELSCOPE_API_KEY environment variable (get from ModelScope)

Local Model

For enhanced security, you can run in local mode:

  • Download the model from HuggingFace
  • Set LOCAL_MODEL_PATH to your downloaded model path

Database Configuration

The server requires database connection information:

MySQL

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

PostgreSQL

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

Launching the Server

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

Connecting to AI Assistants

XiYan MCP Server works with various AI assistants that support the Model Context Protocol:

Claude Desktop

  1. Go to Settings > Developer Settings
  2. Add a new MCP Server with URL: http://localhost:8080

Cline

Add the following to your ~/.config/cline/config.json:

"mcpServers": {
  "xiyan-sql": {
    "url": "http://localhost:8080"
  }
}

Goose

Add the following to your configuration:

"mcpServers": {
  "xiyan-sql": {
    "url": "http://localhost:8080"
  }
}

Cursor

Add the following to your settings:

"mcpServers": {
  "xiyan-sql": {
    "url": "http://localhost:8080"
  }
}

Troubleshooting

If you encounter issues:

  1. Check that your database connection parameters are correct
  2. Verify that your API keys are valid and properly set
  3. Ensure your database user has appropriate permissions
  4. Check server logs for detailed error messages

For more information, visit the GitHub repository or refer to the XiYan-SQL documentation.

Related MCPs

Milvus Vector Database
DatabasesPython

Connect to Milvus vector database for semantic search and vector operations

MotherDuck DuckDB
DatabasesPython

SQL analytics with DuckDB and MotherDuck for AI assistants

Alibaba Cloud Tablestore
DatabasesJava, Python

Connect to Alibaba Cloud Tablestore for vector search and RAG applications

About Model Context Protocol

Model Context Protocol (MCP) allows AI models to access external tools and services, extending their capabilities beyond their training data.

Generate Cursor Documentation

Save time on coding by generating custom documentation and prompts for Cursor IDE.