MCP Setup — AI Assistant Tools (Claude Desktop, Cursor)
ThetaPrime can expose tools to an MCP-capable AI assistant, so you can ask things like "what's my BankNifty strangle's P&L right now" or "is today's reconciliation clean" without opening the dashboard.
This is local only — the assistant spawns mcp_server.py on your own
machine, which talks to your already-running ThetaPrime over localhost only;
nothing is exposed to the internet. Read tools (P&L, positions, status, logs)
always work. Arming a strategy, closing a position, and saving or editing a
strategy spec are each opt-in — see Write tools and
Saving strategy specs below.
Requirements
-
ThetaPrime must be running — the tools read from it live, they don't work standalone.
-
A separate Python install to run
mcp_server.pyunder, with themcpandrequestspackages — ThetaPrime's own bundled runtime isn't a general-purpose interpreter and can't run other scripts. Any recent Python 3 from python.org works; this is unrelated to and doesn't affect your ThetaPrime install.
powershell
pip install mcp requests
- Your dashboard password (Settings → the same one you log in with).
Configure Claude Desktop
mcp_server.py ships in your install directory alongside app.exe (default
C:\Program Files\ThetaPrime\mcp_server.py — check your Start Menu shortcut's
target if you installed elsewhere).
Edit claude_desktop_config.json at %APPDATA%\Claude\claude_desktop_config.json.
{
"mcpServers": {
"thetaprime": {
"command": "C:\Users\you\AppData\Local\Programs\Python\Python312\python.exe",
"args": ["C:\Program Files\ThetaPrime\mcp_server.py"],
"env": {
"THETAPRIME_URL": "http://localhost:5000",
"THETAPRIME_MCP_PASSWORD": "your-dashboard-password"
}
}
}
}
Not sure which python.exe you have? Run (Get-Command python).Source in
PowerShell (after installing Python, if you haven't already).
Restart Claude Desktop after saving.
Tools
| Tool | Answers |
|---|---|
list_strategies |
Which strategies exist, enabled/mode/armed for each |
get_strategy_status(strategy) |
Armed/disarmed and paper/real for one strategy |
get_positions |
Open legs, entry prices, mode for every open position |
get_pnl(strategy?, from_date?, to_date?) |
P&L summary, optionally scoped |
get_reconciliation_status |
Last orphan-position check result |
get_recent_logs(n?) |
Recent App Event Log entries |
get_strategy_spec(strategy) |
The full Composer spec (JSON) of an existing strategy — accepts lib_v1 or lib_v1.spec.json |
Write tools (opt-in)
Off by default. Turn on Settings → Safety Settings → "Allow AI assistant (MCP) to arm, enable and square off strategies" to enable these:
| Tool | Does |
|---|---|
disarm_strategy(strategy) |
Disarms — no confirmation step, this is the fail-safe direction |
disable_strategy(strategy) |
Disables and unschedules — no confirmation step, and not behind this switch (fail-safe direction). Refused while the strategy has an open position |
enable_strategy(strategy, confirm=False) |
Enables (schedules) a strategy — paper enables at once; real mode is a two-call flow, see below. Does not arm it |
arm_strategy(strategy, confirm=False) |
Arms for real trading — two-call flow, see below |
close_position(strategy, confirm=False) |
Squares off at market — two-call flow, see below |
arm_strategy, close_position and (for a real-mode strategy) enable_strategy
use a two-call confirm convention, same
as clicking the button on the dashboard: call once with confirm=False to
get a preview (today's P&L for arm, the legs/exit prices for close, the mode,
armed state and next entry time for enable) — the
assistant should show you that and get your explicit go-ahead in the
conversation — then call again with confirm=True to actually place the
order. Both routes are the exact same code path the dashboard buttons use;
turning this on is equivalent to handing the AI assistant your dashboard
password's arm/square-off access, gated by this separate switch. Switching a
strategy to Real mode counts as arming, so it is behind the same switch;
switching back to Paper (which disarms) is not.
enable_strategy is also refused while the daily loss limit is active, and
disable_strategy is refused unless the strategy is completely flat (no open
leg, no parked long leg, no unconfirmed close, no manual-control flag, no position
engine running) — the dashboard's own Pause button is unchanged and less strict.
The strategy name can be given as lib_v1 or lib_v1.spec.json. Assistant
enables/disables are recorded in the App Event Log with source: mcp.
There's no raw order-placement tool either way — ThetaPrime's unit is a
configured strategy, not a manual order, and every tool requires an explicit
strategy argument (no "current"/"last mentioned" strategy).
Saving strategy specs (opt-in)
A separate switch from the one above: Settings → Safety Settings → "Allow AI
assistant (MCP) to save and edit strategy specs". Off by default. It lets an
assistant — for example one using the thetaprime-strategy-builder skill from
Composer's Build with AI dialog — put a
strategy straight into Composer instead of you importing a .spec.json by hand.
| Tool | Does |
|---|---|
save_strategy_spec(strategy, spec, overwrite=False, confirm=False) |
Saves a spec under a bare name (letters, digits, underscore) |
- A new name saves directly. The strategy is created disabled and in paper mode; nothing runs until you enable it (and, for real trading, arm it) yourself. Check the payoff diagram in Composer first.
- Editing an existing strategy needs
overwrite=Trueand is refused unless the strategy is disarmed, disabled, and has no open position (and no position engine running for it). This is checked by ThetaPrime itself, not left to the assistant. Saving from the Composer page in your browser is unchanged. - Two calls, like arm/close. With
confirm=Falsenothing is written and the assistant gets back the list of changes (for exampleblocks.exits[0].params.pts: 60 -> 45); it should show you that and get your go-ahead before calling again withconfirm=True. - The previous version is kept as
<name>.spec.json.bakin the strategies folder — one file, replaced by the next edit. There is no restore tool: to go back, delete the edited<name>.spec.jsonand rename the.bakto<name>.spec.json. (The dashboard card's<name>.jsonis regenerated on every save.) - Every assistant save is recorded in the App Event Log as
strategy.composer_savedwithsource: mcpand the list of changes.
If the switch is off, save_strategy_spec fails with "AI spec-save is
disabled in Settings" and the skill falls back to giving you a file to import.