mcp-strategy-research-db

mcp-strategy-research-db

An MCP server that provides access to a SQLite database for analyzing trading strategy backtest results and performance metrics. It enables AI assistants to identify robust strategies across different market regimes and compare them against benchmarks using risk-adjusted metrics.

Category
访问服务器

README

mcp-strategy-research-db

A Model Context Protocol (MCP) server that provides Claude Code access to a strategy research SQLite database for analyzing trading strategy backtest results.

Features

  • Analyze strategy performance across multiple market periods
  • Find strategies that work across all market regimes (robust strategies)
  • Compare strategies against Buy & Hold benchmarks
  • Query risk-adjusted metrics (Calmar ratio, Sharpe ratio)
  • Find alpha-generating strategies that beat benchmarks
  • Analyze strategy consistency across different symbols
  • Run custom SQL queries (read-only) for advanced analysis

Installation

# Clone the repository
git clone https://github.com/locupleto/mcp-strategy-research-db.git
cd mcp-strategy-research-db

# Create virtual environment
python3 -m venv venv
source venv/bin/activate

# Install dependencies
pip install -r requirements.txt

Configuration

Set the required environment variable:

export STRATEGY_DB_PATH=/path/to/strategy_research.db

The database is typically generated by the trading-lab project's strategy search scripts.

Register with Claude Code

MCP servers can be registered at two scopes:

Project Level (Recommended)

Registers the server for the current project only. The configuration is stored in ~/.claude.json under the project's path. This is the recommended approach for project-specific tools.

cd /Volumes/Work/development/projects/git/mcp-strategy-research-db

claude mcp add strategy-research-db \
    "$(pwd)/venv/bin/python3" \
    "$(pwd)/strategy_research_mcp_server.py"

This adds the server to ~/.claude.json under the project's mcpServers configuration:

{
  "projects": {
    "/Volumes/Work/development/projects/git/mcp-strategy-research-db": {
      "mcpServers": {
        "strategy-research-db": {
          "type": "stdio",
          "command": "/Volumes/Work/development/projects/git/mcp-strategy-research-db/venv/bin/python3",
          "args": [
            "/Volumes/Work/development/projects/git/mcp-strategy-research-db/strategy_research_mcp_server.py"
          ]
        }
      }
    }
  }
}

User Level (Global)

Registers the server globally, available in all projects. Use the -s user flag:

claude mcp add -s user strategy-research-db \
    "$(pwd)/venv/bin/python3" \
    "$(pwd)/strategy_research_mcp_server.py"

Verify Registration

# List all registered MCP servers
claude mcp list

# Debug mode for troubleshooting
claude --mcp-debug

Tools (17 total)

Database Overview

Tool Description
get_database_status Database statistics: runs, strategies, symbols, date ranges
list_search_runs List all backtest runs with filtering options
get_run_details Get detailed information about a specific search run

Strategy Analysis

Tool Description
get_top_strategies Get top-ranked strategies with customizable sorting and filters
get_strategy_details Get full details for a specific strategy ID
compare_strategy_across_periods Analyze how a strategy performs across different market periods

Cross-Period Robustness

Tool Description
find_robust_strategies Find strategies that work consistently across ALL market periods
get_period_summary Summary statistics for each market period tested

Benchmark Analysis

Tool Description
find_alpha_generators Find strategies that beat Buy & Hold benchmark
get_risk_adjusted_rankings Rank strategies by Calmar ratio or other risk-adjusted metrics

Symbol Analysis

Tool Description
get_symbol_performance Performance breakdown by individual symbol
find_best_symbols_for_strategy Find which symbols work best with a given strategy

Capital Deployment Analysis

Tool Description
get_capital_deployment_analysis Analyze portfolio capital utilization across periods using time-in-market data
get_daily_position_counts Get exact daily position counts from trade-level data (requires Dec 2025+ runs)
compare_timing_modes Compare Conservative (T+1) vs Aggressive (same-day) trade timing

Advanced

Tool Description
run_custom_query Execute custom SQL queries (read-only)
get_schema Get database schema documentation
list_strategy_ids List strategy IDs with optional pattern filtering

Key Metrics Explained

Performance Metrics

  • Expectancy: Expected return per trade (%)
  • Win Rate: Percentage of winning trades
  • Profit Factor: Gross profit / Gross loss ratio
  • CAGR: Compound Annual Growth Rate

Risk Metrics

  • Max Drawdown: Largest peak-to-trough decline
  • Calmar Ratio: CAGR / Max Drawdown (higher = better risk-adjusted returns)
  • Sharpe Ratio: Risk-adjusted return relative to risk-free rate

Consistency Metrics

  • Consistency Score: % of symbols where strategy is profitable
  • Symbols Beating Benchmark: % of symbols that outperform Buy & Hold

Example Usage

# Get overview of the database
> get_database_status

# Find strategies that work in ALL market periods
> find_robust_strategies min_periods=6 min_consistency=0.7

# Get top strategies for a specific period
> get_top_strategies period_name="2008 Financial Crisis" sort_by="median_calmar_ratio" limit=10

# Compare a strategy across all periods
> compare_strategy_across_periods strategy_id="buy_adm_momentum_low__sell_adm_momentum_high"

# Find alpha generators
> find_alpha_generators min_alpha=5.0 min_beat_rate=0.6

Database Schema

The SQLite database contains four main tables:

search_runs

Metadata about each backtest run (study, period, date range, benchmark data)

aggregated_results

Strategy-level aggregated metrics using MEDIAN values across all symbols tested

symbol_results

Per-symbol backtest results for detailed analysis

trade_results (Dec 2025+)

Individual trade records with entry/exit dates for daily position count analysis. Enables exact portfolio-level capital deployment tracking over time.

Requirements

  • Python 3.10+
  • MCP SDK (mcp>=1.23.1)
  • SQLite strategy research database (from trading-lab project)

Related Projects

  • trading-lab: Strategy backtesting and signal research platform
  • mcp-marketdata-db: Market data MCP server

License

MIT

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选