lockout-mcp

v0.4.0
io.github.lockoutgate/lockout-mcp Checked 2 days ago Published 1 hour ago

Read, preview and trade Robinhood Chain stock tokens through one lockout account.

Your agent sends the order. The account answers on chain, down to the gate. Site · Lock · Bench · Datasheet · GitHub · Verify the bytes lockout-mcp puts seven tools in an agent's hands for one lockout account on Robinhood Chain, signed with the agent's own key. The owner seals the rules first: a loss limit, size caps, a bell and a $LOCKOUT bond. The agent reads them, previews each order against the account's own gates, and sends its buys and sells through the same buy() and sell() the owner uses.

Summary extracted from the README.

lockout-mcp puts seven tools in an agent's hands for one lockout account on Robinhood Chain, signed with the agent's own key. The owner seals the rules first: a loss limit, size caps, a bell and a $LOCKOUT bond. The agent reads them, previews each order against the account's own gates, and sends its buys and sells through the same buy() and sell() the owner uses. Every answer is read from the receipt: executed, halted by the loss latch, or reverted at a numbered gate. Nothing the server does can loosen the rules.

Run npx -y lockout-mcp init to create a local agent key and print client setup and a lock page link that fills in the agent address.

  • npx -y lockout-mcp doctor --account <address> checks the account, agent, feeds and sealed headroom.
  • npx -y lockout-mcp watch <address> follows session events and prints links to their records.
# seven tools on one account; the key file is opened only to trade
claude mcp add lockout -e LOCKOUT_FACTORY=0xeAD444A07f59C89Fb4454F28854245D5D8E1f456 -e LOCKOUT_LENS=0xfbCAcd8748a473a4778a43B1bCd2dB3B563daA42 \
  -e LOCKOUT_ACCOUNT=<account> -e LOCKOUT_AGENT_KEY_FILE=<absolute path of agent.key> -- npx -y lockout-mcp

Set up

  1. Make the agent's key. Run npx -y lockout-mcp init, or use cast below. Use a key other than the owner's. The file holds one 0x-prefixed hex line, readable only by you:
