MCP server for Jesse algorithmic trading framework
Project description
Jesse MCP Server
An MCP (Model Context Protocol) server that exposes Jesse's algorithmic trading framework capabilities to LLM agents.
Status: Feature Complete ✅
All planned features implemented and tested. 32 tools available (17 core + 15 agent).
Installation
PyPI
pip install jesse-mcp
uvx (recommended for running directly)
uvx jesse-mcp
Arch Linux (AUR)
yay -S jesse-mcp
# or
paru -S jesse-mcp
From Source
git clone https://github.com/bkuri/jesse-mcp.git
cd jesse-mcp
pip install -e .
Usage
# stdio transport (default, for MCP clients)
jesse-mcp
# HTTP transport (for remote access)
jesse-mcp --transport http --port 8100
# Show help
jesse-mcp --help
Environment Variables
| Variable | Description | Default |
|---|---|---|
JESSE_URL |
Jesse REST API URL | http://localhost:9000 |
JESSE_PASSWORD |
Jesse UI password | (required) |
JESSE_API_TOKEN |
Pre-generated API token | (alternative to password) |
Features
- Backtesting - Single and batch backtest execution via Jesse REST API
- Optimization - Hyperparameter tuning with walk-forward validation
- Monte Carlo Analysis - Statistical robustness testing
- Pairs Trading - Cointegration testing and strategy generation
- Strategy Management - CRUD operations for trading strategies
- Risk Analysis - VaR, stress testing, comprehensive risk reports
- Agent Tools - 15 specialized tools for autonomous trading workflows
Architecture
LLM Agent ←→ MCP Protocol ←→ jesse-mcp ←→ Jesse REST API (localhost:9000)
↓
Mock Fallbacks (when Jesse unavailable)
Available Tools (32 Total)
Core Tools (17)
Phase 1: Backtesting
| Tool | Description |
|---|---|
backtest |
Run single backtest with specified parameters |
strategy_list |
List available strategies |
strategy_read |
Read strategy source code |
strategy_validate |
Validate strategy code |
Phase 2: Data & Analysis
| Tool | Description |
|---|---|
candles_import |
Download candle data from exchanges |
backtest_batch |
Run concurrent multi-asset backtests |
analyze_results |
Extract insights from backtest results |
walk_forward |
Walk-forward analysis for overfitting detection |
Phase 3: Optimization
| Tool | Description |
|---|---|
optimize |
Optimize hyperparameters using Optuna |
Phase 4: Risk Analysis
| Tool | Description |
|---|---|
monte_carlo |
Monte Carlo simulations for risk analysis |
var_calculation |
Value at Risk (historical, parametric, Monte Carlo) |
stress_test |
Test under extreme market scenarios |
risk_report |
Comprehensive risk assessment |
Phase 5: Pairs Trading
| Tool | Description |
|---|---|
correlation_matrix |
Cross-asset correlation analysis |
pairs_backtest |
Backtest pairs trading strategies |
factor_analysis |
Decompose returns into systematic factors |
regime_detector |
Identify market regimes and transitions |
Agent Tools (15)
Specialized tools for autonomous trading workflows:
| Tool | Description |
|---|---|
strategy_suggest_improvements |
AI-powered strategy enhancement suggestions |
strategy_compare_strategies |
Compare multiple strategies side-by-side |
strategy_optimize_pair_selection |
Optimize pairs trading selection |
strategy_analyze_optimization_impact |
Analyze impact of optimization changes |
risk_analyze_portfolio |
Portfolio-level risk analysis |
risk_stress_test |
Advanced stress testing |
risk_assess_leverage |
Leverage risk assessment |
risk_recommend_hedges |
Hedging recommendations |
risk_analyze_drawdown_recovery |
Drawdown recovery analysis |
backtest_comprehensive |
Full backtest with all metrics |
backtest_compare_timeframes |
Compare performance across timeframes |
backtest_optimize_parameters |
Quick parameter optimization |
backtest_monte_carlo |
Backtest with Monte Carlo analysis |
backtest_analyze_regimes |
Regime-aware backtest analysis |
backtest_validate_significance |
Statistical significance validation |
Testing
# Install dev dependencies
pip install jesse-mcp[dev]
# Run all tests
pytest -v
# Run with coverage
pytest --cov=jesse_mcp
Status: 49 tests passing
Local Development
Prerequisites
- Python 3.10+
- Jesse 1.13.x running on localhost:9000
- PostgreSQL on localhost:5432
- Redis on localhost:6379
Start Jesse Stack (Podman)
# Start infrastructure
podman run -d --name jesse-postgres --network host \
-e POSTGRES_USER=jesse_user -e POSTGRES_PASSWORD=password -e POSTGRES_DB=jesse_db \
docker.io/library/postgres:14-alpine
podman run -d --name jesse-redis --network host \
docker.io/library/redis:6-alpine redis-server --save "" --appendonly no
# Start Jesse
podman run -d --name jesse --network host \
-v /path/to/jesse-bot:/home:z \
docker.io/salehmir/jesse:latest bash -c "cd /home && jesse run"
Start Dev MCP Server
./scripts/start-dev-server.sh # Start on port 8100
./scripts/stop-dev-server.sh # Stop server
Add to OpenCode
Add to ~/.config/opencode/opencode.json:
{
"mcp": {
"jesse-mcp-dev": {
"type": "remote",
"url": "http://localhost:8100/mcp",
"enabled": true
}
}
}
Documentation
- Using with LLMs - How to use with MCP-compatible LLMs
- Production Deployment - Production deployment guide
- Jesse Setup - Jesse integration setup
- Agent System - Agent architecture
- AGENTS.md - Development guidelines for AI agents
API Reference
Jesse REST Client
The jesse_rest_client.py module provides direct access to Jesse's REST API:
from jesse_mcp.core.jesse_rest_client import get_jesse_rest_client
client = get_jesse_rest_client()
# Run backtest
result = client.backtest(
strategy="OctopusStrategy",
symbol="BTC-USDT",
timeframe="1h",
start_date="2024-01-01",
end_date="2024-01-31"
)
Mock Implementations
When Jesse is unavailable, all tools gracefully fall back to mock implementations that return realistic synthetic data. This enables development and testing without a full Jesse installation.
Key Dependencies
| Package | Version | Purpose |
|---|---|---|
| fastmcp | >=0.3.0 | MCP server framework |
| numpy | >=1.24.0 | Numerical computations |
| pandas | >=2.0.0 | Data manipulation |
| scipy | >=1.10.0 | Statistical functions |
| scikit-learn | >=1.3.0 | ML utilities |
| optuna | >=3.0.0 | Hyperparameter optimization |
Project Structure
jesse_mcp/
├── server.py # FastMCP server with 17 core tools
├── optimizer.py # Phase 3: Optimization tools
├── risk_analyzer.py # Phase 4: Risk analysis tools
├── pairs_analyzer.py # Phase 5: Pairs trading tools
├── agent_tools.py # 15 agent-specific tools
├── core/
│ ├── integrations.py # Jesse framework integration
│ ├── jesse_rest_client.py # REST API client
│ └── mock.py # Mock implementations
├── agents/
│ ├── base.py # Base agent class
│ ├── backtester.py # Backtesting specialist
│ └── risk_manager.py # Risk management specialist
└── scripts/
├── start-dev-server.sh
└── stop-dev-server.sh
License
MIT License - see LICENSE file for details.
Publishing
This package uses GitHub Actions with PyPI trusted publishing. To release a new version:
- Update version in
pyproject.tomlandjesse_mcp/__init__.py - Create a git tag:
git tag v1.x.x - Push tag:
git push origin v1.x.x - Create GitHub release - automatically publishes to PyPI
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file jesse_mcp-1.0.0.tar.gz.
File metadata
- Download URL: jesse_mcp-1.0.0.tar.gz
- Upload date:
- Size: 75.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0f3201c271dd338bd18fad12703b4af346a8318268f9aadf08940f2d5e3c9193
|
|
| MD5 |
36a54c5340be10d3ba951ef23f1f6a9e
|
|
| BLAKE2b-256 |
49243bf909c19390eb6a4f06f069678900a5f7d0bf619ce112209ccb1574f20c
|
Provenance
The following attestation bundles were made for jesse_mcp-1.0.0.tar.gz:
Publisher:
publish.yml on bkuri/jesse-mcp
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
jesse_mcp-1.0.0.tar.gz -
Subject digest:
0f3201c271dd338bd18fad12703b4af346a8318268f9aadf08940f2d5e3c9193 - Sigstore transparency entry: 961524891
- Sigstore integration time:
-
Permalink:
bkuri/jesse-mcp@a9b22fa65d95ace315cc36473eaeb625370fc26b -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/bkuri
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@a9b22fa65d95ace315cc36473eaeb625370fc26b -
Trigger Event:
release
-
Statement type:
File details
Details for the file jesse_mcp-1.0.0-py3-none-any.whl.
File metadata
- Download URL: jesse_mcp-1.0.0-py3-none-any.whl
- Upload date:
- Size: 87.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f78c4078bcbe99a16b31ec77433805f6037c974bb947cf1413f1b7a821f1fe58
|
|
| MD5 |
3bc8392cf48c06b5c895490e2658bbeb
|
|
| BLAKE2b-256 |
484202b37bda76d81ab9cde03768e97b1fac505339c3606187d7ceb188d39e39
|
Provenance
The following attestation bundles were made for jesse_mcp-1.0.0-py3-none-any.whl:
Publisher:
publish.yml on bkuri/jesse-mcp
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
jesse_mcp-1.0.0-py3-none-any.whl -
Subject digest:
f78c4078bcbe99a16b31ec77433805f6037c974bb947cf1413f1b7a821f1fe58 - Sigstore transparency entry: 961524928
- Sigstore integration time:
-
Permalink:
bkuri/jesse-mcp@a9b22fa65d95ace315cc36473eaeb625370fc26b -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/bkuri
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@a9b22fa65d95ace315cc36473eaeb625370fc26b -
Trigger Event:
release
-
Statement type: