इसे छोड़कर कंटेंट पर जाएं

AI agents and MCP

यह कंटेंट अभी तक आपकी भाषा में उपलब्ध नहीं है।

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.

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:

Terminal window
# 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 Guard
GEOMETER_GUARD_KEY="gm_paper_..." geometer-markets mcp --guard http://127.0.0.1:7878

Every 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.

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.

Treat any AI agent as an untrusted operator and give it a dedicated, narrow configuration:

  1. Start on paper (gm_paper_...): test your agent workflow end-to-end against the paper venue before ever issuing a live key.
  2. Narrow allowlists: restrict allowed_symbols, allowed_products, and allowed_segments to only the instruments the agent actually needs.
  3. Low per-order and daily caps: set strict max_order_qty, max_order_value_inr, max_daily_loss_inr, max_daily_trades, and allow_naked_short_options: false.
  4. Engage-only stop tool: an agent can pause its own strategy (no_new_risk or cancel_all) if it detects an anomaly, and must supply a reason. The MCP stop tool refuses:
    • Re-arming or downgrading back to normal
    • close_positions and halted modes
    • account, symbol, or global scopes

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.

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_inr in limits.json?”) are answered normally through ask_product_help.