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.
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.
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.
Configure the MCP server in Cursor using one of these methods:
Method 1: Create a configuration file
.cursor
folder in your current projectmcp.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
xtquantai
cmd /c uvx path:\to\xtquantai
Important:
cmd /c
in the command, otherwise the command window will close immediately after executionpath:\to\xtquantai
with the actual path to your XTQuantAI directory# Get trading dates for Shanghai market
dates = get_trading_dates(market="SH")
# Get stock list for A-shares in Shanghai and Shenzhen
stocks = get_stock_list(sector="沪深A股")
# 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"
)
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.
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.
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"
]
}
}
}
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.
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.
To add this MCP server to Claude Desktop:
1. Find your configuration file:
~/Library/Application Support/Claude/claude_desktop_config.json
%APPDATA%\Claude\claude_desktop_config.json
~/.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