StarkFiStarkFi

MCP Server

27 MCP tools for AI-native Starknet DeFi automation

What is MCP?

The Model Context Protocol (MCP) is an open standard that enables AI assistants (like Claude, Cursor, Windsurf, Antigravity) to interact with external tools. StarkFi runs as an MCP server, exposing every DeFi feature as a typed tool with Zod-validated schemas.

Prerequisites

Before using StarkFi MCP tools:

  1. Node.js v18 or later
  2. StarkFi Auth Server running (required for authentication and signing)
  3. Authentication — run npx starkfi@latest auth login <email> and verify with the OTP before the MCP server can execute transactions

Important: The MCP server requires an active authenticated session. Always call get_auth_status first to verify the session is active before attempting any wallet operations.

Getting Started

1. Configure your AI client  →  See Setup
2. get_auth_status            →  Verify session is active
3. Read-only tools            →  Query balances, quotes, positions (safe, no confirmation needed)
4. Transactional tools        →  Execute swaps, sends, staking (requires user confirmation)

Tool Categories

CategoryCountTools
Auth & Config2get_auth_status, config_action
Wallet5get_tx_status, get_balance, deploy_account, send_tokens, get_portfolio
Trade5get_swap_quote, swap_tokens, get_multi_swap_quote, multi_swap, batch_execute
Staking8list_validators, list_pools, get_staking_info, get_stake_status, stake_tokens, unstake_tokens, claim_rewards, compound_rewards
Lending7list_lending_pools, get_lending_position, supply_assets, withdraw_assets, borrow_assets, repay_debt, close_position

How It Works

  1. StarkFi starts an MCP server via starkfi mcp-start
  2. The server uses StdioServerTransport for communication
  3. AI clients connect and discover all 27 tools with JSON schemas
  4. The AI sends tool calls, StarkFi executes them on Starknet
  5. Results are returned as structured JSON

All tools return consistent error responses with typed StarkfiError codes — see Error Handling.

Read-Only vs Transactional

Read-OnlyTransactional
Examplesget_balance, get_swap_quote, list_validatorsswap_tokens, send_tokens, stake_tokens
Side effectsNone — safe to call freelyMutates blockchain state
User confirmationNot neededAlways required before execution
SimulationN/ASet simulate: true to preview fees without executing

Agent Best Practices

  1. Always authenticate first — call get_auth_status before any operation
  2. Quote before executing — call get_swap_quote before swap_tokens, and get_multi_swap_quote before multi_swap
  3. Use simulation — set simulate: true on any transactional tool to preview fees
  4. Confirm with the user — never execute a transactional tool without explicit user confirmation
  5. Check existing positions — use get_stake_status and get_lending_position before staking/lending to avoid duplicates

Starting the Server

starkfi mcp-start

Or configure it as an MCP server in your AI client's config — see Setup.

Edit on GitHub

Last updated on

On this page