Skip to content

"Vibe-Trading: Your Personal Trading Agent"

feat(tools): three Gildata research tools over the srv-tool NL endpoint

sambazhufd6f07b1e862
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 96abe046b..df2732937 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -7,6 +7,26 @@ This project adheres to [Semantic Versioning](https://semver.org/).
### Added
+- **Three Gildata research tools over the vendor's 标准版 (srv-tool) NL
+ endpoint** — natural-language tools the agent itself queries, wrapping the
+ three vendor capabilities the project did not already cover (news,
+ screening and generic FinQuery are deliberately left to the existing
+ tools):
+ - `get_cn_macro_series` (`MacroIndustryData`): China macro / regional /
+ industry EDB time series — GDP, CPI, PMI, rates, 31 industry series —
+ complementing `get_macro_series` (FRED, US/global only until now).
+ - `get_cn_announcements` (`AnnouncementData`): A-share / HK / fund
+ announcement retrieval with highlighted excerpts (`get_sec_filings`
+ covers SEC filings only).
+ - `search_broker_reports` (`FinancialResearchReport`): broker-research
+ search over the Juyuan library — title, broker, industry, rating,
+ excerpt — coexisting with the eastmoney-backed `get_research_reports`.
+ All three share one thin client (`src/tools/gildata_srv.py`: JSON-RPC POST
+ + `format=json`, own throttle bucket), echo the routed `api_names` so a
+ mis-routed question is visible to the agent, cap rows via `limit`, and are
+ key-gated on `GILDATA_TOKEN` (optional `GILDATA_SRV_TOOL_URL` override).
+ MCP tool surface grows 75 → 78.
+
- **`get_fund_nav`: NAV history for Chinese off-exchange funds (场外基金).**
Off-exchange funds publish no OHLCV bars — their series is the daily NAV —
so this lands as an agent tool (`NetFundUnitValueReport` behind the same
diff --git a/README.md b/README.md
index ade15c7f6..ea655af65 100644
--- a/README.md
+++ b/README.md
@@ -1401,7 +1401,7 @@ Posting `{}` schedules a template on its own suggested cadence with its declared
## 🔌 MCP Plugin
-Vibe-Trading exposes 74 MCP tools for any MCP-compatible client. Runs as a stdio subprocess — no server setup needed. Core research tools work with zero API keys for HK/US/crypto; trading connector tools use the selected connector profile, and `run_swarm` needs an LLM key.
+Vibe-Trading exposes 78 MCP tools for any MCP-compatible client. Runs as a stdio subprocess — no server setup needed. Core research tools work with zero API keys for HK/US/crypto; trading connector tools use the selected connector profile, and `run_swarm` needs an LLM key.
**Environment variables:** the client spawns the server itself, so a shell `export` never reaches it — set them in the client's `env` block. Generated backtest code is sandboxed to the allowed run roots, so writing results into a workspace of your own needs `VIBE_TRADING_ALLOWED_RUN_ROOTS`:
@@ -1470,7 +1470,7 @@ with `--host` / `--port`.
</details>
-**MCP tools exposed (74):** `list_skills`, `load_skill`, `start_research_goal`, `get_research_goal`, `add_goal_evidence`, `update_research_goal_status`, `backtest`, `factor_analysis`, `alpha_zoo`, `alpha_bench`, `analyze_options`, `analyze_options_payoff`, `pattern_recognition`, `read_url`, `read_document`, `web_search`, `write_file`, `read_file`, `list_strategies`, `query_strategies`, `get_strategy_evidence`, `refresh_strategy_evidence`, `trading_connections`, `trading_select_connection`, `trading_check`, `trading_account`, `trading_positions`, `trading_orders`, `trading_quote`, `trading_history`, `list_swarm_presets`, `run_swarm`, `get_market_data`, `get_fund_flow`, `get_dragon_tiger`, `get_northbound_flow`, `get_margin_trading`, `get_block_trades`, `get_shareholder_count`, `get_lockup_expiry`, `get_sector_info`, `get_research_reports`, `get_stock_news`, `get_sec_filings`, `get_financial_statements`, `get_options_chain`, `get_stock_profile`, `screen_market`, `search_symbol`, `get_macro_series`, `get_fund_nav`, `iwencai_search`, `qveris_search`, `qveris_inspect`, `qveris_execute`, `get_institutional_holdings`, `etf_holdings`, `prediction_market`, `research_papers`, `get_swarm_status`, `get_run_result`, `list_runs`, `reap_stale_runs`, `retry_run`, `analyze_trade_journal`, `extract_shadow_strategy`, `run_shadow_backtest`, `render_shadow_report`, `scan_shadow_signals`, `quantlib_call`, `cashflow_performance`, `orderbook_depth`, `sentiment`, `technical_indicators`, `get_fundamentals`.
+**MCP tools exposed (78):** `list_skills`, `load_skill`, `start_research_goal`, `get_research_goal`, `add_goal_evidence`, `update_research_goal_status`, `backtest`, `factor_analysis`, `alpha_zoo`, `alpha_bench`, `analyze_options`, `analyze_options_payoff`, `pattern_recognition`, `read_url`, `read_document`, `web_search`, `write_file`, `read_file`, `list_strategies`, `query_strategies`, `get_strategy_evidence`, `refresh_strategy_evidence`, `trading_connections`, `trading_select_connection`, `trading_check`, `trading_account`, `trading_positions`, `trading_orders`, `trading_quote`, `trading_history`, `list_swarm_presets`, `run_swarm`, `get_market_data`, `get_fund_flow`, `get_dragon_tiger`, `get_northbound_flow`, `get_margin_trading`, `get_block_trades`, `get_shareholder_count`, `get_lockup_expiry`, `get_sector_info`, `get_research_reports`, `get_stock_news`, `get_sec_filings`, `get_financial_statements`, `get_options_chain`, `get_stock_profile`, `screen_market`, `search_symbol`, `get_macro_series`, `get_fund_nav`, `get_cn_macro_series`, `get_cn_announcements`, `search_broker_reports`, `iwencai_search`, `qveris_search`, `qveris_inspect`, `qveris_execute`, `get_institutional_holdings`, `etf_holdings`, `prediction_market`, `research_papers`, `get_swarm_status`, `get_run_result`, `list_runs`, `reap_stale_runs`, `retry_run`, `analyze_trade_journal`, `extract_shadow_strategy`, `run_shadow_backtest`, `render_shadow_report`, `scan_shadow_signals`, `quantlib_call`, `cashflow_performance`, `orderbook_depth`, `sentiment`, `technical_indicators`, `get_fundamentals`.
### SWARM external MCP tools
diff --git a/README_ar.md b/README_ar.md
index a1213aff7..f7ca32d46 100644
--- a/README_ar.md
+++ b/README_ar.md
@@ -1282,7 +1282,7 @@ vibe-trading-mcp --transport sse # legacy SSE (deprecated)
</details>
-**أدوات MCP المعروضة (75):** `list_skills`, `load_skill`, `start_research_goal`, `get_research_goal`, `add_goal_evidence`, `update_research_goal_status`, `backtest`, `factor_analysis`, `alpha_zoo`, `alpha_bench`, `analyze_options`, `analyze_options_payoff`, `pattern_recognition`, `read_url`, `read_document`, `web_search`, `write_file`, `read_file`, `list_strategies`, `query_strategies`, `get_strategy_evidence`, `refresh_strategy_evidence`, `trading_connections`, `trading_select_connection`, `trading_check`, `trading_account`, `trading_positions`, `trading_orders`, `trading_quote`, `trading_history`, `list_swarm_presets`, `run_swarm`, `get_market_data`, `get_fund_flow`, `get_dragon_tiger`, `get_northbound_flow`, `get_margin_trading`, `get_block_trades`, `get_shareholder_count`, `get_lockup_expiry`, `get_sector_info`, `get_research_reports`, `get_stock_news`, `get_sec_filings`, `get_financial_statements`, `get_options_chain`, `get_stock_profile`, `screen_market`, `search_symbol`, `get_macro_series`, `get_fund_nav`, `iwencai_search`, `qveris_search`, `qveris_inspect`, `qveris_execute`, `get_institutional_holdings`, `etf_holdings`, `prediction_market`, `research_papers`, `get_swarm_status`, `get_run_result`, `list_runs`, `reap_stale_runs`, `retry_run`, `analyze_trade_journal`, `extract_shadow_strategy`, `run_shadow_backtest`, `render_shadow_report`, `scan_shadow_signals`, `quantlib_call`, `cashflow_performance`, `orderbook_depth`, `sentiment`, `technical_indicators`, `get_fundamentals`.
+**أدوات MCP المعروضة (78):** `list_skills`, `load_skill`, `start_research_goal`, `get_research_goal`, `add_goal_evidence`, `update_research_goal_status`, `backtest`, `factor_analysis`, `alpha_zoo`, `alpha_bench`, `analyze_options`, `analyze_options_payoff`, `pattern_recognition`, `read_url`, `read_document`, `web_search`, `write_file`, `read_file`, `list_strategies`, `query_strategies`, `get_strategy_evidence`, `refresh_strategy_evidence`, `trading_connections`, `trading_select_connection`, `trading_check`, `trading_account`, `trading_positions`, `trading_orders`, `trading_quote`, `trading_history`, `list_swarm_presets`, `run_swarm`, `get_market_data`, `get_fund_flow`, `get_dragon_tiger`, `get_northbound_flow`, `get_margin_trading`, `get_block_trades`, `get_shareholder_count`, `get_lockup_expiry`, `get_sector_info`, `get_research_reports`, `get_stock_news`, `get_sec_filings`, `get_financial_statements`, `get_options_chain`, `get_stock_profile`, `screen_market`, `search_symbol`, `get_macro_series`, `get_fund_nav`, `get_cn_macro_series`, `get_cn_announcements`, `search_broker_reports`, `iwencai_search`, `qveris_search`, `qveris_inspect`, `qveris_execute`, `get_institutional_holdings`, `etf_holdings`, `prediction_market`, `research_papers`, `get_swarm_status`, `get_run_result`, `list_runs`, `reap_stale_runs`, `retry_run`, `analyze_trade_journal`, `extract_shadow_strategy`, `run_shadow_backtest`, `render_shadow_report`, `scan_shadow_signals`, `quantlib_call`, `cashflow_performance`, `orderbook_depth`, `sentiment`, `technical_indicators`, `get_fundamentals`.
### أدوات MCP الخارجية في SWARM
diff --git a/README_es.md b/README_es.md
index 3695aa52d..d3674f2a0 100644
--- a/README_es.md
+++ b/README_es.md
@@ -1286,7 +1286,7 @@ Enviar `{}` programa una plantilla con su propia cadencia sugerida y sus valores
## 🔌 MCP Plugin
-Vibe-Trading expone 74 MCP tools para cualquier cliente compatible con MCP. Se ejecuta como un subproceso stdio — no requiere configuración de servidor. Las herramientas de investigación principales funcionan sin ninguna API key para HK/US/crypto; las herramientas del conector de trading usan el perfil de conector seleccionado, y `run_swarm` necesita una LLM key.
+Vibe-Trading expone 78 MCP tools para cualquier cliente compatible con MCP. Se ejecuta como un subproceso stdio — no requiere configuración de servidor. Las herramientas de investigación principales funcionan sin ninguna API key para HK/US/crypto; las herramientas del conector de trading usan el perfil de conector seleccionado, y `run_swarm` necesita una LLM key.
**Variables de entorno:** el cliente lanza el servidor él mismo, así que un `export` de shell nunca le llega — configúralas en el bloque `env` del cliente. El código de backtest generado está confinado a los run roots permitidos, así que para escribir resultados en un workspace propio necesitas `VIBE_TRADING_ALLOWED_RUN_ROOTS`:
@@ -1357,7 +1357,7 @@ dirección de bind con `--host` / `--port`.
</details>
-**MCP tools expuestas (75):** `list_skills`, `load_skill`, `start_research_goal`, `get_research_goal`, `add_goal_evidence`, `update_research_goal_status`, `backtest`, `factor_analysis`, `alpha_zoo`, `alpha_bench`, `analyze_options`, `analyze_options_payoff`, `pattern_recognition`, `read_url`, `read_document`, `web_search`, `write_file`, `read_file`, `list_strategies`, `query_strategies`, `get_strategy_evidence`, `refresh_strategy_evidence`, `trading_connections`, `trading_select_connection`, `trading_check`, `trading_account`, `trading_positions`, `trading_orders`, `trading_quote`, `trading_history`, `list_swarm_presets`, `run_swarm`, `get_market_data`, `get_fund_flow`, `get_dragon_tiger`, `get_northbound_flow`, `get_margin_trading`, `get_block_trades`, `get_shareholder_count`, `get_lockup_expiry`, `get_sector_info`, `get_research_reports`, `get_stock_news`, `get_sec_filings`, `get_financial_statements`, `get_options_chain`, `get_stock_profile`, `screen_market`, `search_symbol`, `get_macro_series`, `get_fund_nav`, `iwencai_search`, `qveris_search`, `qveris_inspect`, `qveris_execute`, `get_institutional_holdings`, `etf_holdings`, `prediction_market`, `research_papers`, `get_swarm_status`, `get_run_result`, `list_runs`, `reap_stale_runs`, `retry_run`, `analyze_trade_journal`, `extract_shadow_strategy`, `run_shadow_backtest`, `render_shadow_report`, `scan_shadow_signals`, `quantlib_call`, `cashflow_performance`, `orderbook_depth`, `sentiment`, `technical_indicators`, `get_fundamentals`.
+**MCP tools expuestas (78):** `list_skills`, `load_skill`, `start_research_goal`, `get_research_goal`, `add_goal_evidence`, `update_research_goal_status`, `backtest`, `factor_analysis`, `alpha_zoo`, `alpha_bench`, `analyze_options`, `analyze_options_payoff`, `pattern_recognition`, `read_url`, `read_document`, `web_search`, `write_file`, `read_file`, `list_strategies`, `query_strategies`, `get_strategy_evidence`, `refresh_strategy_evidence`, `trading_connections`, `trading_select_connection`, `trading_check`, `trading_account`, `trading_positions`, `trading_orders`, `trading_quote`, `trading_history`, `list_swarm_presets`, `run_swarm`, `get_market_data`, `get_fund_flow`, `get_dragon_tiger`, `get_northbound_flow`, `get_margin_trading`, `get_block_trades`, `get_shareholder_count`, `get_lockup_expiry`, `get_sector_info`, `get_research_reports`, `get_stock_news`, `get_sec_filings`, `get_financial_statements`, `get_options_chain`, `get_stock_profile`, `screen_market`, `search_symbol`, `get_macro_series`, `get_fund_nav`, `get_cn_macro_series`, `get_cn_announcements`, `search_broker_reports`, `iwencai_search`, `qveris_search`, `qveris_inspect`, `qveris_execute`, `get_institutional_holdings`, `etf_holdings`, `prediction_market`, `research_papers`, `get_swarm_status`, `get_run_result`, `list_runs`, `reap_stale_runs`, `retry_run`, `analyze_trade_journal`, `extract_shadow_strategy`, `run_shadow_backtest`, `render_shadow_report`, `scan_shadow_signals`, `quantlib_call`, `cashflow_performance`, `orderbook_depth`, `sentiment`, `technical_indicators`, `get_fundamentals`.
### SWARM external MCP tools
diff --git a/README_ja.md b/README_ja.md
index 178a3f826..e65174f92 100644
--- a/README_ja.md
+++ b/README_ja.md
@@ -1228,7 +1228,7 @@ curl -X POST http://localhost:8899/scheduled-runs/playbooks/premarket-brief \
## 🔌 MCP Plugin
-Vibe-Trading は MCP-compatible client 向けに 74 MCP tools を公開します。stdio subprocess として動作し、server setup は不要です。Core research tools は HK/US/crypto で API key なしに動作し、trading connector tools は選択中の connector profile を使います。LLM key が必要なのは `run_swarm` のみです。
+Vibe-Trading は MCP-compatible client 向けに 78 MCP tools を公開します。stdio subprocess として動作し、server setup は不要です。Core research tools は HK/US/crypto で API key なしに動作し、trading connector tools は選択中の connector profile を使います。LLM key が必要なのは `run_swarm` のみです。
**環境変数:** server は client 自身が spawn するため、shell の `export` は届きません —— client の `env` block に設定してください。生成された backtest code は allowed run roots 内に制限されるので、結果を自分の作業 directory に書き出すには `VIBE_TRADING_ALLOWED_RUN_ROOTS` が必要です:
@@ -1284,7 +1284,7 @@ vibe-trading-mcp --transport sse # legacy SSE (deprecated)
</details>
-**公開される MCP tools(75):** `list_skills`, `load_skill`, `start_research_goal`, `get_research_goal`, `add_goal_evidence`, `update_research_goal_status`, `backtest`, `factor_analysis`, `alpha_zoo`, `alpha_bench`, `analyze_options`, `analyze_options_payoff`, `pattern_recognition`, `read_url`, `read_document`, `web_search`, `write_file`, `read_file`, `list_strategies`, `query_strategies`, `get_strategy_evidence`, `refresh_strategy_evidence`, `list_swarm_presets`, `run_swarm`, `get_market_data`, `get_fund_flow`, `get_dragon_tiger`, `get_northbound_flow`, `get_margin_trading`, `get_block_trades`, `get_shareholder_count`, `get_lockup_expiry`, `get_sector_info`, `get_research_reports`, `get_stock_news`, `get_sec_filings`, `get_financial_statements`, `get_options_chain`, `get_stock_profile`, `screen_market`, `search_symbol`, `get_macro_series`, `get_fund_nav`, `iwencai_search`, `qveris_search`, `qveris_inspect`, `qveris_execute`, `get_institutional_holdings`, `etf_holdings`, `prediction_market`, `research_papers`, `get_swarm_status`, `get_run_result`, `list_runs`, `reap_stale_runs`, `retry_run`, `analyze_trade_journal`, `extract_shadow_strategy`, `run_shadow_backtest`, `render_shadow_report`, `scan_shadow_signals`, `trading_connections`, `trading_select_connection`, `trading_check`, `trading_account`, `trading_positions`, `trading_orders`, `trading_quote`, `trading_history`, `quantlib_call`, `cashflow_performance`, `orderbook_depth`, `sentiment`, `technical_indicators`, `get_fundamentals`.
+**公開される MCP tools(78):** `list_skills`, `load_skill`, `start_research_goal`, `get_research_goal`, `add_goal_evidence`, `update_research_goal_status`, `backtest`, `factor_analysis`, `alpha_zoo`, `alpha_bench`, `analyze_options`, `analyze_options_payoff`, `pattern_recognition`, `read_url`, `read_document`, `web_search`, `write_file`, `read_file`, `list_strategies`, `query_strategies`, `get_strategy_evidence`, `refresh_strategy_evidence`, `list_swarm_presets`, `run_swarm`, `get_market_data`, `get_fund_flow`, `get_dragon_tiger`, `get_northbound_flow`, `get_margin_trading`, `get_block_trades`, `get_shareholder_count`, `get_lockup_expiry`, `get_sector_info`, `get_research_reports`, `get_stock_news`, `get_sec_filings`, `get_financial_statements`, `get_options_chain`, `get_stock_profile`, `screen_market`, `search_symbol`, `get_macro_series`, `get_fund_nav`, `get_cn_macro_series`, `get_cn_announcements`, `search_broker_reports`, `iwencai_search`, `qveris_search`, `qveris_inspect`, `qveris_execute`, `get_institutional_holdings`, `etf_holdings`, `prediction_market`, `research_papers`, `get_swarm_status`, `get_run_result`, `list_runs`, `reap_stale_runs`, `retry_run`, `analyze_trade_journal`, `extract_shadow_strategy`, `run_shadow_backtest`, `render_shadow_report`, `scan_shadow_signals`, `trading_connections`, `trading_select_connection`, `trading_check`, `trading_account`, `trading_positions`, `trading_orders`, `trading_quote`, `trading_history`, `quantlib_call`, `cashflow_performance`, `orderbook_depth`, `sentiment`, `technical_indicators`, `get_fundamentals`.
### SWARM の外部 MCP tools
diff --git a/README_ko.md b/README_ko.md
index 0106fd4b3..da48e9805 100644
--- a/README_ko.md
+++ b/README_ko.md
@@ -1285,7 +1285,7 @@ vibe-trading-mcp --transport sse # legacy SSE (deprecated)
</details>
-**노출되는 MCP tools(75):** `list_skills`, `load_skill`, `start_research_goal`, `get_research_goal`, `add_goal_evidence`, `update_research_goal_status`, `backtest`, `factor_analysis`, `alpha_zoo`, `alpha_bench`, `analyze_options`, `analyze_options_payoff`, `pattern_recognition`, `read_url`, `read_document`, `web_search`, `write_file`, `read_file`, `list_strategies`, `query_strategies`, `get_strategy_evidence`, `refresh_strategy_evidence`, `trading_connections`, `trading_select_connection`, `trading_check`, `trading_account`, `trading_positions`, `trading_orders`, `trading_quote`, `trading_history`, `list_swarm_presets`, `run_swarm`, `get_market_data`, `get_fund_flow`, `get_dragon_tiger`, `get_northbound_flow`, `get_margin_trading`, `get_block_trades`, `get_shareholder_count`, `get_lockup_expiry`, `get_sector_info`, `get_research_reports`, `get_stock_news`, `get_sec_filings`, `get_financial_statements`, `get_options_chain`, `get_stock_profile`, `screen_market`, `search_symbol`, `get_macro_series`, `get_fund_nav`, `iwencai_search`, `qveris_search`, `qveris_inspect`, `qveris_execute`, `get_institutional_holdings`, `etf_holdings`, `prediction_market`, `research_papers`, `get_swarm_status`, `get_run_result`, `list_runs`, `reap_stale_runs`, `retry_run`, `analyze_trade_journal`, `extract_shadow_strategy`, `run_shadow_backtest`, `render_shadow_report`, `scan_shadow_signals`, `quantlib_call`, `cashflow_performance`, `orderbook_depth`, `sentiment`, `technical_indicators`, `get_fundamentals`.
+**노출되는 MCP tools(78):** `list_skills`, `load_skill`, `start_research_goal`, `get_research_goal`, `add_goal_evidence`, `update_research_goal_status`, `backtest`, `factor_analysis`, `alpha_zoo`, `alpha_bench`, `analyze_options`, `analyze_options_payoff`, `pattern_recognition`, `read_url`, `read_document`, `web_search`, `write_file`, `read_file`, `list_strategies`, `query_strategies`, `get_strategy_evidence`, `refresh_strategy_evidence`, `trading_connections`, `trading_select_connection`, `trading_check`, `trading_account`, `trading_positions`, `trading_orders`, `trading_quote`, `trading_history`, `list_swarm_presets`, `run_swarm`, `get_market_data`, `get_fund_flow`, `get_dragon_tiger`, `get_northbound_flow`, `get_margin_trading`, `get_block_trades`, `get_shareholder_count`, `get_lockup_expiry`, `get_sector_info`, `get_research_reports`, `get_stock_news`, `get_sec_filings`, `get_financial_statements`, `get_options_chain`, `get_stock_profile`, `screen_market`, `search_symbol`, `get_macro_series`, `get_fund_nav`, `get_cn_macro_series`, `get_cn_announcements`, `search_broker_reports`, `iwencai_search`, `qveris_search`, `qveris_inspect`, `qveris_execute`, `get_institutional_holdings`, `etf_holdings`, `prediction_market`, `research_papers`, `get_swarm_status`, `get_run_result`, `list_runs`, `reap_stale_runs`, `retry_run`, `analyze_trade_journal`, `extract_shadow_strategy`, `run_shadow_backtest`, `render_shadow_report`, `scan_shadow_signals`, `quantlib_call`, `cashflow_performance`, `orderbook_depth`, `sentiment`, `technical_indicators`, `get_fundamentals`.
### SWARM 외부 MCP tools
diff --git a/README_zh.md b/README_zh.md
index 1d2bbadcc..eeedb84d1 100644
--- a/README_zh.md
+++ b/README_zh.md
@@ -1233,7 +1233,7 @@ POST `{}` 即按模板自身的建议节奏和默认变量排程。渲染后的
## 🔌 MCP Plugin
-Vibe-Trading 为任何 MCP-compatible client 暴露 74 个 MCP tools。它作为 stdio subprocess 运行,无需 server setup。核心 research tools 对港股/美股/加密零 API key 可用;trading connector tools 使用当前选择的 connector profile;只有 `run_swarm` 需要 LLM key。
+Vibe-Trading 为任何 MCP-compatible client 暴露 78 个 MCP tools。它作为 stdio subprocess 运行,无需 server setup。核心 research tools 对港股/美股/加密零 API key 可用;trading connector tools 使用当前选择的 connector profile;只有 `run_swarm` 需要 LLM key。
**环境变量:** server 由 client 自己 spawn,因此在 shell 里 `export` 永远传不进去 —— 请写在 client 的 `env` 块里。生成的回测代码被限制在 allowed run roots 内,所以要把结果写进你自己的工作目录,需要 `VIBE_TRADING_ALLOWED_RUN_ROOTS`:
@@ -1289,7 +1289,7 @@ vibe-trading-mcp --transport sse # legacy SSE (deprecated)
</details>
-**暴露的 MCP tools(75):** `list_skills`, `load_skill`, `start_research_goal`, `get_research_goal`, `add_goal_evidence`, `update_research_goal_status`, `backtest`, `factor_analysis`, `alpha_zoo`, `alpha_bench`, `analyze_options`, `analyze_options_payoff`, `pattern_recognition`, `read_url`, `read_document`, `web_search`, `write_file`, `read_file`, `list_strategies`, `query_strategies`, `get_strategy_evidence`, `refresh_strategy_evidence`, `list_swarm_presets`, `run_swarm`, `get_market_data`, `get_fund_flow`, `get_dragon_tiger`, `get_northbound_flow`, `get_margin_trading`, `get_block_trades`, `get_shareholder_count`, `get_lockup_expiry`, `get_sector_info`, `get_research_reports`, `get_stock_news`, `get_sec_filings`, `get_financial_statements`, `get_options_chain`, `get_stock_profile`, `screen_market`, `search_symbol`, `get_macro_series`, `get_fund_nav`, `iwencai_search`, `qveris_search`, `qveris_inspect`, `qveris_execute`, `get_institutional_holdings`, `etf_holdings`, `prediction_market`, `research_papers`, `get_swarm_status`, `get_run_result`, `list_runs`, `reap_stale_runs`, `retry_run`, `analyze_trade_journal`, `extract_shadow_strategy`, `run_shadow_backtest`, `render_shadow_report`, `scan_shadow_signals`, `trading_connections`, `trading_select_connection`, `trading_check`, `trading_account`, `trading_positions`, `trading_orders`, `trading_quote`, `trading_history`, `quantlib_call`, `cashflow_performance`, `orderbook_depth`, `sentiment`, `technical_indicators`, `get_fundamentals`.
+**暴露的 MCP tools(78):** `list_skills`, `load_skill`, `start_research_goal`, `get_research_goal`, `add_goal_evidence`, `update_research_goal_status`, `backtest`, `factor_analysis`, `alpha_zoo`, `alpha_bench`, `analyze_options`, `analyze_options_payoff`, `pattern_recognition`, `read_url`, `read_document`, `web_search`, `write_file`, `read_file`, `list_strategies`, `query_strategies`, `get_strategy_evidence`, `refresh_strategy_evidence`, `list_swarm_presets`, `run_swarm`, `get_market_data`, `get_fund_flow`, `get_dragon_tiger`, `get_northbound_flow`, `get_margin_trading`, `get_block_trades`, `get_shareholder_count`, `get_lockup_expiry`, `get_sector_info`, `get_research_reports`, `get_stock_news`, `get_sec_filings`, `get_financial_statements`, `get_options_chain`, `get_stock_profile`, `screen_market`, `search_symbol`, `get_macro_series`, `get_fund_nav`, `get_cn_macro_series`, `get_cn_announcements`, `search_broker_reports`, `iwencai_search`, `qveris_search`, `qveris_inspect`, `qveris_execute`, `get_institutional_holdings`, `etf_holdings`, `prediction_market`, `research_papers`, `get_swarm_status`, `get_run_result`, `list_runs`, `reap_stale_runs`, `retry_run`, `analyze_trade_journal`, `extract_shadow_strategy`, `run_shadow_backtest`, `render_shadow_report`, `scan_shadow_signals`, `trading_connections`, `trading_select_connection`, `trading_check`, `trading_account`, `trading_positions`, `trading_orders`, `trading_quote`, `trading_history`, `quantlib_call`, `cashflow_performance`, `orderbook_depth`, `sentiment`, `technical_indicators`, `get_fundamentals`.
### SWARM 的外部 MCP tools
diff --git a/agent/.env.example b/agent/.env.example
index 1a9c25be6..45fcf59a0 100644
--- a/agent/.env.example
+++ b/agent/.env.example
@@ -213,6 +213,7 @@ TUSHARE_TOKEN=your-tushare-token
# FMP_API_KEY=xxx # optional US-equity OHLCV fallback provider (selectable get_market_data source)
# GILDATA_TOKEN=xxx # optional Gildata (恒生聚源) provider — commercial token via [email protected]; joins the a_share/hk_equity chain tails for OHLCV (selectable get_market_data source) and powers the get_fund_nav OTC-fund NAV tool
# GILDATA_BASE_URL=xxx # optional endpoint override (defaults to the vendor's raw-api MCP endpoint)
+# GILDATA_SRV_TOOL_URL=xxx # optional override of the vendor's 标准版 NL research endpoint (powers get_cn_macro_series / get_cn_announcements / search_broker_reports)
# TICKERALL_API_KEY=xxx # optional hosted MetaTrader 5 forex/metals feed — EXPLICIT source="tickerall" only, never an automatic fallback (no local terminal; https://tickerall.com)
# TICKERALL_ACCOUNT_ID=xxx # required alongside the key: history is served per connected broker account (read-only)
# TICKERALL_BASE_URL=xxx # optional endpoint override (defaults to the public API)
diff --git a/agent/SKILL.md b/agent/SKILL.md
index 0c97e7ea1..8e95e4b6a 100644
--- a/agent/SKILL.md
+++ b/agent/SKILL.md
@@ -133,7 +133,7 @@ Comprehensive knowledge base covering:
Use `load_skill(name)` to access full methodology docs with code templates.
-## Available MCP Tools (75)
+## Available MCP Tools (78)
| Tool | Description | API Key |
|------|-------------|---------|
@@ -169,6 +169,9 @@ Use `load_skill(name)` to access full methodology docs with code templates.
| `search_symbol` | Symbol / ticker search across markets | None |
| `get_macro_series` | FRED macroeconomic series | FRED_API_KEY |
| `get_fund_nav` | Chinese off-exchange fund NAV history | GILDATA_TOKEN |
+| `get_cn_macro_series` | China macro/industry EDB series (NL query) | GILDATA_TOKEN |
+| `get_cn_announcements` | A-share/HK/fund announcement search (NL query) | GILDATA_TOKEN |
+| `search_broker_reports` | Broker research search over the Juyuan library (NL query) | GILDATA_TOKEN |
| `iwencai_search` | A-share natural-language research search | IWENCAI_KEY |
| `qveris_search` | Search QVeris premium data/tool marketplace (free discovery) | QVERIS_API_KEY + paid mode |
| `qveris_inspect` | Inspect QVeris tool schemas before executing (free) | QVERIS_API_KEY + paid mode |
diff --git a/agent/mcp_server.py b/agent/mcp_server.py
index ebffb9a61..44b8cebdd 100644
--- a/agent/mcp_server.py
+++ b/agent/mcp_server.py
@@ -1881,6 +1881,11 @@ def _key_gated_tool_classes() -> dict[str, Any]:
"""
from src.tools.fred_macro_tool import FredMacroTool
from src.tools.fund_nav_tool import GildataFundNavTool
+ from src.tools.gildata_research_tools import (
+ GetCnAnnouncementsTool,
+ GetCnMacroSeriesTool,
+ SearchBrokerReportsTool,
+ )
from src.tools.iwencai_tool import IWenCaiSearchTool
from src.tools.qveris_tool import (
QVerisExecuteTool,
@@ -1891,6 +1896,9 @@ def _key_gated_tool_classes() -> dict[str, Any]:
return {
"get_macro_series": FredMacroTool,
"get_fund_nav": GildataFundNavTool,
+ "get_cn_macro_series": GetCnMacroSeriesTool,
+ "get_cn_announcements": GetCnAnnouncementsTool,
+ "search_broker_reports": SearchBrokerReportsTool,
"iwencai_search": IWenCaiSearchTool,
"qveris_search": QVerisSearchTool,
"qveris_inspect": QVerisInspectTool,
@@ -2321,6 +2329,58 @@ def get_fund_nav(
return _execute_key_gated("get_fund_nav", params)
+def get_cn_macro_series(query: str, limit: int = 50) -> str:
+ """Fetch China macro / regional / industry economic indicator series (宏观 EDB).
+
+ GDP, CPI, PPI, PMI, money supply, rates, trade, 31 industry series and
+ regional data — dated observations with unit and frequency, asked for in
+ natural language. Complements get_macro_series (FRED, US/global).
+ Requires GILDATA_TOKEN; without it the tool returns a not-available error.
+
+ Args:
+ query: Natural-language indicator request, e.g. "2024年中国月度CPI同比".
+ limit: Maximum rows returned.
+ """
+ return _execute_key_gated(
+ "get_cn_macro_series", {"query": query, "limit": limit}
+ )
+
+
+def get_cn_announcements(query: str, limit: int = 50) -> str:
+ """Search Chinese-market announcements (公告): A-share, HK and fund filings.
+
+ Annual reports, earnings, dividends, buybacks, restructuring, inquiry
+ letters — with title, publish date and a highlighted excerpt. For US
+ filings use get_sec_filings. Requires GILDATA_TOKEN.
+
+ Args:
+ query: Natural-language announcement request, e.g. "贵州茅台2024年年度分红公告".
+ limit: Maximum rows returned.
+ """
+ return _execute_key_gated(
+ "get_cn_announcements", {"query": query, "limit": limit}
+ )
+
+
+def search_broker_reports(query: str, limit: int = 50) -> str:
+ """Search sell-side broker research (券商研报) over the Juyuan library.
+
+ Title, broker, industry, rating and a highlighted excerpt of the argument
+ — for company deep-dives, industry views and macro commentary. Coexists
+ with get_research_reports (eastmoney-backed). Requires GILDATA_TOKEN.
+
+ Args:
+ query: Natural-language research request, e.g. "最近三个月白酒行业的券商研报观点".
+ limit: Maximum rows returned.
+ """
+ return _execute_key_gated(
+ "search_broker_reports", {"query": query, "limit": limit}
+ )
+
+
@mcp.tool
def iwencai_search(query: str, limit: int = 20) -> str:
"""Run a natural-language A-share research query against iWenCai (问财).
diff --git a/agent/src/config/env_schema.py b/agent/src/config/env_schema.py
index 26b77d35f..a3f7d0b38 100644
--- a/agent/src/config/env_schema.py
+++ b/agent/src/config/env_schema.py
@@ -193,6 +193,8 @@ class DataConfig(_EnvBase):
alias="GILDATA_BASE_URL",
default="https://api.gildata.com/mcp-servers/aidata-assistant-srv-rawapi",
)
+ # Standard-version (srv-tool) NL research endpoint — see src/tools/gildata_srv.py.
+ gildata_srv_tool_url: str = Field(alias="GILDATA_SRV_TOOL_URL", default="")
fred_api_key: str = Field(alias="FRED_API_KEY", default="")
vibe_trading_iwencai_key: str = Field(alias="VIBE_TRADING_IWENCAI_KEY", default="")
vibe_trading_sec_ua: str = Field(alias="VIBE_TRADING_SEC_UA", default="")
diff --git a/agent/src/skills/data-routing/SKILL.md b/agent/src/skills/data-routing/SKILL.md
index 222dab159..da4c3ecbf 100644
--- a/agent/src/skills/data-routing/SKILL.md
+++ b/agent/src/skills/data-routing/SKILL.md
@@ -70,6 +70,9 @@ is required only where listed (no key listed = free / no auth).
| Symbol search | `search_symbol` | A-share, US, HK, Canada, crypto/index/FX | — |
| Macro / FRED series | `get_macro_series` | Macro (US/global) | `FRED_API_KEY` |
| OTC fund NAV (场外基金净值) | `get_fund_nav` | CN off-exchange funds | `GILDATA_TOKEN` |
+| China macro / industry EDB (宏观行业) | `get_cn_macro_series` | CN macro/regional/industry | `GILDATA_TOKEN` |
+| CN announcements (公告检索) | `get_cn_announcements` | A-share / HK / fund | `GILDATA_TOKEN` |
+| Broker research (券商研报) | `search_broker_reports` | A-share / HK | `GILDATA_TOKEN` |
| iWenCai NL search (问财) | `iwencai_search` | A-share | `VIBE_TRADING_IWENCAI_KEY` |
Notes:
diff --git a/agent/src/tools/gildata_research_tools.py b/agent/src/tools/gildata_research_tools.py
new file mode 100644
index 000000000..4180f5a0f
--- /dev/null
+++ b/agent/src/tools/gildata_research_tools.py
@@ -0,0 +1,207 @@
+"""Read-only tools: Gildata (恒生聚源) NL research over the srv-tool endpoint.
+
+Three agent-facing wrappers around the vendor's 标准版 natural-language tools,
+picked for value the project does not already cover:
+
+* ``get_cn_macro_series`` — ``MacroIndustryData``: China macro / regional /
+ industry EDB time series (the project's macro coverage is FRED, i.e.
+ US/global only).
+* ``get_cn_announcements`` — ``AnnouncementData``: A-share / HK / fund
+ announcement retrieval with highlighted excerpts (the existing
+ ``get_sec_filings`` covers SEC filings only).
+* ``search_broker_reports`` — ``FinancialResearchReport``: broker research
+ search over the Juyuan report library (deeper metadata than the existing
+ eastmoney-backed ``get_research_reports``; both coexist).
+
+Deliberately NOT wrapped (overlap with existing tools): news
+(``get_stock_news``/``web_search``), screening (``screen_market`` /
+``iwencai_search``), fund/manager selection, the generic ``FinQuery`` and the
+``FinDataFallbackQuery`` catch-all.
+
+The agent authors the natural-language ``query``; the server routes it. The
+routed ``api_names`` are echoed in every envelope so a mis-routed question is
+visible and the agent can re-ask. Rows are the vendor's structured dicts,
+capped to the most recent ``limit``.
+"""
+
+from __future__ import annotations
+
+import json
+import logging
+from typing import Any
+
+from src.agent.tools import BaseTool
+from src.config.accessor import get_env_config
+from src.tools.gildata_srv import call_srv_tool
+
+logger = logging.getLogger(__name__)
+
+_DEFAULT_LIMIT = 50
+_MAX_LIMIT = 200
+
+
+def _error(message: str) -> str:
+ return json.dumps({"ok": False, "error": message}, ensure_ascii=False)
+
+
+def _envelope(vendor_tool: str, query: str, payload: dict[str, Any], limit: int) -> str:
+ """Build the shared success envelope from a call_srv_tool payload."""
+ rows = payload.get("rows") or []
+ return json.dumps(
+ {
+ "ok": True,
+ "source": "gildata",
+ "vendor_tool": vendor_tool,
+ "query": query,
+ "api_names": payload.get("api_names") or [],
+ "rows": rows[:limit],
+ "count": min(len(rows), limit),
+ },
+ ensure_ascii=False,
+ )
+
+
+def _clean_query(kwargs: Any) -> str | None:
+ query = kwargs.get("query")
+ if not isinstance(query, str) or not query.strip():
+ return None
+ return query.strip()
+
+
+def _clean_limit(kwargs: Any) -> int:
+ try:
+ limit = int(kwargs.get("limit", _DEFAULT_LIMIT) or _DEFAULT_LIMIT)
+ except (TypeError, ValueError):
+ limit = _DEFAULT_LIMIT
+ return max(1, min(_MAX_LIMIT, limit))
+
+
+class _GildataSrvToolBase(BaseTool):
+ """Shared plumbing for the srv-tool wrappers."""
+
+ vendor_tool: str = ""
+
+ @classmethod
+ def check_available(cls) -> bool:
+ """Available only when ``GILDATA_TOKEN`` is configured."""
+ return bool(get_env_config().data.gildata_token)
+
+ def execute(self, **kwargs: Any) -> str:
+ if not get_env_config().data.gildata_token:
+ return _error("GILDATA_TOKEN is not configured")
+ query = _clean_query(kwargs)
+ if query is None:
+ return _error("'query' is required and must be a non-empty string")
+ limit = _clean_limit(kwargs)
+ try:
+ payload = call_srv_tool(self.vendor_tool, query)
+ except Exception as exc:
+ logger.warning("%s failed: %s", self.name, exc)
+ return _error(str(exc))
+ return _envelope(self.vendor_tool, query, payload, limit)
+
+
+class GetCnMacroSeriesTool(_GildataSrvToolBase):
+ """China macro / regional / industry economic time series (EDB)."""
+
+ name = "get_cn_macro_series"
+ vendor_tool = "MacroIndustryData"
+ description = (
+ "Fetch China macro / regional / industry economic indicator series "
+ "(宏观 EDB): GDP, CPI, PPI, PMI, money supply, interest rates, "
+ "imports/exports, plus 31 industry series (prices, output, inventory) "
+ "and regional data — as dated observations with unit and frequency. "
+ "Ask in natural language, e.g. {\"query\": \"2023年至2024年中国季度"
+ "GDP同比增速和CPI同比\"}. Complements get_macro_series (FRED, "
+ "US/global). Requires GILDATA_TOKEN."
+ )
+ parameters = {
+ "type": "object",
+ "properties": {
+ "query": {
+ "type": "string",
+ "description": (
+ "Natural-language indicator request naming the indicators, "
+ "geography and date range, e.g. '2024年中国月度CPI同比' or "
+ "'近三年半导体行业销售额'."
+ ),
+ },
+ "limit": {
+ "type": "integer",
+ "description": f"Maximum rows returned (1-{_MAX_LIMIT}). "
+ f"Defaults to {_DEFAULT_LIMIT}.",
+ "default": _DEFAULT_LIMIT,
+ },
+ },
+ "required": ["query"],
+ }
+
+
+class GetCnAnnouncementsTool(_GildataSrvToolBase):
+ """A-share / HK / fund announcement retrieval with highlighted excerpts."""
+
+ name = "get_cn_announcements"
+ vendor_tool = "AnnouncementData"
+ description = (
+ "Search Chinese-market company announcements (公告): A-share, HK and "
+ "fund filings — annual reports, earnings, dividends, buybacks, "
+ "restructuring, regulatory inquiry letters — with title, publish date "
+ "and a highlighted excerpt of the relevant passage. Ask in natural "
+ "language, e.g. {\"query\": \"贵州茅台2024年年度分红公告\"}. For US "
+ "filings use get_sec_filings. Requires GILDATA_TOKEN."
+ )
+ parameters = {
+ "type": "object",
+ "properties": {
+ "query": {
+ "type": "string",
+ "description": (
+ "Natural-language announcement request naming the company "
+ "/ fund, announcement type and time window, e.g. '宁德时代"
+ "最近三个月的回购公告'."
+ ),
+ },
+ "limit": {
+ "type": "integer",
+ "description": f"Maximum rows returned (1-{_MAX_LIMIT}). "
+ f"Defaults to {_DEFAULT_LIMIT}.",
+ "default": _DEFAULT_LIMIT,
+ },
+ },
+ "required": ["query"],
+ }
+
+
+class SearchBrokerReportsTool(_GildataSrvToolBase):
+ """Broker research search over the Juyuan report library."""
+
+ name = "search_broker_reports"
+ vendor_tool = "FinancialResearchReport"
+ description = (
+ "Search sell-side broker research (券商研报) over the Juyuan library: "
+ "report title, broker, analyst, industry, rating and a highlighted "
+ "excerpt of the argument — for company deep-dives, industry views and "
+ "macro commentary. Ask in natural language, e.g. {\"query\": \"最近三"
+ "个月白酒行业的券商研报观点\"}. Coexists with get_research_reports "
+ "(eastmoney-backed). Requires GILDATA_TOKEN."
+ )
+ parameters = {
+ "type": "object",
+ "properties": {
+ "query": {
+ "type": "string",
+ "description": (
+ "Natural-language research request naming the company / "
+ "industry / theme and time window, e.g. '比亚迪2024年报"
+ "点评'."
+ ),
+ },
+ "limit": {
+ "type": "integer",
+ "description": f"Maximum rows returned (1-{_MAX_LIMIT}). "
+ f"Defaults to {_DEFAULT_LIMIT}.",
+ "default": _DEFAULT_LIMIT,
+ },
+ },
+ "required": ["query"],
+ }
diff --git a/agent/src/tools/gildata_srv.py b/agent/src/tools/gildata_srv.py
new file mode 100644
index 000000000..f88169f2a
--- /dev/null
+++ b/agent/src/tools/gildata_srv.py
@@ -0,0 +1,112 @@
+"""Shared client for the Gildata (恒生聚源) srv-tool MCP endpoint.
+
+The vendor's 标准版 server (``aidata-assistant-srv-tool``) exposes ten
+natural-language research tools — macro/industry EDB series, announcement
+retrieval, broker-research search, screening and the like. Unlike the raw-api
+endpoint the loaders use, every tool takes a free-form ``query`` string the
+*agent* authors, which makes these a natural fit for the agent tool layer:
+the LLM writes the question, the server routes it, and this client returns
+the structured rows plus the ``api_name`` the server actually routed to —
+so a mis-routed question is visible to the agent and it can re-ask.
+
+Transport is identical to the loader's raw-api path (JSON-RPC POST, token on
+the URL query string, ``format=json`` for structured rows, the MCP dual
+Accept header) but goes through its own throttle bucket: these calls cost
+~5s each and belong to research flows, not price fetching.
+"""
+
+from __future__ import annotations
+
+import logging
+from typing import Any
+
+from backtest.loaders._http import resolve_min_interval, throttled_post_json
+from src.config.accessor import get_env_config
+
+logger = logging.getLogger(__name__)
+
+DEFAULT_SRV_TOOL_URL = "https://api.gildata.com/mcp-servers/aidata-assistant-srv-tool"
+
+_HOST_KEY = "gildata-srv"
+_MIN_INTERVAL_ENV = "VIBE_TRADING_GILDATA_SRV_MIN_INTERVAL"
+_DEFAULT_MIN_INTERVAL_S = 0.5
+_TIMEOUT_S = 60.0
+
+
+def _url() -> str:
+ base = (get_env_config().data.gildata_srv_tool_url or DEFAULT_SRV_TOOL_URL).strip()
+ return f"{base}{'&' if '?' in base else '?'}format=json"
+
+
+def call_srv_tool(
+ name: str, query: str, *, timeout: float = _TIMEOUT_S
+) -> dict[str, Any]:
+ """Invoke one srv-tool NL tool and return its merged structured payload.
+
+ Args:
+ name: Tool name, e.g. ``"MacroIndustryData"``.
+ query: Natural-language question (authored by the agent).
+ timeout: Per-request socket timeout; NL research calls are slow.
+
+ Returns:
+ ``{"api_names": [...], "rows": [...]}`` — rows of every result entry
+ concatenated, with the routed ``api_names`` surfaced for the agent.
+
+ Raises:
+ RuntimeError: Token missing, or the vendor answered a non-zero
+ business code.
+ requests.RequestException: Propagated from the HTTP layer.
+ ValueError: Unrecognizable response shape.
+ """
+ token = get_env_config().data.gildata_token
+ if not token:
+ raise RuntimeError("GILDATA_TOKEN is not configured")
+
+ url = f"{_url()}&token={token}"
+ payload = {
+ "jsonrpc": "2.0",
+ "id": 1,
+ "method": "tools/call",
+ "params": {"name": name, "arguments": {"query": query}},
+ }
+ outer = throttled_post_json(
+ url,
+ host_key=_HOST_KEY,
+ min_interval=resolve_min_interval(
+ _MIN_INTERVAL_ENV, _DEFAULT_MIN_INTERVAL_S
+ ),
+ json_body=payload,
+ headers={"Accept": "application/json, text/event-stream"},
+ timeout=timeout,
+ )
+
+ result = outer.get("result") if isinstance(outer, dict) else None
+ if result is None:
+ message = outer.get("message") if isinstance(outer, dict) else None
+ raise RuntimeError(f"gildata srv-tool call failed: {message or outer!r}")
+ content = result.get("content") or []
+ if not content or not isinstance(content[0], dict):
+ raise ValueError(f"gildata srv-tool response has no content: {outer!r}")
+ text = content[0].get("text")
+ if not isinstance(text, str):
+ raise ValueError(f"gildata srv-tool content is not text: {content[0]!r}")
+
+ import json
+
+ inner = json.loads(text)
+ if not isinstance(inner, dict) or inner.get("code") not in (0, "0"):
+ raise RuntimeError(
+ f"gildata srv-tool {name} returned error: {str(inner)[:200]}"
+ )
+
+ api_names: list[str] = []
+ rows: list[dict[str, Any]] = []
+ for entry in inner.get("results") or []:
+ if not isinstance(entry, dict):
+ continue
+ if entry.get("api_name"):
+ api_names.append(str(entry["api_name"]))
+ entry_rows = entry.get("rows")
+ if isinstance(entry_rows, list):
+ rows.extend(r for r in entry_rows if isinstance(r, dict))
+ return {"api_names": api_names, "rows": rows}
diff --git a/agent/tests/test_env_schema.py b/agent/tests/test_env_schema.py
index 2b594eac6..97f62de56 100644
--- a/agent/tests/test_env_schema.py
+++ b/agent/tests/test_env_schema.py
@@ -117,6 +117,7 @@ class TestEnvConfigDefaults:
assert c.data.fmp_api_key == ""
assert c.data.gildata_token == ""
assert c.data.gildata_base_url.endswith("aidata-assistant-srv-rawapi")
+ assert c.data.gildata_srv_tool_url == ""
assert c.data.fred_api_key == ""
assert c.data.vibe_trading_iwencai_key == ""
assert c.data.vibe_trading_sec_ua == ""
diff --git a/agent/tests/test_gildata_research_tools.py b/agent/tests/test_gildata_research_tools.py
new file mode 100644
index 000000000..dc6ad797b
--- /dev/null
+++ b/agent/tests/test_gildata_research_tools.py
@@ -0,0 +1,120 @@
+"""Tests for the gildata srv-tool research wrappers.
+
+All MCP transport is mocked at ``gildata_research_tools.call_srv_tool`` —
+no test reaches the live vendor.
+"""
+
+from __future__ import annotations
+
+import json
+
+
+
+from src.tools import gildata_research_tools as grt
+from src.tools.gildata_research_tools import (
+ GetCnAnnouncementsTool,
+ GetCnMacroSeriesTool,
+ SearchBrokerReportsTool,
+)
+
+TOOLS = [GetCnMacroSeriesTool, GetCnAnnouncementsTool, SearchBrokerReportsTool]
+
+
+class TestAvailabilityAndMetadata:
+ """All three wrappers gate on GILDATA_TOKEN and share plumbing."""
+
+ def test_unavailable_without_token(self, monkeypatch):
+ monkeypatch.delenv("GILDATA_TOKEN", raising=False)
+ for cls in TOOLS:
+ assert cls.check_available() is False
+
+ def test_available_with_token(self, monkeypatch):
+ monkeypatch.setenv("GILDATA_TOKEN", "secret")
+ for cls in TOOLS:
+ assert cls.check_available() is True
+
+ def test_metadata(self):
+ by_name = {cls.name: cls for cls in TOOLS}
+ assert by_name["get_cn_macro_series"].vendor_tool == "MacroIndustryData"
+ assert by_name["get_cn_announcements"].vendor_tool == "AnnouncementData"
+ assert by_name["search_broker_reports"].vendor_tool == "FinancialResearchReport"
+ for cls in TOOLS:
+ assert cls().is_readonly is True
+
+
+class TestExecute:
+ """Envelope shape, api_names echo, limit, and error paths."""
+
+ def _patch(self, monkeypatch, payload):
+ monkeypatch.setenv("GILDATA_TOKEN", "secret")
+ monkeypatch.setattr(grt, "call_srv_tool", lambda tool, query: payload)
+
+ def test_macro_happy_path(self, monkeypatch):
+ self._patch(monkeypatch, {
+ "api_names": ["EDB取数"],
+ "rows": [
+ {"indicatorname": "中国:GDP:当期同比", "date": "2024-12-31",
+ "value": "5.4", "unit": "%", "frequency": "季"},
+ ],
+ })
+ out = json.loads(GetCnMacroSeriesTool().execute(
+ query="2024年中国GDP同比"))
+ assert out["ok"] is True
+ assert out["source"] == "gildata"
+ assert out["vendor_tool"] == "MacroIndustryData"
+ assert out["api_names"] == ["EDB取数"]
+ assert out["rows"][0]["value"] == "5.4"
+ assert out["count"] == 1
+
+ def test_announcements_rows_and_multiple_api_names(self, monkeypatch):
+ self._patch(monkeypatch, {
+ "api_names": ["公告库", "公告库"],
+ "rows": [
+ {"title": "分红公告", "pubtime": "2025-04-03", "highlight": "每10股276.24元"},
+ {"title": "年报", "pubtime": "2025-04-02", "highlight": "..."},
+ ],
+ })
+ out = json.loads(GetCnAnnouncementsTool().execute(
+ query="贵州茅台2024年年度分红公告"))
+ assert out["api_names"] == ["公告库", "公告库"]
+ assert out["count"] == 2
+ assert out["rows"][0]["highlight"].startswith("每10股")
+
+ def test_limit_caps_rows(self, monkeypatch):
+ self._patch(monkeypatch, {
+ "api_names": ["研报库"],
+ "rows": [{"title": f"r{i}"} for i in range(80)],
+ })
+ out = json.loads(SearchBrokerReportsTool().execute(
+ query="白酒研报", limit=10))
+ assert out["count"] == 10 and len(out["rows"]) == 10
+
+ def test_limit_clamped_to_max(self, monkeypatch):
+ self._patch(monkeypatch, {"api_names": [], "rows": []})
+ out = json.loads(GetCnMacroSeriesTool().execute(
+ query="GDP", limit=99999))
+ assert out["ok"] is True # clamped, not rejected
+
+ def test_vendor_error_becomes_ok_false(self, monkeypatch):
+ def boom(tool, query):
+ raise RuntimeError("gildata srv-tool MacroIndustryData returned error: quota")
+ monkeypatch.setenv("GILDATA_TOKEN", "secret")
+ monkeypatch.setattr(grt, "call_srv_tool", boom)
+ out = json.loads(GetCnMacroSeriesTool().execute(query="GDP"))
+ assert out["ok"] is False
+ assert "quota" in out["error"]
+
+ def test_missing_query_rejected(self, monkeypatch):
+ monkeypatch.setenv("GILDATA_TOKEN", "secret")
+ out = json.loads(SearchBrokerReportsTool().execute(query=" "))
+ assert out["ok"] is False and "'query'" in out["error"]
+
+ def test_missing_token_rejected(self, monkeypatch):
+ monkeypatch.delenv("GILDATA_TOKEN", raising=False)
+ out = json.loads(GetCnAnnouncementsTool().execute(query="分红"))
+ assert out["ok"] is False and "GILDATA_TOKEN" in out["error"]
+
+ def test_empty_rows_still_ok(self, monkeypatch):
+ self._patch(monkeypatch, {"api_names": [], "rows": []})
+ out = json.loads(GetCnAnnouncementsTool().execute(query="不存在的东西"))
+ assert out["ok"] is True and out["rows"] == []