SuperAPI AI Directory

xiyan_mcp_server

Fetch data from databases with natural-language queries, using XiyanSQL as the text-to-SQL model.

Open website

About this tool

XiYan MCP Server is a Model Context Protocol (MCP) server designed to query databases via natural language. It is powered by XiYan-SQL, which is a state-of-the-art model for text-to-SQL on open benchmarks.

Purpose

The server converts natural language queries into SQL statements and executes them to retrieve data from the database.

Key Capabilities

  • Retrieve data via natural language using XiYanSQL.
  • Supports general-purpose LLMs (GPT, qwenmax) as well as state-of-the-art text-to-SQL models.
  • Supports a fully local mode (high security!).
  • Supports MySQL and PostgreSQL.
  • Lists available tables as resources.
  • Reads table contents.

Usage

Installation

Requires Python 3.11+. The latest version can be installed via pip. To install the development version, you can install from the GitHub source. It can also be installed from Smithery.ai (not fully tested).

Configuration

A YAML configuration file is required; a default configuration file config_demo.yml is provided.

MCP Configuration

The transport protocol can be set to stdio or sse. The default port is 8000. The default log level is ERROR; it is recommended to set it to INFO. debug, host, sse_path, message_path, etc. can be customized and usually do not need to be changed.

LLM Configuration

name is the model name, key is the API key, and url is the API address. The following models are supported:

  • General-purpose LLMs (such as gpt3.5) can be configured directly.
  • Alibaba Qwen (such as Qwen-max) can use a specific configuration. It is recommended to use XiYanSQL-qwencoder-32B (a state-of-the-art text-to-SQL model). There are two ways to use it: (1) Modelscope, (2) Alibaba Cloud DashScope. You need to apply for an API-inference key from Modelscope. For DashScope, you need to set environment variables and send an email to godot.lzl@alibaba-inc.com to obtain a key; the key is valid for 1 month or 200 queries. You can also deploy the model yourself.

Database Configuration

host, port, user, password, and database are connection information. Local or remote databases are supported; currently MySQL and PostgreSQL are supported (more dialects will be supported soon). For PostgreSQL, dialect should be set to postgresql.

Starting

  • If using sse, run the command in the terminal, then visit in the browser http://localhost:8000/sse。
  • If using stdio, it is usually declared as a command in a specific MCP application, and the command can also be used for debugging.

It supports use in applications such as Claude Desktop, Cline, Goose, and Cursor. Claude Desktop currently does not support the SSE transport protocol.

Applicable Scenarios

Suitable for scenarios that require quickly querying databases via natural language, especially for tasks such as data analysis and report generation that require writing SQL.

Limitations

  • Only MySQL and PostgreSQL are supported.
  • Remote mode requires an API key, and the key has usage limits.
  • Local mode requires deploying the model yourself.
  • Specific information such as fees and pricing is not explicitly mentioned.
  • Some features (such as installation from Smithery.ai) have not been fully tested.

Tools

  • get_data: provides a natural language interface to retrieve data from the database. The server uses the built-in model to convert the input natural language into SQL and calls the database to return the query results.
  • {dialect}://{table_name} resource: when table_name is specified, some sample data can be obtained for the model's reference.
  • {dialect}:// resource: lists the current database names.