AI agents and MCP
This content is not available in your language yet.
AI-written bots and autonomous AI agents fail in ways ordinary scripts do not: an agent can loop, invert a buy into a sell, misread a lot size, or be steered into an unwanted order by prompt injection in external text. Putting the risk limits inside the prompt does not solve this — the limits must live outside the agent.
geometer-markets mcp runs a local Model Context Protocol (MCP) server that sits in front of your Order Guard. The AI agent never sees your broker credentials, cannot change limits.json, and can never re-arm a stop switch.
How the MCP server connects
Section titled “How the MCP server connects”Start the Order Guard first, issue a dedicated scoped local key for your agent (with tight limits and a narrow symbol allowlist), and point your MCP client at geometer-markets mcp:
# Issue a dedicated key for the agent (paper first)geometer-markets key create \ --name claude-paper-agent \ --mode paper \ --account default \ --strategy ai-agent \ --limits ai-tight-limits
# Run the MCP server over stdio talking only to the local Order GuardGEOMETER_GUARD_KEY="gm_paper_..." geometer-markets mcp --guard http://127.0.0.1:7878Every order action from the MCP server goes through the exact same /v1/* API, OPS rate limiter, margin estimate, worst-case options check, unknown-outcome gate, and signed hash chain as any other bot.
Available MCP tools
Section titled “Available MCP tools”The MCP server exposes eight focused tools:
| Tool | Privilege | What it does |
|---|---|---|
preview_order |
Read-only dry run | Computes itemized India charges (brokerage, STT, exchange fee, SEBI fee, stamp duty, GST) and runs the pre-trade risk check without sending an order to the broker. |
place_order |
orders:write |
Submits an explicit order requiring symbol, side, quantity, order_type, product, client_order_id (and price/trigger_price as required). Reports structured guard approval or refusal (code, message, limit, decision_id). |
cancel_order |
orders:write |
Cancels an open order owned strictly by this key’s scoped account_id and strategy_id. Cannot touch manual orders or other strategies’ orders. |
positions |
portfolio:read |
Reads reconciled net and day positions for the scoped account. |
limits |
limits:read |
Reads active limits.json, limits_version, limits_hash, and current daily counters. Strictly read-only — never edits limits. |
stop |
stop:engage |
Engage-only stop switch restricted to scope: "strategy" and modes no_new_risk or cancel_all. |
record_head |
record:read |
Reads the current signed chain sequence number, head_hash, last checkpoint sequence, and signer_pub_key. |
ask_product_help |
Documentation help | Answers neutral technical questions about limits.json fields, order mechanics, stop switches, static IPv6 setup, and offline verification. |
Tight limits and engage-only stop switch
Section titled “Tight limits and engage-only stop switch”Treat any AI agent as an untrusted operator and give it a dedicated, narrow configuration:
- Start on paper (
gm_paper_...): test your agent workflow end-to-end against the paper venue before ever issuing a live key. - Narrow allowlists: restrict
allowed_symbols,allowed_products, andallowed_segmentsto only the instruments the agent actually needs. - Low per-order and daily caps: set strict
max_order_qty,max_order_value_inr,max_daily_loss_inr,max_daily_trades, andallow_naked_short_options: false. - Engage-only
stoptool: an agent can pause its own strategy (no_new_riskorcancel_all) if it detects an anomaly, and must supply areason. The MCPstoptool refuses:- Re-arming or downgrading back to
normal close_positionsandhaltedmodesaccount,symbol, orglobalscopes
- Re-arming or downgrading back to
Only a human operator on the privileged local control plane (geometer-markets kill over guard-admin.sock) can clear or re-arm a stop switch or widen limits.json.
Tools-only refusal policy
Section titled “Tools-only refusal policy”Geometer Markets enforces its tools-only boundary directly inside the MCP server:
- Every text-bearing input field across all eight tools is screened both individually and concatenated (to stop split-field prompt smuggling).
- Requests asking which security to buy or sell, which option strike or expiry to pick, how to size positions for a given capital, or which trading approach to choose are refused with a structured refusal code — without naming any trade direction, security, or risk size.
- This refusal filter is tested across English, Hindi (Devanagari and Romanized), and Malayalam (Malayalam script and Romanized), while neutral tool-usage questions (such as “How do I set
max_daily_loss_inrinlimits.json?”) are answered normally throughask_product_help.