moomoo-api-mcp
Enables AI agents to access real-time market data, manage Moomoo trading accounts, and execute trades via the Moomoo platform.
README
Moomoo API MCP Server
An MCP (Model Context Protocol) server for the Moomoo trading platform. This server allows AI agents (like Claude Desktop or Gemini) to access market data, account information, and execute trades via the moomoo-api Python SDK.
🚀 Build Your Own Trading Agent
Take your trading to the next level with AI!
This MCP server empowers developers to build custom trading skills and strategies. By integrating this tool, you can enable any compatible AI agent to interact directly with the Moomoo platform on your behalf. Whether you want an AI assistant that monitors the market, analyzes your portfolio, or automatically executes complex trading strategies, this server provides the seamless bridge between your custom AI logic and Moomoo's powerful trading infrastructure.
Features
- Market Data: Real-time quotes, historical K-lines, market snapshots, and order books.
- Account Management: Comprehensive account summaries, assets, positions, and cash flow analysis.
- Trading: Full order management including placing, modifying, and canceling orders.
- System Health: Built-in health checks and connectivity verification.
- Extensible Architecture: Built on FastMCP for easy extension of trading capabilities.
Tools
System
check_health: Check connectivity to Moomoo OpenD gateway and server health.
Account
get_accounts: List all trading accounts (REAL and SIMULATE).get_account_summary: Get a complete summary of assets and positions for an account.get_assets: Retrieve account assets (cash, market value, buying power).get_positions: Get current stock positions with P/L data.get_max_tradable: Calculate maximum tradable quantity for a specific stock.get_margin_ratio: Check margin ratios for specific stocks.get_cash_flow: Retrieve historical cash flow records.unlock_trade: Unlock trading access for REAL accounts.
Market Data
get_stock_quote: Get real-time stock quotes.get_historical_klines: Retrieve historical candlestick data (Day, Week, Min, etc.).get_market_snapshot: Get efficient market snapshots for multiple stocks.get_order_book: View real-time bid/ask order book depth.
Trading
place_order: Place a new order (Market, Limit, Stop, etc.).modify_order: Modify price or quantity of an open order.cancel_order: Cancel an open order.get_orders: Get list of orders for the current day.get_deals: Get list of executed trades (deals) for the current day.get_history_orders: Search historical orders.get_history_deals: Search historical deals.
Installation
Quick Start (Recommended)
You can run the server directly using uvx (part of the uv toolkit).
Using --refresh ensures you are always running the latest version:
# Optional: Set these environment variables for REAL trading access.
# If omitted, the server will safely run in SIMULATE-only (paper trading) mode.
export MOOMOO_TRADE_PASSWORD="your_trading_password"
export MOOMOO_SECURITY_FIRM="FUTUSG" # e.g. FUTUSG, FUTUINC, etc.
uvx --refresh moomoo-api-mcp
Permanent Installation
To install it as a persistent tool available in your shell:
uv tool install moomoo-api-mcp
# Optional: Set these environment variables for REAL trading access.
# If omitted, the server will safely run in SIMULATE-only (paper trading) mode.
export MOOMOO_TRADE_PASSWORD="your_trading_password"
export MOOMOO_SECURITY_FIRM="FUTUSG" # e.g. FUTUSG, FUTUINC, etc.
# Then run:
moomoo-api-mcp
Note: The
moomoo-apiPython SDK and other dependencies will be installed automatically.
Development Setup
-
Clone the repository:
git clone https://github.com/Litash/moomoo-api-mcp.git cd moomoo-api-mcp -
Install dependencies:
uv sync -
Run locally:
uv run moomoo-api-mcp
Configuration
1. Prerequisites
Moomoo OpenD (Required)
The MCP server communicates with the Moomoo API via Moomoo OpenD, a local gateway application. You MUST install and run this first.
-
Download OpenD:
- Visit the Moomoo Open API Download Page.
- Download the version appropriate for your OS (Windows/Mac/Linux).
-
Install & Run:
- Install the application.
- Launch Moomoo OpenD.
- Log in with your Moomoo account credentials.
-
Configure:
- Ensure the listening port is set to
11111(this is the default). - Note: The MCP server connects to
127.0.0.1:11111by default.
- Ensure the listening port is set to
2. Environment Variables
To enable REAL account access, you must securely provide your credentials.
| Variable | Description | Example |
|---|---|---|
MOOMOO_TRADE_PASSWORD |
Your trading password (plain text) | 123456 |
MOOMOO_SECURITY_FIRM |
Your broker region (e.g., FUTUSG, FUTUINC) | FUTUSG |
Note: Without these, the server runs in SIMULATE-only mode (paper trading).
3. Configure Claude Desktop
Add the server to your claude_desktop_config.json:
Option A: Using PyPI Package (Recommended)
{
"mcpServers": {
"moomoo": {
"command": "uvx",
"args": ["--refresh", "moomoo-api-mcp"],
"env": {
"MOOMOO_TRADE_PASSWORD": "your_trading_password",
"MOOMOO_SECURITY_FIRM": "FUTUSG"
}
}
}
}
Note: The
--refreshflag ensures you always have the latest version but may increase startup time due to version checking. You can remove it once you have the correct version installed.
Option B: Local Development
{
"mcpServers": {
"moomoo": {
"command": "uv",
"args": [
"--directory",
"C:\\path\\to\\moomoo-api-mcp",
"run",
"moomoo-api-mcp"
],
"env": {
"MOOMOO_TRADE_PASSWORD": "your_trading_password",
"MOOMOO_SECURITY_FIRM": "FUTUSG"
}
}
}
}
Security: Never commit your password to version control. The
envblock in the config file remains local.
AI Agent Guidance
IMPORTANT: All account tools default to REAL trading accounts.
When using this MCP server, AI agents MUST:
-
Notify the user clearly before accessing REAL account data. Example:
"I'm about to access your REAL trading account. This will show your actual portfolio and balances."
-
Follow the unlock workflow for REAL accounts:
- First call
unlock_trade(it handles env vars automatically, or pass password if needed). - Then call account/trading tools (they default to
trd_env='REAL').
- First call
-
Only use SIMULATE accounts when explicitly requested by the user. To use simulation:
- Pass
trd_env='SIMULATE'parameter explicitly. - No unlock is required for simulation accounts.
- Pass
Workflow Example
User: "Show me my portfolio"
Agent Response:
"I'm accessing your REAL trading account to show your portfolio.
If you prefer to use a simulation account instead, please let me know."
[Proceeds to unlock_trade → get_account_summary]
Order Status Filter Usage
When using get_orders or get_history_orders, the status_filter_list parameter accepts an array of string values:
["SUBMITTED", "FILLED_ALL", "CANCELLED_ALL"]
Valid status strings:
UNSUBMITTED,WAITING_SUBMIT,SUBMITTING,SUBMIT_FAILEDSUBMITTED,FILLED_PART,FILLED_ALLCANCELLING_PART,CANCELLING_ALL,CANCELLED_PART,CANCELLED_ALLREJECTED,DISABLED,DELETED,FAILED,NONE
Note: The server automatically converts these strings to the required SDK enum format. If no orders match the filter, an empty list is returned.
License
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.
Disclaimer
Unofficial Project: This software is an independent open-source project and is not affiliated with, endorsed by, or sponsored by Moomoo Inc., Futu Holdings Ltd., or their affiliates.
- Use at your own risk: Trading involves financial risk. The authors provide this software "as is" without warranty of any kind.
- Test First: Always test your agents and tools in the Simulation (Paper Trading) environment before using real funds.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。