Moomoo API MCP Server
Project description
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.
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
Method 1: Quick Start with uvx (Recommended)
If you have uv installed, you can run the server directly without manual installation:
uvx moomoo-api-mcp
Or install it permanently as a tool:
uv tool install moomoo-api-mcp
Method 2: Manual Setup (Development)
Prerequisites
- Python 3.10+
- uv package manager
- Moomoo OpenD gateway installed and running
Steps
-
Clone the repository:
git clone <repository-url> cd moomoo-api-mcp
-
Install dependencies:
uv sync -
Configure OpenD:
- Launch OpenD and log in with your Moomoo account.
- Ensure the gateway is listening on
127.0.0.1:11111(default).
Usage
Run Locally
Start the MCP server:
uv run moomoo-mcp
Environment Variables
To enable REAL account access, set your trading password via environment variable:
| Variable | Description |
|---|---|
MOOMOO_TRADE_PASSWORD |
Your Moomoo trading password (plain text) |
MOOMOO_TRADE_PASSWORD_MD5 |
MD5 hash of your trading password (alternative) |
MOOMOO_SECURITY_FIRM |
Securities firm: FUTUSG (Singapore), FUTUSECURITIES (HK), FUTUINC (US), FUTUAU (AU) |
Note: If both password vars are set,
MOOMOO_TRADE_PASSWORDtakes precedence.
Without these variables, the server runs in SIMULATE-only mode (paper trading).
Generating MD5 Password Hash
If you prefer not to store your plain text password in environment variables, you can generate an MD5 hash using PowerShell:
-
Open PowerShell
-
Run the following command (replace
your_trading_passwordwith your actual password):$password = "your_trading_password" $md5 = [System.Security.Cryptography.HashAlgorithm]::Create("MD5") $utf8 = [System.Text.Encoding]::UTF8 $hash = [System.BitConverter]::ToString($md5.ComputeHash($utf8.GetBytes($password))).Replace("-", "").ToLower() Write-Host "MD5 Hash: $hash"
-
Copy the output hash and set it as
MOOMOO_TRADE_PASSWORD_MD5.
Configure Claude Desktop
Add the server to your claude_desktop_config.json:
{
"mcpServers": {
"moomoo": {
"command": "uv",
"args": [
"--directory",
"C:\\path\\to\\moomoo-api-mcp",
"run",
"moomoo-mcp"
],
"env": {
"MOOMOO_TRADE_PASSWORD": "your_trading_password",
"MOOMOO_SECURITY_FIRM": "FUTUSG"
}
}
}
}
Security: Never commit your password to git. The
envblock in the config file is local-only.
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]
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file moomoo_api_mcp-0.1.0.tar.gz.
File metadata
- Download URL: moomoo_api_mcp-0.1.0.tar.gz
- Upload date:
- Size: 83.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
15110a1ab95849f323cc0c053b37ef4c0daf142cfdc6f7d32679d545d7577469
|
|
| MD5 |
a60927a8d6652ccfc06fe71ee8cb2d75
|
|
| BLAKE2b-256 |
9af5e9c471e6e431ef1e556b7f0cdb5dbbb6a2d3c737bbba51bef4b19ad0bb36
|
Provenance
The following attestation bundles were made for moomoo_api_mcp-0.1.0.tar.gz:
Publisher:
manual-release.yml on Litash/moomoo-api-mcp
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
moomoo_api_mcp-0.1.0.tar.gz -
Subject digest:
15110a1ab95849f323cc0c053b37ef4c0daf142cfdc6f7d32679d545d7577469 - Sigstore transparency entry: 832832378
- Sigstore integration time:
-
Permalink:
Litash/moomoo-api-mcp@0c3cfbf87e036c0b5327d3ad651d827303427470 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/Litash
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
manual-release.yml@0c3cfbf87e036c0b5327d3ad651d827303427470 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file moomoo_api_mcp-0.1.0-py3-none-any.whl.
File metadata
- Download URL: moomoo_api_mcp-0.1.0-py3-none-any.whl
- Upload date:
- Size: 27.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3d239f48865113fe88640c155c1cf993b09102ec36b20bebb859507223bf9329
|
|
| MD5 |
031a77e116afcd5c398a77ba9c0812cb
|
|
| BLAKE2b-256 |
ad8f2171a391263c6cc53a6128b4e70ea8d6d2bd28b94939c5eba88b2c3ed1ba
|
Provenance
The following attestation bundles were made for moomoo_api_mcp-0.1.0-py3-none-any.whl:
Publisher:
manual-release.yml on Litash/moomoo-api-mcp
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
moomoo_api_mcp-0.1.0-py3-none-any.whl -
Subject digest:
3d239f48865113fe88640c155c1cf993b09102ec36b20bebb859507223bf9329 - Sigstore transparency entry: 832832379
- Sigstore integration time:
-
Permalink:
Litash/moomoo-api-mcp@0c3cfbf87e036c0b5327d3ad651d827303427470 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/Litash
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
manual-release.yml@0c3cfbf87e036c0b5327d3ad651d827303427470 -
Trigger Event:
workflow_dispatch
-
Statement type: