{
  "markdown": "# Haiku MCP Server\n\nAn MCP (Model Context Protocol) server that enables AI agents to execute blockchain transactions via the [Haiku API](https://docs.haiku.trade).\n\n[![npm version](https://badge.fury.io/js/haiku-mcp-server.svg)](https://www.npmjs.com/package/haiku-mcp-server)\n[![GitHub](https://img.shields.io/badge/GitHub-Haiku--Trading%2Fhaiku--mcp--server-blue)](https://github.com/Haiku-Trading/haiku-mcp-server)\n\n## Features\n\n- **Token Discovery**: List supported tokens and DeFi assets across 21 blockchain networks\n- **Balance Checking**: Get wallet balances across all supported chains\n- **Trading Quotes**: Get quotes for swaps and portfolio rebalancing\n- **Transaction Building**: Convert quotes to unsigned EVM transactions\n- **Wallet Integration**: Extract EIP-712 payloads for external wallet signing (Coinbase, AgentKit, Safe, etc.)\n- **Self-Contained Execution**: Optional end-to-end execution with WALLET_PRIVATE_KEY env var\n- **Yield Discovery**: Find the highest-yielding DeFi opportunities across protocols and chains, filtered by APY, TVL, and category\n- **Portfolio Analysis**: Analyze a wallet's holdings and surface context-specific yield opportunities based on what it actually holds\n\n## Installation\n\n```bash\nnpm install haiku-mcp-server\n```\n\nOr run directly with npx:\n\n```bash\nnpx haiku-mcp-server\n```\n\n## Configuration\n\n### Environment Variables\n\n| Variable | Required | Description |\n|----------|----------|-------------|\n| `HAIKU_API_KEY` | No | Your Haiku API key for higher rate limits. Contact contact@haiku.trade to request one. |\n| `HAIKU_BASE_URL` | No | API base URL. Defaults to `https://api.haiku.trade/v1` |\n| `WALLET_PRIVATE_KEY` | No | Private key (0x hex) for self-contained execution via `haiku_execute`. |\n| `RPC_URL_{chainId}` | No | Override RPC URL for a specific chain (e.g., `RPC_URL_42161` for Arbitrum). |\n\n> **Note:** The API works without a key, but providing one unlocks higher rate limits for production use.\n\n### Claude Desktop Configuration\n\nAdd to your `claude_desktop_config.json`:\n\n```json\n{\n  \"mcpServers\": {\n    \"haiku\": {\n      \"command\": \"npx\",\n      \"args\": [\"haiku-mcp-server\"]\n    }\n  }\n}\n```\n\nWith API key for higher rate limits:\n\n```json\n{\n  \"mcpServers\": {\n    \"haiku\": {\n      \"command\": \"npx\",\n      \"args\": [\"haiku-mcp-server\"],\n      \"env\": {\n        \"HAIKU_API_KEY\": \"your-api-key-here\"\n      }\n    }\n  }\n}\n```\n\n## Available Tools\n\n### `haiku_get_tokens`\n\nGet supported tokens and DeFi assets for trading.\n\n**Parameters:**\n- `network` (optional): Filter by chain ID (e.g., 42161 for Arbitrum)\n- `category` (optional): Filter by token category:\n  - `token` - Vanilla tokens (ETH, USDC, etc.)\n  - `collateral` - eg. Aave aTokens (deposited collateral)\n  - `varDebt` - eg. Aave variable debt tokens\n  - `vault` - eg. Yearn/Morpho yield vaults\n  - `weightedLiquidity` - eg. Balancer LP tokens\n  - `concentratedLiquidity` - eg. Uniswap V3 LP positions\n\n**Example:**\n```json\n{\n  \"network\": 42161,\n  \"category\": \"token\"\n}\n```\n\n### `haiku_get_balances`\n\nGet token balances for a wallet address across all chains.\n\n**Parameters:**\n- `walletAddress` (optional): Wallet address or ENS name. Required when `WALLET_PRIVATE_KEY` is not set; omit to auto-derive from `WALLET_PRIVATE_KEY` when it is set.\n\n**Example:**\n```json\n{\n  \"walletAddress\": \"0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045\"\n}\n```\nOmit `walletAddress` when `WALLET_PRIVATE_KEY` is set to use the derived address.\n\n### `haiku_get_quote`\n\nGet a quote for a token swap or portfolio rebalance.\n\n> **Note:** Quotes are valid for 5 minutes, but execute as quickly as possible after quoting — the longer you wait, the more likely prices have moved and the transaction will fail on-chain.\n\n**Parameters:**\n- `inputPositions` (required): Map of token IID to amount to spend\n- `targetWeights` (required): Map of output token IID to weight (must sum to 1)\n- `slippage` (optional): Max slippage as decimal (default: 0.003)\n- `receiver`: Receiving wallet address. **Required when `WALLET_PRIVATE_KEY` is not set** — must be provided explicitly. When `WALLET_PRIVATE_KEY` is set, auto-derived if omitted. When `WALLET_PRIVATE_KEY` is not set (Path B), you must pass `receiver` explicitly.\n\n**Example:**\n```json\n{\n  \"inputPositions\": {\n    \"arb:0x82aF49447D8a07e3bd95BD0d56f35241523fBab1\": \"1.0\"\n  },\n  \"targetWeights\": {\n    \"arb:0xaf88d065e77c8cC2239327C5EDb3A432268e5831\": 0.5,\n    \"arb:0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9\": 0.5\n  },\n  \"slippage\": 0.005\n}\n```\nExample above omits `receiver` (valid when `WALLET_PRIVATE_KEY` is set). For Path B, include `\"receiver\": \"0x...\"`.\n\n### `haiku_prepare_signatures`\n\nExtract and normalize EIP-712 signing payloads from a quote for external wallet signing (Path B only). When using `quoteId`, the quote must have been obtained in the same session.\n\nUse this when a wallet MCP handles signing (Coinbase Payments MCP, wallet-agent, AgentKit, Safe, etc.). Returns standardized typed data that any wallet's `signTypedData` can consume, plus step-by-step instructions.\n\n**Parameters:**\n- `quoteId` (preferred): Quote ID from `haiku_get_quote` — server resolves the full quote from session cache. QuoteId only works when the quote was returned by `haiku_get_quote` in the same MCP session; otherwise use `quoteResponse`.\n- `quoteResponse` (fallback): Full response object from `haiku_get_quote`, if quoteId is unavailable\n\n**Returns:**\n- `requiresPermit2`: Whether Permit2 signature is needed\n- `permit2`: EIP-712 payload to pass to `signTypedData` (if required)\n- `requiresBridgeSignature`: Whether bridge signature is needed\n- `bridgeIntent`: EIP-712 payload to pass to `signTypedData` (if required)\n- `sourceChainId`: Chain ID for the transaction\n- `instructions`: Step-by-step instructions for completing the flow\n\n**Example:**\n```json\n{\n  \"quoteId\": \"abc123...\"\n}\n```\n\n### `haiku_discover_yields`\n\nDiscover yield-bearing opportunities across DeFi protocols, ranked by APY or TVL.\n\nUse this to answer questions like \"best lending yields on Arbitrum\", \"highest APY vaults\nwith at least $1M TVL\", or \"what can I do with USDC on Base\". The `iid` field in results\ncan be used directly as a key in the `targetWeights` object in `haiku_get_quote`.\n\n**Parameters:**\n- `network` (optional): Filter by chain ID (e.g., 42161 for Arbitrum)\n- `category` (optional): `lending` (Aave collateral), `vault` (Yearn/Morpho), `lp` (Balancer/Uniswap), `all` (default)\n- `minApy` (optional): Minimum APY as a percentage (e.g., `5` means ≥5% APY)\n- `minTvl` (optional): Minimum TVL in USD (e.g., `1000000` means ≥$1M). Filters to established mainstream vaults.\n- `sortBy` (optional): `apy` (default) or `tvl`, descending\n- `limit` (optional): Max results (default 20)\n\n**Example:**\n```json\n{\n  \"network\": 42161,\n  \"category\": \"lending\",\n  \"minTvl\": 1000000,\n  \"sortBy\": \"apy\",\n  \"limit\": 10\n}\n```\n\n### `haiku_analyze_portfolio`\n\nAnalyze a wallet's DeFi portfolio and surface relevant yield opportunities.\n\nReturns current positions enriched with available APY options, collateral health factors,\nand context-specific opportunities based on what the wallet actually holds. Pair with\n`haiku_discover_yields` for broader market context, then use `haiku_get_quote` to execute.\n\n**Parameters:**\n- `walletAddress` (required): Wallet address (0x...) to analyze\n\n**Example:**\n```json\n{\n  \"walletAddress\": \"0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045\"\n}\n```\n\n### `haiku_execute`\n\nExecute a quote. Two distinct paths depending on who holds the private key.\n\n**Path A — Self-contained** (`WALLET_PRIVATE_KEY` set in env): Haiku signs Permit2/bridge payloads internally and broadcasts. Returns a tx hash.\n\n**Parameters:**\n- `quoteId` (required): Quote ID from `haiku_get_quote`\n- `sourceChainId` (recommended): Chain ID from the quote response. Omit only if the quote was obtained in the same session — the server can recover from cache.\n- `permit2SigningPayload` (optional): Pass through from `haiku_get_quote` if present\n- `bridgeSigningPayload` (optional): Pass through from `haiku_get_quote` if present (cross-chain only)\n- `approvals` (optional): Pass through from `haiku_get_quote` if present\n\n**Example:**\n```json\n{\n  \"quoteId\": \"abc123...\",\n  \"sourceChainId\": 42161,\n  \"permit2SigningPayload\": { /* from haiku_get_quote, if present */ },\n  \"approvals\": [ /* from haiku_get_quote, if present */ ]\n}\n```\n\n---\n\n**Path B — External wallet** (no `WALLET_PRIVATE_KEY`, using a wallet MCP): You sign and broadcast. `broadcast: false` is **required** — without `WALLET_PRIVATE_KEY`, haiku cannot sign or send the final EVM transaction. If you call `haiku_execute` with `broadcast: true` and no `WALLET_PRIVATE_KEY`, the server returns an error directing you to set `broadcast: false` and broadcast the returned transaction via your wallet MCP.\n\nBefore calling `haiku_execute`:\n1. If `approvals` is non-empty in the quote: broadcast each approval as a transaction `{ to, data, value }` (include `value` when present, e.g. for native token) via your wallet MCP and wait for confirmation.\n2. If signatures are required: call `haiku_prepare_signatures` with the quoteId, sign the returned EIP-712 payloads via your wallet MCP, then pass the signatures here.\n\n**Parameters:**\n- `quoteId` (required): Quote ID from `haiku_get_quote`\n- `sourceChainId` (recommended): Chain ID from the quote response. Omit only if the quote was obtained in the same session — the server can recover from cache.\n- `broadcast` (required): Must be `false` — haiku returns the unsigned tx for you to broadcast\n- `permit2Signature` (optional): Signature from signing the Permit2 payload via your wallet MCP\n- `userSignature` (optional): Signature from signing the bridge payload via your wallet MCP (cross-chain only)\n\n**Example:**\n```json\n{\n  \"quoteId\": \"abc123...\",\n  \"sourceChainId\": 42161,\n  \"broadcast\": false,\n  \"permit2Signature\": \"0x...\"\n}\n```\nReturns `{ transaction: { to, data, value, chainId } }` — pass `transaction` to your wallet MCP's `sendTransaction`.\n\n## Token IID Format\n\nTokens are identified using the IID format: `chainSlug:tokenAddress`\n\nExamples:\n- `arb:0x82aF49447D8a07e3bd95BD0d56f35241523fBab1` - WETH on Arbitrum\n- `arb:0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee` - Native ETH on Arbitrum\n- `base:0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913` - USDC on Base\n\n## Supported Chains\n\n| Chain | Chain ID | Slug |\n|-------|----------|------|\n| Arbitrum | 42161 | arb |\n| Avalanche | 43114 | avax |\n| Base | 8453 | base |\n| Berachain | 80094 | bera |\n| BNB Smart Chain | 56 | bsc |\n| Bob | 60808 | bob |\n| Ethereum | 1 | eth |\n| Gnosis | 100 | gnosis |\n| Hyperliquid | 999 | hype |\n| Katana | 747474 | katana |\n| Lisk | 1135 | lisk |\n| MegaETH | 4326 | megaeth |\n| Monad | 143 | monad |\n| Optimism | 10 | opt |\n| Plasma | 9745 | plasma |\n| Polygon | 137 | poly |\n| Scroll | 534352 | scroll |\n| Sei | 1329 | sei |\n| Sonic | 146 | sonic |\n| Unichain | 130 | uni |\n| World Chain | 480 | worldchain |\n| ApeChain | 33139 | ape |\n\n## Workflow Examples\n\n### Path A: Self-Contained Swap (WALLET_PRIVATE_KEY set)\n\nHaiku handles all signing and broadcasting. Returns a tx hash.\n\n```\n1. haiku_get_quote(inputPositions, targetWeights) → returns quoteId, sourceChainId, permit2SigningPayload?, bridgeSigningPayload?, approvals\n2. haiku_execute(quoteId, sourceChainId, permit2SigningPayload?, bridgeSigningPayload?, approvals)\n   → Haiku broadcasts approvals, signs Permit2/bridge internally, broadcasts swap, returns tx hash\n```\n\n### Path B: External Wallet (wallet MCP handles signing + broadcasting)\n\nUse when WALLET_PRIVATE_KEY is not set and a separate wallet MCP holds the keys.\n\n**Simple swap (no Permit2 or bridge signatures needed, e.g. native ETH input):**\n```\n1. haiku_get_quote(inputPositions, targetWeights, receiver) → returns quoteId, sourceChainId, approvals\n2. For each item in approvals: broadcast as transaction { to, data, value } (include value when present) via wallet MCP and wait for confirmation\n3. haiku_execute(quoteId, sourceChainId, broadcast: false)\n   → returns { transaction: { to, data, value, chainId } }\n4. Broadcast transaction via wallet MCP\n```\n\n**With Permit2 or bridge signatures (e.g. ERC-20 input or cross-chain swap):**\n```\n1. haiku_get_quote(inputPositions, targetWeights, receiver) → returns quoteId, sourceChainId, approvals, permit2SigningPayload?, bridgeSigningPayload?\n2. For each item in approvals: broadcast as transaction { to, data, value } (include value when present) via wallet MCP and wait for confirmation\n3. haiku_prepare_signatures(quoteId) → returns normalized EIP-712 payloads + step-by-step instructions\n4. Sign payloads via wallet MCP (e.g. coinbase_sign_typed_data) → get permit2Signature?, userSignature?\n5. haiku_execute(quoteId, sourceChainId, permit2Signature?, userSignature?, broadcast: false)\n   → returns { transaction: { to, data, value, chainId } }\n6. Broadcast transaction via wallet MCP (e.g. coinbase_send_transaction)\n```\n\n### Yield Discovery\n\n```\n1. haiku_discover_yields with category/network/minTvl filters → find opportunities, note iid\n2. haiku_get_quote with the chosen iid as a key in targetWeights\n3. Execute via Path A or Path B above\n```\n\n### Portfolio Analysis & Optimization\n\n```\n1. haiku_analyze_portfolio with wallet address → review positions and opportunities\n2. Optionally haiku_discover_yields for broader market context\n3. haiku_get_quote to rebalance into higher-yielding positions\n4. Execute via Path A or Path B above\n```\n\n## Transaction Signing\n\nTwo modes depending on your setup:\n\n**Self-contained** (`WALLET_PRIVATE_KEY` set): `haiku_execute` signs everything internally and broadcasts. Returns a tx hash. No external signing needed.\n\n**External wallet** (no `WALLET_PRIVATE_KEY`): Use `haiku_execute` with `broadcast: false` (required — haiku cannot sign or broadcast without the private key). If you call `haiku_execute` with `broadcast: true` and no `WALLET_PRIVATE_KEY`, the server returns an error directing you to set `broadcast: false` and broadcast the returned transaction via your wallet MCP. Returns `{ transaction: { to, data, value, chainId } }` for your wallet MCP to broadcast. If Permit2 or bridge signatures are required, call `haiku_prepare_signatures` first. If approvals are present in the quote, broadcast each approval `{ to, data, value }` (include `value` when present, e.g. for native token) via your wallet MCP before calling `haiku_execute`.\n\nThe external wallet design allows agents to use any signing infrastructure (wallet MCPs, hardware wallets, custodial services, MPC, etc.).\n\n## Cross-Chain Bridge Signatures\n\nFor cross-chain swaps, the quote may return `isComplexBridge: true`, indicating a bridge intent signature is required in addition to (or instead of) Permit2.\n\n**Self-contained (Path A):** Pass `bridgeSigningPayload` from the quote to `haiku_execute` — it handles the bridge signature internally.\n\n**External wallet (Path B):** Call `haiku_prepare_signatures` with the quoteId — it returns a normalized `bridgeIntent` EIP-712 payload. Sign it via your wallet MCP and pass the result as `userSignature` to `haiku_execute`.\n\n## Transport Modes\n\n### Stdio (default)\n\nStandard MCP stdio transport — used by Claude Desktop, Cursor, etc.\n\n```bash\nnpx haiku-mcp-server\n```\n\n### Streamable HTTP\n\nHTTP transport for remote hosting, Smithery, and web-based MCP clients.\n\n```bash\nnpx haiku-mcp-server --http\nnpx haiku-mcp-server --http --port=8080\n```\n\nEndpoints:\n- `POST /mcp` — MCP Streamable HTTP endpoint\n- `GET /health` — Health check\n\n## Development\n\n```bash\n# Install dependencies\nnpm install\n\n# Build\nnpm run build\n\n# Run locally (stdio, works without API key)\nnpm start\n\n# Run locally (HTTP)\nnpm run start:http\n\n# Run with API key for higher rate limits\nHAIKU_API_KEY=your-key npm start\n```\n\n## License\n\nMIT\n",
  "bytes": 15756,
  "sha": "369c7026629e5ceabc73afbb86b615ce9bc7a4eef52bebb578da5517a568d7b4",
  "repo_slug": "haiku-trading/haiku-mcp-server",
  "fonte": "repo",
  "truncated": false,
  "api": "https://agentalog.com/api/listings/mcp_io_github_haiku_trading_haiku_mcp_server_38d40214/readme"
}