tzzb-mcp
tzzb-mcp
同花順投資帳本 MCP サービス(Tonghuashun Investment Ledger MCP Server)
MCP(Model Context Protocol) を通じて、個人の複数口座の保有明細、資産トレンド、取引記録、リアルタイム相場、ウォッチリストを照会します。AI アシスタント(WorkBuddy など)に接続すると、自然言語で投資帳本データを直接照会できます。
機能特徴
13 個の MCP ツール:ログイン認証、口座、保有、トレンド、取引、相場、為替、取引日、ウォッチリスト照会をカバー
複数口座対応:証券口座、手動口座、信用取引口座(
fund_key/manual_id/rzrq_fund_keyで区別)CDP ブラウザプロキシ:すべての API リクエストは Chrome DevTools Protocol 経由でブラウザ内で実行され、ブラウザのネイティブネットワークスタックを再利用して、Python 直接接続時の 401 アンチクローリング遮断を回避
独立した Chrome Profile(
~/.tzzb_chrome_profile):日常のブラウザ使用に影響なしCookie 永続化(
~/.tzzb_cookies.json):1 回のログインで約 7 日間は再ログイン不要切断時自動再接続:CDP 接続が切断された場合、自動的に再接続を 1 回試行
Related MCP server: Stock MCP Server
環境要件
Python ≥ 3.10
Chrome ブラウザがインストール済みであること
インストール
cd tzzb-mcp
pip install .依存関係:mcp>=1.0.0、websocket-client>=1.8.0、pydantic>=2.0.0。
インストール後、コマンド tzzb-mcp でサービスを起動できます(エントリポイントは pyproject.toml の [project.scripts] に定義)。
MCP 設定
MCP クライアント(WorkBuddy の mcp.json など)で stdio 方式により接続します:
{
"mcpServers": {
"tzzb-mcp": {
"command": "python",
"args": ["-m", "src.server"],
"cwd": "/path/to/tzzb-mcp"
}
}
}cwd はプロジェクトディレクトリ(src/ を含むディレクトリ)を指す必要があります。
クイックスタート
初回使用時は必ず tzzb_login を呼び出してください:このツールは Chrome デバッグインスタンスを起動し、ブラウザで投資帳本(tzzb.10jqka.com.cn)にログインする必要があります。ログイン成功後、Cookie は自動的に抽出され永続化されます。
1. tzzb_login → 弹出 Chrome,手动登录投资账本
2. tzzb_account_list → 获取所有账户的 fund_key / manual_id
3. tzzb_positions → 查看持仓明细日常の照会:
1. tzzb_account_list → 获取账户列表
2. tzzb_positions → 查看具体持仓
3. tzzb_asset_trend → 查看收益走势(可选)ツール一覧
ツール名 | 用途 |
| 投資帳本にログインし、Cookie を抽出・永続化(初回必須) |
| 現在のログイン状態を確認 |
| 全口座リストを取得( |
| 口座概要(インターフェース利用不可時は自動フォールバック) |
| ポートフォリオ概要(account_summary と同様、フォールバック含む) |
| 保有明細を取得(株式 + ファンド)⭐ |
| 資産 / 収益トレンドデータを取得 |
| 当日の分足収益データを取得 |
| 当日の取引記録を取得 |
| 株式のリアルタイム相場を取得 |
| 香港ドルから人民元への為替レートを取得 |
| 直近の取引日情報を取得 |
| ウォッチリストの株式とファンドを取得 |
⭐ は最もよく使うツールを示します。
使用ルールと注意事項
並列呼び出し禁止:すべてのツールは同じ Chrome CDP 接続を共有します(内部にグローバルロックあり)。一度に呼び出せるツールは 1 つのみで、直列に呼び出してください。
保有照会の前に口座リストを取得:
tzzb_positionsのfund_key/manual_idパラメータはtzzb_account_listから取得します。パラメータを渡さない場合は全口座の集計データを返します(空の場合あり)。相場形式は
市場:コード:上海は33(例:33:600519)、深センは47(例:47:000001)。保有データのmarketフィールドは"2"が上海(33)、"1"が深セン(47)に対応します。ファンド保有インターフェースは利用不可:
tzzb_positionsが返すfundフィールドは常に{"error": "基金持仓接口不可用"}です(基盤インターフェースが HTTP 400 を返すため、保護が組み込まれています)。fundフィールドは無視し、stockデータのみを使用してください。フィールド名はピンイン略称:相場は
xianjia(現在値)、zuoshou(前日終値)、zqdm(コード)、scdm(市場)を返します。表示時は中国語にマッピングする必要があります。数値フィールドが文字列の場合あり:保有 / 相場の数値(例:
"300"、"18.09")は文字列型です。使用時に変換に注意してください。日付形式
YYYYMMDD:資産トレンドが返すdateはYYYYMMDD(例:20260827)で、表示時はYYYY-MM-DDに変換します。切断時自動リトライ:ツール呼び出しが失敗した場合(CDP 接続切断)、1 回リトライすれば内部で自動再接続されます。連続 2 回失敗した場合は
tzzb_loginを呼び出して再認証してください。
技術アーキテクチャ
AI 助手(MCP Client)
│ stdio
▼
tzzb-mcp(MCP Server, Python)
│ Chrome DevTools Protocol :9222
▼
Chrome 浏览器(独立 Profile)
│ 浏览器原生 fetch(携带 Cookie)
▼
同花顺投资账本 API(tzzb.10jqka.com.cn)CDP デバッグポート:
9222独立した Chrome Profile:
~/.tzzb_chrome_profileCookie 永続化:
~/.tzzb_cookies.json(有効期限約 7 日)グローバルロックによる直列呼び出し、CDP 切断時は自動再接続
ディレクトリ構造
tzzb-mcp/
├── pyproject.toml # 项目配置与依赖
├── src/
│ ├── server.py # MCP 服务入口(工具注册)
│ ├── auth.py # 登录、Cookie 提取与持久化
│ ├── client.py # Chrome CDP 连接与请求代理
│ ├── models.py # 数据模型
│ └── api/ # 各业务接口封装
│ ├── account.py # 账户列表 / 总览
│ ├── position.py # 持仓明细
│ ├── market.py # 行情 / 汇率 / 交易日
│ ├── trade.py # 交易记录 / 分时收益 / 资产趋势
│ └── watchlist.py # 自选列表
└── SKILL.md # AI 助手使用技能文档(工具详细说明)トラブルシューティングガイド
現象 | 原因 | 解決 |
「未登录」エラーが発生 | Cookie が存在しない、または期限切れ |
|
CDP リクエスト失敗 | Chrome が起動していない、または接続が切断 | 内部で自動再接続されるため 1 回リトライ。それでも失敗する場合は |
ファンド保有が空 / エラー |
| 保護が組み込まれているため、 |
|
|
|
Chrome が自動起動しない | — | 手動起動: |
License
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 Connectors
Access real-time and historical market data for China A-shares and Hong Kong stocks, along with ne…
Read-only China A-share data for AI agents: market, limit-up, capital flow and disclosures.
Provide access to Chinese stock market data including historical prices, real-time data, news, and…
Ask your AI about bank accounts, spending, debts, holdings, and investment activity.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceEnables querying financial data including stocks, indices, funds, and futures from Chinese, Hong Kong, and US markets. Provides real-time market information, financial indicators, news, and trading suggestions through Eastmoney and Sina data sources.133ISC
- AlicenseBqualityDmaintenanceProvides real-time market data for A-shares, Hong Kong, and US stocks using the Tencent Finance API. It enables users to manage stock positions and watchlists through an AI assistant.1220ISC
- FlicenseNot gradedqualityDmaintenanceProvides real-time quotes, fund flows, and corporate announcements for Chinese A-share stocks. It enables users to search for stocks, analyze financial indicators, and summarize quarterly reports through natural language.
- AlicenseAqualityCmaintenanceEnables AI assistants to query real-time A-share stock data, including quotes, fund flows, sector flows, and K-line history, without needing an API key.57MIT
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/Mrkelo/tzzb-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server