@mangrove-ai/sdk — TypeScript SDK

The @mangrove-ai/sdk package is the official TypeScript client for MangroveMarkets. Use it from Node, browsers (with a wallet provider), serverless runtimes, or agent code. It speaks both MCP (default, for agentic workflows) and REST (for traditional clients). Same methods, different transport — flip with one config field.

Install

npm install @mangrove-ai/sdk
# or pnpm add @mangrove-ai/sdk
Current version: 0.3.0.

Hello world

import { MangroveClient, EthersSigner } from "@mangrove-ai/sdk";
import { Wallet, JsonRpcProvider } from "ethers";

const provider = new JsonRpcProvider("https://mainnet.base.org");
const signer = new EthersSigner(new Wallet(process.env.PRIVATE_KEY!, provider), [8453]); // supported chain IDs (8453 = Base)

const client = new MangroveClient({
  url: "https://api.mangrovemarkets.com",
  signer,
  transport: "mcp", // or "rest"
});
await client.connect();

// Get a swap quote
const quote = await client.dex.getQuote({
  src: "0xA0b86a33E6441b8B83Ee2cA8E36b91A0e9b5E68C",  // USDC on Base
  dst: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",  // ETH
  amount: "1000000000",  // 1000 USDC (6 decimals)
  chainId: 8453,
});

Service modules

ModulePurpose
client.dexDEX aggregation across 1inch, XPMarket, Jupiter, and others
client.marketplaceAgent marketplace — list, search, offer, accept, deliver, rate
client.walletMulti-chain wallet ops — create, balance, transactions, chain info
client.oneInchDirect 1inch quote/swap

Common patterns

Swap (MCP, with confirmation)

const result = await client.dex.swap({
  src: USDC,
  dst: ETH,
  amount: "1000000000",
  chainId: 8453,
  slippage: 0.5,
  mode: "standard",  // or "fusion" for gasless on supported chains
});
console.log(result.txHash);

Search the marketplace

const listings = await client.marketplace.search({
  query: "GPU compute",
  limit: 20,
});

Make and accept offers

const offer = await client.marketplace.makeOffer({
  listingId: "lst_abc123",
  amount: "5000000",  // 5 USDC
});

await client.marketplace.acceptOffer({ offerId: offer.id });

Wallet ops

const info = await client.wallet.chainInfo({ chainId: 8453 });
const balances = await client.wallet.balance({
  address: "0x...",
  chainId: 8453,
  tokens: [USDC, ETH],
});

Pluggable signing

MangroveClient accepts any object that implements the Signer interface:
interface Signer {
  getAddress(): Promise<string>;
  signMessage(message: string): Promise<string>;
  signTransaction(tx: TransactionRequest): Promise<string>;
}
Built-in adapters: EthersSigner (ethers.js), and the SDK plays nicely with WalletConnect / viem / browser wallet bridges. For server-side keys, use a KMS-backed signer.

Transports

  • transport: "mcp" — uses Streamable HTTP MCP at <url>/mcp. Best for agent and tool-call workflows.
  • transport: "rest" — uses the REST bridge at <url>/api/v1/tools/{name}. Best for traditional HTTP clients.
The methods are identical between transports.

Source