cast wallet new | awk '$1 == "Private" {print $3}' > agent.key && chmod 600 agent.key
cast wallet address --private-key "$(cat agent.key)"     # the address the owner names as the agent
  1. Open the account. The owner, with their own wallet, creates the account on the lock page (https://lockout.exchange/#lock) with that address as the agent, deposits USDG, seals the rules, and sends the agent a little ETH for gas.
  2. Add the server to the agent's client. It runs over stdio and needs Node.js 20 or newer.

Claude Code:

claude mcp add lockout -e LOCKOUT_FACTORY=0xeAD444A07f59C89Fb4454F28854245D5D8E1f456 -e LOCKOUT_LENS=0xfbCAcd8748a473a4778a43B1bCd2dB3B563daA42 \
  -e LOCKOUT_ACCOUNT=<account> -e LOCKOUT_AGENT_KEY_FILE=<absolute path of agent.key> -- npx -y lockout-mcp

Claude Desktop and Cursor:

{ "mcpServers": { "lockout": { "command": "npx", "args": ["-y", "lockout-mcp"],
  "env": { "LOCKOUT_FACTORY": "0xeAD444A07f59C89Fb4454F28854245D5D8E1f456", "LOCKOUT_LENS": "0xfbCAcd8748a473a4778a43B1bCd2dB3B563daA42",
           "LOCKOUT_ACCOUNT": "<account>", "LOCKOUT_AGENT_KEY_FILE": "<absolute path of agent.key>" } } } }

Codex:

[mcp_servers.lockout]
command = "npx"
args = ["-y", "lockout-mcp"]
env = { LOCKOUT_FACTORY = "0xeAD444A07f59C89Fb4454F28854245D5D8E1f456", LOCKOUT_LENS = "0xfbCAcd8748a473a4778a43B1bCd2dB3B563daA42", LOCKOUT_ACCOUNT = "<account>", LOCKOUT_AGENT_KEY_FILE = "<absolute path of agent.key>" }
Setting Meaning
LOCKOUT_FACTORY, LOCKOUT_LENS, LOCKOUT_ACCOUNT Required. On every call the server checks chain 4663, that the factory created the account, and that the Lens reads the same factory.
LOCKOUT_AGENT_KEY_FILE Needed to trade. An absolute path; the server opens it as given.
LOCKOUT_RPC_URL Replaces the public endpoint, https://rpc.mainnet.chain.robinhood.com. Sell previews read with eth_simulateV1, so it must support that.
LOCKOUT_RPC_FALLBACK A second endpoint, tried after the first.
LOCKOUT_TX_JOURNAL A local JSONL file that gets each sent transaction's hash and outcome. A reverted transaction has no logs, so this is where its hash is kept.

The package ships skill/SKILL.md, the procedure for the agent: read the session, preview, send, read the result.

One buy

FIG. 3. buy, from src/tools/trade.ts, src/tools/preview.ts and src/verdict.ts. A diagram of the steps; it shows no amounts.

A predicted rejection is still sent: the reverted transaction is the account's answer on chain, and the buy that meets the loss limit has to be mined to record the halt. Every sent transaction costs gas. The reply carries the preview taken before sending (prediction) and whether the receipt agrees with it (predictionMatched).

Tools

Tool Takes Returns
account_status nothing The session, the bell, the rules, positions, and the loss left before the limit
markets nothing Listed stocks and pools, feed age and pause flags, and the next mint window change
quote stock, side, amount The order simulated on every listed pool, best output first, with its distance from the feed price
preview_buy stock, usdgIn, poolRef?, minSharesOut? The account's verdict on one buy, with no transaction
preview_sell stock, sharesIn, poolRef?, minUsdgOut? The account's verdict on one sell, with no transaction
buy as preview_buy The buy sent with the agent key, and its verdict from the receipt
sell as preview_sell The sell sent with the agent key, and its verdict from the receipt
  • Amounts are strings. An integer is raw units; add a decimal point for display units, so "200.0" is 200 USDG.
  • Without poolRef, the passing pool with the highest output is used; if none passes, the first listed pool.
  • Without a minimum, it comes from the preview and the session's maxSlippageBps, at least one raw unit.

Reading a result

outcome Receipt What it means
EXECUTED status 1, BuyExecuted or SellExecuted The trade filled. For a sell, check executed: a zero fill is possible. halted: true means this trade closed buys until the bell.
REJECTED_HALT_LATCHED status 1, LockoutTriggered, no fill The buy met the loss limit at gate 05. Nothing traded and the account is halted: later buys in this session revert at gate 03 (AccountHalted()), so do not resend them.
REJECTED_REVERT status 0 The account refused the order. gateIndex and errorName come from replaying it one block earlier, and stay empty when that replay disagrees.

When the server cannot get that far, the tool returns an error and no verdict:

Error Do
Set LOCKOUT_AGENT_KEY_FILE for trading, Agent key file is unreadable or invalid Point the setting at the key file: one 0x line of 64 hex digits.
This key is not the agent of this account The owner named another agent, or cleared it. Nothing was sent.
Insufficient ETH for transaction gas Send the agent's address ETH. Nothing was sent.
RPC chain ID must be 4663, Account is outside the configured factory, Lens factory does not match Check the endpoint and the three addresses.
Lens and account simulation disagree The two reads gave different answers at one block. Nothing was sent; read again.
Transaction receipt was unavailable within 30 seconds The reply carries txHash. Look it up before sending anything new.

What this key cannot do

FIG. 2. From the access checks in LockoutAccount.sol and LockoutFactory.sol: solid gold arrows move tokens, thin arrows call, dashed arrows read.

  • Call anything but buy and sell. seal, tighten, manualHalt, setAgent, depositUsdg, withdraw, sweep and emergencyWithdraw revert with NotOwner(). No tool here sends them.
  • Trade outside a sealed session: buys revert at gate 01 and sells at sell gate 04. Agent sells still work between the bell and release().
  • Buy before the bell once the account is halted: gate 03.
  • Trade a stock without a live feed. The feed must be no older than maxFeedAgeSec and at most 90,000 s, its oracle not paused, and maxSlippageBps above 0; each fill must land within maxSlippageBps of the feed price.
  • Receive tokens. The account pays only its owner.

The owner can clear this key while the session is sealed, never swap in another. Keep the key file on the machine that runs the server, mode 600; the server reads it only to sign, and refuses to send when the key is the owner's or no longer the account's agent.