Skip to main content

MCP server (stdio) exposing the AlphaForge `forge` CLI to Claude Code / Cursor / Codex

Project description

alpha-forge-mcp

A Model Context Protocol (MCP) server that exposes the AlphaForge alpha-forge CLI to AI coding agents — Claude Code, Cursor, Codex, and any MCP-capable client — over stdio.

⚠️ Pre-release / Alpha (0.1.0aN). Tool signatures and return formats may change without notice. Not recommended for production automation yet. Feedback welcome via Issues.

It is a thin open-source wrapper: it shells out to the (commercial, closed-source) alpha-forge binary with --json and returns the parsed result. The MCP server itself contains no core logic — alpha-forge plus a valid license are required for anything to actually run.

Tools

Tool What it does Underlying command
list_strategies List registered strategies alpha-forge strategy list --json
get_strategy Full JSON of one strategy alpha-forge strategy show <id> --json
list_results List saved backtest results alpha-forge backtest list [--strategy <id>] --json
get_result Metrics & trades of one result alpha-forge backtest report <result_id> --json
run_backtest Run a backtest alpha-forge backtest run <symbol> --strategy <id> [--start] [--end] --json
run_optimize Optimize parameters (Optuna) alpha-forge optimize run <symbol> --strategy <id> [--metric] [--trials] --json
generate_pinescript Generate Pine Script v6 source alpha-forge pine preview --strategy <id> [--with-webhook]

All tools carry MCP tool annotations (readOnlyHint for the read tools; openWorldHint for run_backtest / run_optimize, which fetch external market data) and return structured outputstructuredContent with an object outputSchema — alongside the text result.

Resources

Read-only data is also exposed as MCP resources, so clients such as Claude Code can reference them by @-mention without an explicit tool call. They delegate to the same alpha-forge commands as the read tools and return application/json.

Resource URI Payload
forge://strategies All registered strategies
forge://strategy/{strategy_id} One strategy definition
forge://results All saved backtest results
forge://result/{result_id} Metrics & trades of one result

Prompts

Reusable workflows are exposed as MCP prompts (surfaced as /mcp__alpha-forge__<name> slash commands in Claude Code):

Prompt Arguments What it does
backtest_and_review strategy_id, symbol Run a backtest, then review the key metrics and red flags
optimize_and_verify strategy_id, symbol Optimize with Optuna, then check the result for overfitting

Streamable HTTP transport, RBAC, rate limiting, and audit logging are planned for a later release.

Prerequisites

  1. The alpha-forge binary must be installed and on your PATH (or set ALPHA_FORGE_BIN).
  2. You must be authenticated: run alpha-forge system auth login once.
  3. Python 3.11+ (only needed if not using uvx).

Install & run

The recommended way is via uvx — no manual install needed; your IDE launches it on demand.

uvx alpha-forge-mcp        # starts the stdio MCP server

Or install explicitly:

pip install alpha-forge-mcp
alpha-forge-mcp

Claude Code

The easiest way is the claude mcp add command (user scope — available in every project):

claude mcp add --scope user alpha-forge -- uvx alpha-forge-mcp

Alternatively, add the server to a project-scoped .mcp.json at the repository root (checked in and shared with your team):

{
  "mcpServers": {
    "alpha-forge": { "command": "uvx", "args": ["alpha-forge-mcp"] }
  }
}

Note: Claude Code does not read ~/.claude/mcp.json. User-scoped servers are stored in ~/.claude.json (managed by claude mcp add); project-scoped servers live in .mcp.json at the project root.

Cursor / Codex

Use the same command / args in the client's MCP server configuration:

{
  "mcpServers": {
    "alpha-forge": { "command": "uvx", "args": ["alpha-forge-mcp"] }
  }
}

If alpha-forge is installed at a non-standard location, pass it via env:

{
  "mcpServers": {
    "alpha-forge": {
      "command": "uvx",
      "args": ["alpha-forge-mcp"],
      "env": { "ALPHA_FORGE_BIN": "/path/to/alpha-forge" }
    }
  }
}

Troubleshooting

  • forge_not_found — ensure alpha-forge (or legacy forge) is on PATH, or set ALPHA_FORGE_BIN=/path/to/alpha-forge.
  • authentication_required — run alpha-forge system auth login. The MCP server does not store credentials; it relies on alpha-forge's own auth.

Development

uv sync --extra dev
uv run pytest
uv run ruff check .

Forge binary discovery order: ALPHA_FORGE_BINPATH (forge, alpha-forge) → OS default install paths.

License

Apache License 2.0

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

alpha_forge_mcp-0.1.0a5.tar.gz (66.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

alpha_forge_mcp-0.1.0a5-py3-none-any.whl (18.3 kB view details)

Uploaded Python 3

File details

Details for the file alpha_forge_mcp-0.1.0a5.tar.gz.

File metadata

  • Download URL: alpha_forge_mcp-0.1.0a5.tar.gz
  • Upload date:
  • Size: 66.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for alpha_forge_mcp-0.1.0a5.tar.gz
Algorithm Hash digest
SHA256 60f83a234ec2f9799080c9025920121db60964d9257f88c8c76d6cebb68bafd6
MD5 199a53703a7a762d6c8071270ff59fa3
BLAKE2b-256 a9a8b4aae1debfc35ab6f27aeff4918965dd1859017d243d0083afd87b8c19e2

See more details on using hashes here.

Provenance

The following attestation bundles were made for alpha_forge_mcp-0.1.0a5.tar.gz:

Publisher: publish.yml on alforge-labs/alpha-forge-mcp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file alpha_forge_mcp-0.1.0a5-py3-none-any.whl.

File metadata

File hashes

Hashes for alpha_forge_mcp-0.1.0a5-py3-none-any.whl
Algorithm Hash digest
SHA256 848b4579c32af21c7679dc3bab79005bc910042039f6a14577046c1724a52f22
MD5 fc5aed4945cd58682c2602bebc145cb0
BLAKE2b-256 0cc25f4a0db303f07d89dddfecf4d7081cb9e573ec88c7fafec4bcd20ef591b6

See more details on using hashes here.

Provenance

The following attestation bundles were made for alpha_forge_mcp-0.1.0a5-py3-none-any.whl:

Publisher: publish.yml on alforge-labs/alpha-forge-mcp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page