Skip to content

"Vibe-Trading: Your Personal Trading Agent"

fix(mcp): bound Alpha Bench requests

cgycorey17b9b8b7d970
diff --git a/README.md b/README.md
index aa23b5ac1..b0dd9011a 100644
--- a/README.md
+++ b/README.md
@@ -1091,7 +1091,7 @@ Posting `{}` schedules a template on its own suggested cadence with its declared
## 🔌 MCP Plugin
-Vibe-Trading exposes 62 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 64 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`:
diff --git a/README_ar.md b/README_ar.md
index e971f6a13..f81d43fe0 100644
--- a/README_ar.md
+++ b/README_ar.md
@@ -1058,7 +1058,7 @@ curl -X POST http://localhost:8899/scheduled-runs/playbooks/premarket-brief \
## 🔌 MCP Plugin
-يعرض Vibe-Trading 62 أداة MCP لأي عميل متوافق مع MCP. يعمل كعملية stdio فرعية، دون إعداد خادم. أدوات البحث الأساسية تعمل دون أي مفاتيح API لأسواق HK/US/crypto؛ وأدوات connector للتداول تستخدم profile الموصل المختار، ويحتاج `run_swarm` وحده إلى مفتاح LLM.
+يعرض Vibe-Trading 64 أداة MCP لأي عميل متوافق مع MCP. يعمل كعملية stdio فرعية، دون إعداد خادم. أدوات البحث الأساسية تعمل دون أي مفاتيح API لأسواق HK/US/crypto؛ وأدوات connector للتداول تستخدم profile الموصل المختار، ويحتاج `run_swarm` وحده إلى مفتاح LLM.
**متغيرات البيئة:** العميل هو من يشغّل الخادم بنفسه، لذا لا يصل إليه `export` من الـ shell أبداً —— اضبطها في كتلة `env` الخاصة بالعميل. كود الاختبار الخلفي المولَّد محصور ضمن جذور التشغيل المسموح بها، لذا تحتاج إلى `VIBE_TRADING_ALLOWED_RUN_ROOTS` لكتابة النتائج في دليل عمل خاص بك:
@@ -1114,7 +1114,7 @@ vibe-trading-mcp --transport sse # legacy SSE (deprecated)
</details>
-**أدوات MCP المعروضة (62):** `list_skills`, `load_skill`, `start_research_goal`, `get_research_goal`, `add_goal_evidence`, `update_research_goal_status`, `backtest`, `factor_analysis`, `analyze_options`, `analyze_options_payoff`, `pattern_recognition`, `read_url`, `read_document`, `web_search`, `write_file`, `read_file`, `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`, `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`.
+**أدوات MCP المعروضة (64):** `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`, `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`, `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`.
### أدوات MCP الخارجية في SWARM
@@ -1435,7 +1435,7 @@ Vibe-Trading/
├── agent/ # Backend (Python)
│ ├── cli/ # CLI package — interactive TUI + subcommands
│ ├── api_server.py # FastAPI server — runs, sessions, upload, swarm, SSE
-│ ├── mcp_server.py # MCP server — 62 tools for OpenClaw / Claude Desktop
+│ ├── mcp_server.py # MCP server — 64 tools for OpenClaw / Claude Desktop
│ │
│ ├── src/
│ │ ├── agent/ # ReAct agent core
diff --git a/README_ja.md b/README_ja.md
index 3bacf641d..a0c0a9fc8 100644
--- a/README_ja.md
+++ b/README_ja.md
@@ -1055,7 +1055,7 @@ curl -X POST http://localhost:8899/scheduled-runs/playbooks/premarket-brief \
## 🔌 MCP Plugin
-Vibe-Trading は MCP-compatible client 向けに 62 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 向けに 64 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` が必要です:
@@ -1111,7 +1111,7 @@ vibe-trading-mcp --transport sse # legacy SSE (deprecated)
</details>
-**公開される MCP tools(62):** `list_skills`, `load_skill`, `start_research_goal`, `get_research_goal`, `add_goal_evidence`, `update_research_goal_status`, `backtest`, `factor_analysis`, `analyze_options`, `analyze_options_payoff`, `pattern_recognition`, `read_url`, `read_document`, `web_search`, `write_file`, `read_file`, `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`, `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`.
+**公開される MCP tools(64):** `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_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`, `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`.
### SWARM の外部 MCP tools
@@ -1438,7 +1438,7 @@ Vibe-Trading/
├── agent/ # バックエンド (Python)
│ ├── cli/ # CLI パッケージ — インタラクティブ TUI + サブコマンド
│ ├── api_server.py # FastAPI サーバー — runs、sessions、upload、swarm、SSE
-│ ├── mcp_server.py # MCP サーバー — OpenClaw / Claude Desktop 向け 62 tools
+│ ├── mcp_server.py # MCP サーバー — OpenClaw / Claude Desktop 向け 64 tools
│ │
│ ├── src/
│ │ ├── agent/ # ReAct エージェントコア
diff --git a/README_ko.md b/README_ko.md
index 0908e3b19..6c8997be9 100644
--- a/README_ko.md
+++ b/README_ko.md
@@ -1058,7 +1058,7 @@ curl -X POST http://localhost:8899/scheduled-runs/playbooks/premarket-brief \
## 🔌 MCP Plugin
-Vibe-Trading은 모든 MCP-compatible client를 위해 62개 MCP tools를 제공합니다. stdio subprocess로 실행되므로 server setup이 필요 없습니다. 핵심 research tools는 HK/US/crypto에서 API key 없이 작동하고, trading connector tools는 선택된 connector profile을 사용하며, `run_swarm`만 LLM key가 필요합니다.
+Vibe-Trading은 모든 MCP-compatible client를 위해 64개 MCP tools를 제공합니다. stdio subprocess로 실행되므로 server setup이 필요 없습니다. 핵심 research tools는 HK/US/crypto에서 API key 없이 작동하고, trading connector tools는 선택된 connector profile을 사용하며, `run_swarm`만 LLM key가 필요합니다.
**환경 변수:** server는 client가 직접 spawn하므로 shell의 `export`는 전달되지 않습니다 —— client의 `env` block에 설정하세요. 생성된 backtest code는 allowed run roots 안으로 제한되므로, 결과를 자신의 작업 directory에 쓰려면 `VIBE_TRADING_ALLOWED_RUN_ROOTS`가 필요합니다:
@@ -1114,7 +1114,7 @@ vibe-trading-mcp --transport sse # legacy SSE (deprecated)
</details>
-**노출되는 MCP tools(62):** `list_skills`, `load_skill`, `start_research_goal`, `get_research_goal`, `add_goal_evidence`, `update_research_goal_status`, `backtest`, `factor_analysis`, `analyze_options`, `analyze_options_payoff`, `pattern_recognition`, `read_url`, `read_document`, `web_search`, `write_file`, `read_file`, `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`, `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`.
+**노출되는 MCP tools(64):** `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`, `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`, `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`.
### SWARM 외부 MCP tools
@@ -1437,7 +1437,7 @@ Vibe-Trading/
├── agent/ # Backend (Python)
│ ├── cli/ # CLI package — interactive TUI + subcommands
│ ├── api_server.py # FastAPI server — runs, sessions, upload, swarm, SSE
-│ ├── mcp_server.py # MCP server — 62 tools for OpenClaw / Claude Desktop
+│ ├── mcp_server.py # MCP server — 64 tools for OpenClaw / Claude Desktop
│ │
│ ├── src/
│ │ ├── agent/ # ReAct agent core
diff --git a/README_zh.md b/README_zh.md
index 1cd097761..5092cdd60 100644
--- a/README_zh.md
+++ b/README_zh.md
@@ -1052,7 +1052,7 @@ POST `{}` 即按模板自身的建议节奏和默认变量排程。渲染后的
## 🔌 MCP Plugin
-Vibe-Trading 为任何 MCP-compatible client 暴露 62 个 MCP tools。它作为 stdio subprocess 运行,无需 server setup。核心 research tools 对港股/美股/加密零 API key 可用;trading connector tools 使用当前选择的 connector profile;只有 `run_swarm` 需要 LLM key。
+Vibe-Trading 为任何 MCP-compatible client 暴露 64 个 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`:
@@ -1108,7 +1108,7 @@ vibe-trading-mcp --transport sse # legacy SSE (deprecated)
</details>
-**暴露的 MCP tools(62):** `list_skills`, `load_skill`, `start_research_goal`, `get_research_goal`, `add_goal_evidence`, `update_research_goal_status`, `backtest`, `factor_analysis`, `analyze_options`, `analyze_options_payoff`, `pattern_recognition`, `read_url`, `read_document`, `web_search`, `write_file`, `read_file`, `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`, `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`.
+**暴露的 MCP tools(64):** `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_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`, `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`.
### SWARM 的外部 MCP tools
@@ -1425,7 +1425,7 @@ Vibe-Trading/
├── agent/ # 后端(Python)
│ ├── cli/ # CLI 包 —— 交互式 TUI + 子命令
│ ├── api_server.py # FastAPI server —— runs、sessions、upload、swarm、SSE
-│ ├── mcp_server.py # MCP server —— 62 个工具,面向 OpenClaw / Claude Desktop
+│ ├── mcp_server.py # MCP server —— 64 个工具,面向 OpenClaw / Claude Desktop
│ │
│ ├── src/
│ │ ├── agent/ # ReAct agent 内核
diff --git a/agent/mcp_server.py b/agent/mcp_server.py
index 4d21c62bf..4324e831e 100644
--- a/agent/mcp_server.py
+++ b/agent/mcp_server.py
@@ -852,7 +852,55 @@ def alpha_bench(
top: Number of top-ranked alphas to include in the report.
output_dir: Optional directory for the generated HTML report.
"""
- registry = _get_registry()
+ if not alpha_id and not zoo:
+ return json.dumps(
+ {
+ "status": "error",
+ "error": "alpha_id or zoo is required for MCP alpha_bench",
+ },
+ ensure_ascii=False,
+ )
+ if alpha_id and zoo:
+ return json.dumps(
+ {
+ "status": "error",
+ "error": "alpha_id and zoo are mutually exclusive",
+ },
+ ensure_ascii=False,
+ )
+
+ try:
+ from datetime import date
+
+ from src.tools.alpha_bench_tool import _parse_period
+
+ start_raw, end_raw = _parse_period(period)
+ start_date = date.fromisoformat(start_raw)
+ end_date = date.fromisoformat(end_raw)
+ try:
+ max_end = start_date.replace(year=start_date.year + 10)
+ except ValueError:
+ max_end = start_date.replace(year=start_date.year + 10, day=28)
+ if end_date > max_end:
+ return json.dumps(
+ {
+ "status": "error",
+ "error": "MCP alpha_bench period must be no more than 10 years",
+ },
+ ensure_ascii=False,
+ )
+ except ValueError as exc:
+ return json.dumps({"status": "error", "error": str(exc)}, ensure_ascii=False)
+
+ if top <= 0 or top > 100:
+ return json.dumps(
+ {
+ "status": "error",
+ "error": "MCP alpha_bench top must be between 1 and 100",
+ },
+ ensure_ascii=False,
+ )
+
params: dict[str, Any] = {
"universe": universe,
"period": period,
@@ -862,8 +910,29 @@ def alpha_bench(
params["alpha_id"] = alpha_id
if zoo is not None:
params["zoo"] = zoo
- if output_dir is not None:
- params["output_dir"] = output_dir
+
+ if output_dir:
+ from src.config.paths import get_runtime_root
+ from src.tools.path_utils import allowed_write_roots, resolve_safe_path
+
+ try:
+ report_roots = [
+ Path.home() / ".vibe-trading" / "reports",
+ get_runtime_root() / "reports",
+ *allowed_write_roots(),
+ ]
+ params["output_dir"] = str(
+ resolve_safe_path(
+ output_dir,
+ None,
+ report_roots,
+ purpose="alpha bench report",
+ )
+ )
+ except ValueError as exc:
+ return json.dumps({"status": "error", "error": str(exc)}, ensure_ascii=False)
+
+ registry = _get_registry()
return registry.execute("alpha_bench", params)
diff --git a/agent/tests/test_mcp_alpha_zoo_contract.py b/agent/tests/test_mcp_alpha_zoo_contract.py
index 3a24575fa..b22bc47cf 100644
--- a/agent/tests/test_mcp_alpha_zoo_contract.py
+++ b/agent/tests/test_mcp_alpha_zoo_contract.py
@@ -2,6 +2,7 @@ from __future__ import annotations
import asyncio
import inspect
+import json
import re
from pathlib import Path
@@ -9,7 +10,6 @@ import mcp_server
from src.tools.alpha_bench_tool import AlphaBenchTool
from src.tools.alpha_zoo_tool import AlphaZooTool
-
_ALPHA_ZOO = getattr(mcp_server.alpha_zoo, "fn", None) or getattr(
mcp_server.alpha_zoo, "__wrapped__", mcp_server.alpha_zoo
)
@@ -35,9 +35,7 @@ def test_wrapper_signatures_match_registered_contracts() -> None:
signature = inspect.signature(wrapper)
assert set(signature.parameters) == set(tool.parameters["properties"])
required = {
- name
- for name, parameter in signature.parameters.items()
- if parameter.default is inspect.Parameter.empty
+ name for name, parameter in signature.parameters.items() if parameter.default is inspect.Parameter.empty
}
assert required == set(tool.parameters["required"])
@@ -71,13 +69,14 @@ def test_alpha_zoo_forwards_filters(monkeypatch) -> None:
def test_alpha_bench_forwards_selection(monkeypatch) -> None:
registry = _RecordingRegistry()
monkeypatch.setattr(mcp_server, "_get_registry", lambda: registry)
+ output_dir = Path.home() / ".vibe-trading" / "reports" / "alpha-zoo"
_ALPHA_BENCH(
universe="sp500",
period="2018-2025",
zoo="alpha101",
top=10,
- output_dir="/tmp/reports",
+ output_dir=str(output_dir),
)
assert registry.calls == [
@@ -88,7 +87,7 @@ def test_alpha_bench_forwards_selection(monkeypatch) -> None:
"period": "2018-2025",
"top": 10,
"zoo": "alpha101",
- "output_dir": "/tmp/reports",
+ "output_dir": str(output_dir.resolve()),
},
)
]
@@ -110,3 +109,79 @@ def test_skill_inventory_matches_static_mcp_registration() -> None:
listed = set(re.findall(r"^\| `([a-z_]+)` \|", tool_section, re.MULTILINE))
assert int(header.group(1)) == len(static)
assert listed == static
+
+
+def test_alpha_bench_requires_a_bounded_selection(monkeypatch) -> None:
+ registry = _RecordingRegistry()
+ monkeypatch.setattr(mcp_server, "_get_registry", lambda: registry)
+
+ result = json.loads(_ALPHA_BENCH(universe="sp500", period="2018-2025"))
+
+ assert result["status"] == "error"
+ assert "alpha_id or zoo" in result["error"]
+ assert registry.calls == []
+
+
+def test_alpha_bench_rejects_periods_over_ten_years(monkeypatch) -> None:
+ registry = _RecordingRegistry()
+ monkeypatch.setattr(mcp_server, "_get_registry", lambda: registry)
+
+ result = json.loads(_ALPHA_BENCH(universe="sp500", period="2010-2025", zoo="alpha101"))
+
+ assert result["status"] == "error"
+ assert "10 years" in result["error"]
+ assert registry.calls == []
+
+
+def test_alpha_bench_rejects_conflicting_selection(monkeypatch) -> None:
+ registry = _RecordingRegistry()
+ monkeypatch.setattr(mcp_server, "_get_registry", lambda: registry)
+
+ result = json.loads(
+ _ALPHA_BENCH(
+ universe="sp500",
+ period="2018-2025",
+ alpha_id="alpha101_001",
+ zoo="alpha101",
+ )
+ )
+
+ assert result["status"] == "error"
+ assert "mutually exclusive" in result["error"]
+ assert registry.calls == []
+
+
+def test_alpha_bench_rejects_unbounded_top(monkeypatch) -> None:
+ registry = _RecordingRegistry()
+ monkeypatch.setattr(mcp_server, "_get_registry", lambda: registry)
+
+ result = json.loads(
+ _ALPHA_BENCH(
+ universe="sp500",
+ period="2018-2025",
+ zoo="alpha101",
+ top=101,
+ )
+ )
+
+ assert result["status"] == "error"
+ assert "between 1 and 100" in result["error"]
+ assert registry.calls == []
+
+
+def test_alpha_bench_rejects_output_outside_allowed_roots(monkeypatch) -> None:
+ registry = _RecordingRegistry()
+ monkeypatch.setattr(mcp_server, "_get_registry", lambda: registry)
+
+ result = json.loads(
+ _ALPHA_BENCH(
+ universe="sp500",
+ period="2018-2025",
+ alpha_id="alpha101_001",
+ output_dir="/tmp/alpha-bench-reports",
+ )
+ )
+
+ assert result["status"] == "error"
+ assert "allowed" in result["error"]
+ assert registry.calls == []