ths-stock-trading-mcp
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@ths-stock-trading-mcpCheck my account balance and current positions."
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
同花顺 Web Simulated Trading MCP Service
Encapsulates the 同花顺 trading system as a general-purpose MCP service (stdio) that various AI Agents can call.
Practical case study: two MCP services working together for fully automated stock trading
This project's MCP service handles "account holdings" and "order placement/trading".
The 同花顺 iFinD AI 金融数据服务 handles "data-driven stock screening" and "market quote/indicator queries" (同花顺 offers free trial credits).
Once both services are connected to the same AI Agent (such as hermes, codex, claude desktop, workbudy, trae work, and deepseek harness), you only need to tell the AI "trade stocks automatically using strategy XX". It will use iFinD to look up quotes and select stocks, then use the trading service to place orders, cancel orders, and check fills automatically — no manual account operation needed throughout.
Important notices
Start the browser and log in first 同花顺 trading system (see "Prerequisites") before the trading service can place orders.
Only market orders are supported, and quantity must be a multiple of 100. Before buying, the AI first checks your cash; before selling, it first checks your holdings.
AI stock trading — each tool does its own thing, and you are solely responsible for profits and losses. Don't abuse this tool, and never use it commercially.
This project is for simulated trading only. What if your strategy is proven and you want to go to live account? Please contact the author for a solution!
Related MCP server: QMT MCP Server
Prerequisites
Manually start the browser (see
启动浏览器.bat): Chrome with debug port 9222, using a dedicated user data directorychrome_profile.Manually log in to 同花顺 trading system and enter the trading page.
Above conditions are met the MCP service can work normally; otherwise every tool returns a clear Chinese error message.
Environment
Recommended Python version: 3.11 (
mcpdependency reqires>=3.10; 3.10–3.12 all work fine).Python environment:
.venvinside the project (virtual environment; creation covered in the next section).Dependencies:
.venv/Scripts/python.exe -m pip install -r requirements.txt.Notes: Playwright connects to the already-open browser via CDP, no browser kernel needs to be downloaded; it stores no account credentials, and fully relies on the manually logged-in session.
Create the Python virtual env
On first use, create .venv under the project root (choose one of the two methods):
# 方式一:标准库 venv(需本机已安装 Python 3.11,可用 py -3.11 指定版本)
py -3.11 -m venv .venv
# 方式二:uv(更快,未装对应版本时自动下载,推荐)
uv venv --python 3.11 .venvAfter that install the dependencies:
.venv/Scripts/python.exe -m pip install -r requirements.txtOn Windows the interpreter is
.venv/Scripts/python.exe(on Linux/macOS:.venv/bin/python); all commands below assume.venv/Scripts/python.exe.
MCP configuration guide
This service runs over stdio transport, any MCP-capable client can connect. The core config is just one line: start server.py with the Python interpreter of the project's .venv.
Connection config (works for all AI Agents)
{
"mcpServers": {
"ths-stock-trading-mcp": {
"command": "D:/workspace_github/ai_ths_moni_trading_mcp/.venv/Scripts/python.exe",
"args": ["D:/workspace_github/ai_ths_moni_trading_mcp/server.py"]
}
}
}On Windows use forward slash paths
D:/...; if your.venvlives elsewhere, adjustcommand.
Verify
After connecting you should see 5 tools: query_account_and_positions / query_deals / query_orders / place_order / cancel_order. Use query_account_and_positions for connectivity test (the browser must be logged in).
Tools
Tool | Description |
| View account funds and holdings (available balance, fund balance, total assets, securities market value, and holding details) |
| View today's fills |
| View today's orders |
| Market order buy/sell ( |
| Cancel unfilled order ( |
Testing
.venv/Scripts/python.exe -m pytest -v # 单元测试
PYTHONPATH=. .venv/Scripts/python.exe scripts/e2e.py # 真实浏览器端到端(需已登录浏览器)
PYTHONPATH=. .venv/Scripts/python.exe scripts/mcp_smoke.py # MCP stdio 协议冒烟Service configuration
config.yaml in the project root:
cdp_endpoint: Crochrome remote debugging address, defaulthttp://127..0.1:9222. If you change the debug port in启动浏览器.bat, sync this setting.refresh_before_tool: whether to refresh the trading page to detect session timeout before each MCP tool run.true(default) = reload the trading page first and detect session, auto close stale tabs and re-enter trading area on timeout;false= old fast path (refresh only when account number whose reload indicates an issue). If 8/18 order-failure issues (quotes failing to load after refresh) recur, setfalseas a one-click rollback.delays: per-step delays in ms during ordering/canceling, you can tune them individually to improve success rate. Ifquote_timeoutfires, it will NOT click the order button and just return "Order failed: quote data not loaded... pending order not submitted";js_settleis delay to wait after an optional page reload JS init (default, 3000). Unconfigured keys automatically use defaults (menu 300 / panel 800 / quotes popup timeout 8000 / cancel permanent delay 1000 / JS ready 3000).
Slow observation mode
MCP tools operate browser very fast by default (1–2 seconds total), not friendly for human step-by-step watch and verify. via config.yaml's slow_ms you can enable slow-down mode: delay that many ms between each browser operation, and print Chinese step in your log (like "fill securities code 600000 and press enter to load quote", "click buy order submit").
In config.yaml set slow_ms to 1200, then restart the MCP service session:
# config.yaml
slow_ms: 1200Set it to 0 to go back to original speed. Using a config file rather than Environment variable is to keep compatible with all AI Agent clients that don't support env variables.
Known limitations
Placing order depends on platform back-end quote service; sometimes returns "temporarily no service[柜台 securities quote (B)]/back-end code (B)" — that's platform-side temporary fault, retry or try later.
Cancellation only works while the order is "unfilled". Already-filled/cancelled orders don't show in the cancelable list,
cancel_orderreturns a clear message.
目录结构
server.py— MCP entry point (FastMCP, stdio)config.yaml— service config (slow observation mode etc.).mcp.json— Claude integration entry configths/— business logic (browser control, selectors, parsing, page ops, errors)scripts/— sabotage / end-to-end / protocol smoketest scriptstests/— unit tests and real-page fixtures
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- FlicenseNot gradedqualityBmaintenanceProvides AI clients access to TdxQuant/通达信 financial data and trading capabilities through MCP. Enables retrieval of market data, financial reports, sector information, and trading operations via stdio or HTTP/SSE connections.25
- FlicenseNot gradedqualityBmaintenanceWraps the miniQMT interface to enable AI assistants to query A-share market data, account information, and place/cancel orders.
- AlicenseNot gradedqualityBmaintenanceEnables AI agents to perform A-share quantitative backtesting by calling TickTest API through MCP protocol.MIT

EasyQuote MCP Serverofficial
AlicenseNot gradedqualityAmaintenanceEnables AI agents to access real-time and historical stock market data for A-shares, Hong Kong, US, and global markets, including quotes, K-lines, fund flows, fundamentals, and board data, via a Python SDK and MCP protocol.1MIT
Related MCP Connectors
Read-only China A-share data for AI agents: market, limit-up, capital flow and disclosures.
MCP server exposing the Backtest360 engine API as tools for AI agents.
Provide access to Chinese stock market data including historical prices, real-time data, news, and…
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/trading-a/ai_ths_moni_trading_mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server