Summary
The MCP server's factor_analysis tool cannot succeed for any input: the
@mcp.tool wrapper in agent/mcp_server.py forwards codes/factor_name
arguments, but the only registered implementation
(agent/src/tools/factor_analysis_tool.py) requires pre-built CSV artifact
paths (factor_csv, return_csv, output_dir). Every MCP call therefore
dies on KeyError: 'factor_csv' before any analysis runs.
Reproduction
Connect any MCP client to vibe-trading-mcp (tested over Streamable HTTP)
and call:
{
"tool": "factor_analysis",
"arguments": {
"codes": ["SBIN.NS", "HDFCBANK.NS", "ICICIBANK.NS"],
"factor_name": "pb",
"start_date": "2025-07-16",
"end_date": "2026-07-16",
"source": "yfinance"
}
}
Result (same for any market/symbols, e.g. US tickers, and for source: "auto" / "tushare"):
factor_analysis error: 'factor_csv'
Root cause
agent/mcp_server.py — the wrapper accepts a codes-based signature and
forwards exactly those keys:
@mcp.tool
def factor_analysis(
codes: list[str],
factor_name: str,
start_date: str,
end_date: str,
source: str = "auto",
top_n: int = 10,
bottom_n: int = 10,
) -> str:
...
return registry.execute(
"factor_analysis",
{
"codes": codes,
"factor_name": factor_name,
"start_date": start_date,
"end_date": end_date,
"source": source,
"top_n": top_n,
"bottom_n": bottom_n,
},
)
agent/src/tools/factor_analysis_tool.py — the registered tool is
artifact-based and reads different keys:
"required": ["factor_csv", "return_csv", "output_dir"],
...
factor_csv=kwargs["factor_csv"], # <- KeyError: 'factor_csv'
FactorAnalysisTool performs no data fetching (it only pd.read_csvs the
two matrices), and I could not find any other code path that builds a factor
matrix from codes + factor_name (the wrapper's docstring mentions
daily_basic fields like pe_ttm/pb, which suggests an intended
tushare-backed builder that isn't wired up).
Verified at commit 86f6012 and, by reading the current sources, still
present on main as of 2026-07-16.
Environment
- vibe-trading-ai installed from git @
86f6012 (pip, Python 3.12, macOS arm64)
vibe-trading-mcp --transport http (Streamable HTTP), stock configuration
- No broker connections, no mandate; pure research usage
Expected behavior (either would resolve it)
- The MCP wrapper matches the registered tool's contract — i.e. it accepts
factor_csv/return_csv/output_dir so agents can feed artifacts they
built with get_market_data + write_file (the flow the
factor-research skill documents); or
- A codes→factor-matrix builder is added behind the current wrapper
signature (e.g. tushare daily_basic for CN, with an honest error for
markets lacking a fundamentals history source).
Happy to provide more detail or test a fix. Thanks for the project — the
MCP server design (research-only surface, no order tools) is excellent.
Summary
The MCP server's
factor_analysistool cannot succeed for any input: the@mcp.toolwrapper inagent/mcp_server.pyforwardscodes/factor_namearguments, but the only registered implementation
(
agent/src/tools/factor_analysis_tool.py) requires pre-built CSV artifactpaths (
factor_csv,return_csv,output_dir). Every MCP call thereforedies on
KeyError: 'factor_csv'before any analysis runs.Reproduction
Connect any MCP client to
vibe-trading-mcp(tested over Streamable HTTP)and call:
{ "tool": "factor_analysis", "arguments": { "codes": ["SBIN.NS", "HDFCBANK.NS", "ICICIBANK.NS"], "factor_name": "pb", "start_date": "2025-07-16", "end_date": "2026-07-16", "source": "yfinance" } }Result (same for any market/symbols, e.g. US tickers, and for
source: "auto"/"tushare"):Root cause
agent/mcp_server.py— the wrapper accepts a codes-based signature andforwards exactly those keys:
agent/src/tools/factor_analysis_tool.py— the registered tool isartifact-based and reads different keys:
FactorAnalysisToolperforms no data fetching (it onlypd.read_csvs thetwo matrices), and I could not find any other code path that builds a factor
matrix from
codes+factor_name(the wrapper's docstring mentionsdaily_basicfields likepe_ttm/pb, which suggests an intendedtushare-backed builder that isn't wired up).
Verified at commit
86f6012and, by reading the current sources, stillpresent on
mainas of 2026-07-16.Environment
86f6012(pip, Python 3.12, macOS arm64)vibe-trading-mcp --transport http(Streamable HTTP), stock configurationExpected behavior (either would resolve it)
factor_csv/return_csv/output_dirso agents can feed artifacts theybuilt with
get_market_data+write_file(the flow thefactor-researchskill documents); orsignature (e.g. tushare
daily_basicfor CN, with an honest error formarkets lacking a fundamentals history source).
Happy to provide more detail or test a fix. Thanks for the project — the
MCP server design (research-only surface, no order tools) is excellent.