SDK/MCP

Run it with Claude

PREVIEW

this walkthrough follows packages/mcp/examples/claude.ts, which ran against a local network in the SDK's end-to-end run.

1. Prepare the agent#

You need the agent's key file, a deployment JSON, and the account ids the owner created for the agent. For a borrower that is the SUI treasury and cap plus the cash treasury and cap. See the Quickstart and Owner actions.

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. The blocks below use /path/to/agent.env for that same path.

2. Add the server to Claude Code#

Shell
claude mcp add essey-sui \
  -e ESSEY_NETWORK=localnet \
  -e ESSEY_RPC_URL=http://127.0.0.1:9000 \
  -e ESSEY_DEPLOYMENT=/path/to/deployment.json \
  -e ESSEY_AGENT_KEY_FILE=/path/to/agent.env \
  -e ESSEY_TREASURY=0x… -e ESSEY_AGENT_CAP=0x… \
  -e ESSEY_CASH_TREASURY=0x… -e ESSEY_CASH_CAP=0x… \
  -e ESSEY_GAS=address-balance \
  -- npx essey-sui-mcp

2b. Or Claude Desktop#

In claude_desktop_config.json:

JSON
{
  "mcpServers": {
    "essey-sui": {
      "command": "npx",
      "args": ["essey-sui-mcp"],
      "env": {
        "ESSEY_NETWORK": "localnet",
        "ESSEY_RPC_URL": "http://127.0.0.1:9000",
        "ESSEY_DEPLOYMENT": "/path/to/deployment.json",
        "ESSEY_AGENT_KEY_FILE": "/path/to/agent.env",
        "ESSEY_TREASURY": "0x…",
        "ESSEY_AGENT_CAP": "0x…",
        "ESSEY_CASH_TREASURY": "0x…",
        "ESSEY_CASH_CAP": "0x…",
        "ESSEY_GAS": "address-balance"
      }
    }
  }
}

Use your own paths and ids. On testnet set ESSEY_NETWORK=testnet, ESSEY_DEPLOYMENT to the file saved from GET /v1/config, and ESSEY_PRIVATE to the file saved from GET /v1/private/config so essey_private_* is served (Install). Drop ESSEY_RPC_URL to use Sui's testnet node. ESSEY_BORROW_ALLOWANCE is what essey_owner_deposit writes into the borrow rules.

3. What happened when it ran#

The example drove the real server with the official MCP client, the way Claude does. On the local network:

CallResult
startessey-sui-mcp: agent 0xb9cb…7193 on localnet, keys separate
list tools24 tools
essey_statusrole borrower, separation ok
essey_offers2 live offers, cheapest usable at 600 bps
essey_borrow {offerId, collateral: "25000000000", amount: "3000000"}landed, signed by the agent key — localnet digest HQnv1iwrJHM2FSinSQJXaQr7nQ2AsfyUMnT76LZqKccu
essey_loansthe open loan owes 3000000
essey_repay {loanId}repaid from the cash treasury — localnet digest 2hDFBvuFWfaLjuwiW8eihKij9u1jTn21TYaPF5h3ygfX
essey_owner_renew {expiresAtMs}unsigned bytes for the owner's address, agentSigned: false
owner devicesigned the renewal bytes — localnet digest Fe1Q73QKPeNzrk65EY54iZRb7sPD5AtiMicGqraEhV9U
essey_warningsnone

Things to ask the agent#

Each maps to one tool: "What can 25 SUI borrow?" (essey_quote), "Borrow 3 USDC on 25 SUI from the cheapest offer" (essey_offers, then essey_borrow), "Repay my loan" (essey_repay), "Renew my caps for ten days" (essey_owner_renew — you then sign the bytes on your own device).