SDK/MCP

MCP server

PREVIEW

@esseyonsui/sui-mcp is a Model Context Protocol server over the SDK, for an agent that runs on its owner's own machine. It speaks MCP over stdio. It runs on Sui testnet and on a localnet; Essey has no mainnet deployment.

It implements the part of MCP it needs — initialize, ping, tools/list, tools/call — itself, rather than loading the official server SDK, whose 95 packages would run inside the process that holds the agent key. Interoperability with the official client is tested separately.

The server requires an agent key file before it starts, even to list its tools. It reads the path only from ESSEY_AGENT_KEY_FILE. That variable is required and has no default. From the project that installed the packages, this writes a mode-600 testnet file and prints the new address:

Shell
node --input-type=module -e "import { createAgentKeyFile } from '@esseyonsui/sui-sdk'; console.log(createAgentKeyFile('agent.env', 'testnet'))"

Point the server at it with ESSEY_AGENT_KEY_FILE=agent.env. essey-sui-init --key writes the same kind of file when that path is missing.

Tools#

24 tools in three groups, split by key and never mixed. With ESSEY_PRIVATE set the server adds the private-flow tools: 77 in all when the ids file carries the v2 sections.

  • Read — no signature.
  • Agent (essey_*) — signed with the agent's own key, inside the limits its owner set on chain. A refusal the node foresees comes back as an error result naming the Move abort (WOULD_ABORT), before anything is signed; a refusal after signing comes back with the digest and the abort's Move name.
  • Owner (essey_owner_*) — never signed. They return { kind: "unsigned", sender, txBytes, kindBytes, agentSigned: false } for the owner to sign on their own device. The owner address and OwnerCaps come from the chain, not from configuration.

Amounts are whole-number strings in the coin's smallest unit: "1000000" is 1 USDC, "1000000000" is 1 SUI. Object ids are 0x hex strings.

Read#

ToolInputsReturns
essey_status—The agent's address, network, role, the deployment's pool, a borrower's allowance left (null without borrow rules), each cap's balance and limits, and the key-separation result.
essey_offers—Live offers with room left, cheapest first.
essey_loansincludeClosed?Open loans only, for a borrower and a lender, with what each owes now. includeClosed: true also lists closed loans. A lender's repaid loan still holding its claim comes back with owed "0".
essey_quotecollateral? (MIST), amount? (loan units)The market's limits, the collateral's borrow value, the pool rate for the amount.
essey_rooms—Sealed rooms still open to bids or to settle.
essey_warnings—Caps near expiry or revoked, loans that can be liquidated, loans due within a day.

Agent (signed by the agent key)#

ToolRoleInputs (required unless marked ?)
essey_post_offerlenderrateBps, maxLtvBps, minFill, maxFill, size, termMs, expiryMs
essey_cancel_offerlenderofferId
essey_borrowborrowerofferId? (omit for the pool), collateral, amount. The result is { ok, digest, loanId }. loanId is the Loan the transaction created, or null when it did not land. essey_repay returns the loanId you passed; a second essey_repay of a repaid loan is refused before signing with borrower::release abort 2 ENoDeed. essey_refinance returns the new loan's id from the created object types.
essey_repayborrowerloanId
essey_refinanceborrowerloanId, offerId, amount
essey_add_collateralborrowerloanId, amount (MIST)
essey_claimborrowerloanId
essey_upkeepeitherdryRun? (decide and report, sign nothing)

A tool for the wrong role is refused before anything is built: a lender cannot borrow and a borrower cannot post offers.

Upkeep#

essey_upkeep runs one pass of what a hosted agent gets: it repays loans before they are due (and every loan by the repay-by), brings home what a closed loan left, tops up a loan near its safety line, flags a lender's defaulted loans with the owner's unsigned collect bytes, and lists warnings. Each step comes back as landed, refused (with the digest and the abort), planned, waiting, owner-action or warning. What a pass does is set by ESSEY_REPAY_LEAD_MS, ESSEY_AUTO_TOP_UP and ESSEY_AUTO_CLAIM (see Configuration).

Public MCP safety#

Seven public tools sign with the agent key: essey_post_offer, essey_cancel_offer, essey_borrow, essey_repay, essey_refinance, essey_add_collateral, and essey_claim.

Call essey_upkeep with dryRun: true. That pass reports and signs nothing. Leaving dryRun off, or setting it false, signs.

Do not start the upkeep loop (essey-sui-mcp upkeep). Without --dry-run it signs, every 60 seconds until stopped. The SDK exports one pass as upkeep and the loop as runUpkeep.

An upkeep step with outcome owner-action nests the owner's unsigned txBytes for collecting a default. agentSigned is false. Do not sign those bytes unless the owner intends that default action.

A sealed room is not an agent tool: the agent signs only the agent lane, and a borrower runs a room from their own wallet. See Key separation.

Owner (unsigned bytes)#

ToolInputs (required unless marked ?)
essey_owner_setuprole (lender/borrower), owner (must differ from the agent), capExpiresAtMs; borrower: suiBudget, cashBudget
essey_owner_lender_rulestotalCap, minFill, maxFill, minRateBps, maxDurationMs, maxLtvBps, capExpiresAtMs?, amount?. On the first call, before a mandate exists, also takerKind and takers: 0 and [] for an open book, 1 with the allowlist, or 2 and [] for sealed rooms only. Later calls may omit either field; the live mandate is written forward. If that read fails, pass both explicitly. They are not defaulted.
essey_owner_depositlender: amount; borrower: cashFloat? and/or collateral? — with collateral, also suiBudget, cashBudget, capExpiresAtMs, maxRateBps, minTermMs, latestMaturityMs, and poolId? — the one pool it may borrow from; omit it and every pool is refused. The cash treasury the rules pin is always the one configured in ESSEY_CASH_TREASURY, read back through the key-separation check, never an input. The allowance in the rules is ESSEY_BORROW_ALLOWANCE, also never an input; without it a deposit with collateral is refused.
essey_owner_renewexpiresAtMs — every cap, same limits and recipients
essey_owner_revoke—
essey_owner_withdrawlender: amount; borrower: sui?, cash?. While a loan is open, cash left behind must cover what those loans owe. A cash amount that would leave less is LOAN_OPEN. The hosted API also keeps the cash float on the agent's form, and a withdraw with no amount takes only the excess.
essey_owner_collect_defaultloanId
essey_owner_loanaction (repay/claim/add-collateral), loanId, amount?. amount is required for add-collateral. Omit it on repay and the tool draws the live amount owed plus a short margin, so interest during signing still closes the loan; the change returns to the cash treasury. Pass amount to repay a specific sum.

A borrower deposit with collateral sets the on-chain borrow rules, which the testnet package carries.

Results#

Each call returns JSON text. A result whose ok is false — a chain refusal — is marked as an error so the agent can read it.