XTQuant AI MCP server

Lightweight Python server for quantitative trading using XTQuant API, enabling real-time stock market interactions and AI-driven financial analysis strategies.
Back to servers
Setup instructions
Provider
davidfnck
Release date
Mar 11, 2025
Language
Python
Stats
81 stars

XTQuantAI is a server based on the Model Context Protocol (MCP) that integrates the XTQuant quantitative trading platform with AI assistants, enabling AI to directly access and operate quantitative trading data and functions.

Installation

Prerequisites

  • Python 3.11 or higher
  • XTQuant QMT or research terminal (Windows only)
  • uv package management tool (recommended)

Installing uv

The uv tool is essential for running the package. Install it in the environment where you plan to run XTQuantAI:

pip install uv

Note: uv maintains a cache. If you encounter errors during setup, you may need to clear the cache using the provided clear_cache_and_run.py script.

Installing XTQuantAI

Download the package by cloning the repository:

git clone https://github.com/dfkai/xtquantai.git

Alternatively, you can download the ZIP archive directly. Save it to any folder as long as you can locate the exact path to the XTQuantAI directory.

Usage

Integration with Cursor

Windows Setup (Required as QMT/Research Terminal only supports Windows)

Configure the MCP server in Cursor using one of these methods:

Method 1: Create a configuration file

  1. Create a .cursor folder in your current project
  2. Create an mcp.json file in the .cursor folder with the following content:
{
  "mcpServers": {
    "xtquantai": {
      "command": "cmd /c uvx",
      "args": [
        "path:\\to\\xtquantai"
      ]
    }
  }
}

Method 2: Add through settings

  1. Go to Settings → MCP → Add new MCP Server
  2. Name: xtquantai
  3. Command: cmd /c uvx path:\to\xtquantai
  4. Set to Enabled

Important:

  • On Windows, always include cmd /c in the command, otherwise the command window will close immediately after execution
  • Replace path:\to\xtquantai with the actual path to your XTQuantAI directory
  • Use single backslashes when entering the path manually, double backslashes are only needed in JSON files

Usage Examples

Getting Trading Dates

# Get trading dates for Shanghai market
dates = get_trading_dates(market="SH")

Getting Stock Lists

# Get stock list for A-shares in Shanghai and Shenzhen
stocks = get_stock_list(sector="沪深A股")

Creating Chart Panels

# Create a chart panel with MA indicator
result = create_chart_panel(
    codes="000001.SZ,600519.SH",
    period="1d",
    indicator_name="MA",
    param_names="period",
    param_values="5"
)

Features

Basic Data Queries

  • get_trading_dates - Get trading dates for a specified market
  • get_stock_list - Get a list of stocks for a specific sector
  • get_instrument_detail - Get detailed information about stocks

Market Data

  • get_history_market_data - Get historical market data for stocks
  • get_latest_market_data - Get latest market data for stocks
  • get_full_market_data - Get complete market data for stocks

Charts and Visualization

  • create_chart_panel - Create stock chart panels with various technical indicators
  • create_custom_layout - Create custom chart layouts with specified indicator names, parameter names, and values

How to install this MCP server

For Claude Code

To add this MCP server to Claude Code, run this command in your terminal:

claude mcp add-json "xtquantai" '{"command":"cmd /c uvx","args":["path:\\to\\xtquantai"]}'

See the official Claude Code MCP documentation for more details.

For Cursor

There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.

If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.

Adding an MCP server to Cursor globally

To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

{
    "mcpServers": {
        "xtquantai": {
            "command": "cmd /c uvx",
            "args": [
                "path:\\to\\xtquantai"
            ]
        }
    }
}

Adding an MCP server to a project

To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.

How to use the MCP server

Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.

The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.

You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.

For Claude Desktop

To add this MCP server to Claude Desktop:

1. Find your configuration file:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json
  • Linux: ~/.config/Claude/claude_desktop_config.json

2. Add this to your configuration file:

{
    "mcpServers": {
        "xtquantai": {
            "command": "cmd /c uvx",
            "args": [
                "path:\\to\\xtquantai"
            ]
        }
    }
}

3. Restart Claude Desktop for the changes to take effect

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later