TypeScriptADK-TS

MCP Fraxlend

Interact with Fraxlend lending pairs — supply, borrow, repay, and query positions on the Frax ecosystem.

Overview

The Fraxlend MCP server lets your agent interact with Fraxlend lending pairs on the Frax protocol. It supports supplying assets, borrowing, repaying loans, managing collateral, and querying current lending pair data — all requiring a wallet private key for on-chain execution.

Private Key Security

This server signs on-chain transactions using your wallet private key. Never commit your private key to source control. Always load it from a secure environment variable.

Getting Started

Install the package:

pnpm add @iqai/mcp-fraxlend

Use the server in your agent:

import { McpFraxlend } from "@iqai/adk";

const toolset = McpFraxlend({
  env: {
    WALLET_PRIVATE_KEY: process.env.WALLET_PRIVATE_KEY,
  },
});

const tools = await toolset.getTools();
import { McpToolset } from "@iqai/adk";

const toolset = new McpToolset({
  name: "Fraxlend MCP Client",
  description: "Client for Fraxlend lending operations",
  transport: {
    mode: "stdio",
    command: "npx",
    args: ["-y", "@iqai/mcp-fraxlend"],
    env: {
      WALLET_PRIVATE_KEY: process.env.WALLET_PRIVATE_KEY,
      PATH: process.env.PATH || "",
    },
  },
});

const tools = await toolset.getTools();
{
  "mcpServers": {
    "fraxlend-mcp-server": {
      "command": "npx",
      "args": ["-y", "@iqai/mcp-fraxlend"],
      "env": {
        "WALLET_PRIVATE_KEY": "your_wallet_private_key_here"
      }
    }
  }
}

Environment Variables

VariableRequiredDescription
WALLET_PRIVATE_KEYYesPrivate key of the wallet used to sign Fraxlend transactions

Available Tools

FRAXLEND_ADD_COLLATERAL
pairAddress:stringamount:string

Description

Add collateral to a FraxLend position

FRAXLEND_GET_POSITIONS
address:string

Description

Get your positions in FraxLend pools

FRAXLEND_BORROW
pairAddress:stringreceiver:stringcollateralAmount:stringborrowAmount:string

Description

Borrow assets from a FraxLend pool

FRAXLEND_GET_STATS

No parameters

Description

Get lending statistics from FraxLend pools

FRAXLEND_LEND
pairAddress:stringamount:string

Description

Lend assets to a FraxLend pool

FRAXLEND_GET_PAIR_ADDRESS
assetSymbol:stringcollateralSymbol:stringsortByApr:string

Description

Get FraxLend pair addresses and pool information

FRAXLEND_REMOVE_COLLATERAL
pairAddress:stringamount:string

Description

Remove collateral from a FraxLend position

FRAXLEND_REPAY
pairAddress:stringamount:string

Description

Repay borrowed assets to a FraxLend pool

FRAXLEND_WITHDRAW
pairAddress:stringamount:string

Description

Withdraw assets from a FraxLend pool

Integration Example

import { AgentBuilder, McpFraxlend } from "@iqai/adk";
import * as dotenv from "dotenv";

dotenv.config();

async function main() {
  // Initialize McpFraxlend toolset
  const toolset = McpFraxlend({
    env: {
      WALLET_PRIVATE_KEY: process.env.WALLET_PRIVATE_KEY,
    },
  });

  // Get available McpFraxlend tools
  const fraxlendTools = await toolset.getTools();

  // Create agent with McpFraxlend tools
  const { runner } = await AgentBuilder.create("fraxlend_agent")
    .withModel("gemini-2.5-flash")
    .withDescription("A DeFi agent that manages Fraxlend lending positions")
    .withTools(...fraxlendTools)
    .build();

  const response = await runner.ask(
    "Show me all available Fraxlend lending pairs and their current interest rates",
  );

  console.log(response);
}

main().catch(console.error);

Further Resources