Get the FREE Ultimate OpenClaw Setup Guide →

xiyan_mcp_server

A Model Context Protocol (MCP) server that enables natural language queries to databases

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
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:

  1. Install the MCP server from PyPI:
pip install xiyan-mcp-server
  1. (Optional) Install from source for development:
pip install git+https://github.com/XGenerationLab/xiyan_mcp_server.git
  1. 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: ""
  1. Run the MCP server using Python:
python -m xiyan_mcp_server
  1. (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

Sponsor this space

Reach thousands of developers