TypeScriptADK-TS

MCP NEAR Intents

Execute cross-chain token swaps and bridge operations using NEAR Protocol intent swaps.

Overview

The NEAR Intents MCP server enables your agent to perform cross-chain token swaps and bridging operations via NEAR's intent-based architecture. It abstracts the complexity of multi-chain routing, letting your agent swap tokens across chains by expressing intent rather than specifying exact routes.

Private Key Security

This server uses your NEAR account private key to sign and submit intents on-chain. Keep your private key secure and never commit it to source control.

Getting Started

Install the package:

pnpm add @iqai/mcp-near-intents

Use the server in your agent:

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

const toolset = McpNearIntents({
  env: {
    ACCOUNT_ID: process.env.NEAR_ACCOUNT_ID,
    ACCOUNT_KEY: process.env.NEAR_ACCOUNT_KEY,
  },
});

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

const toolset = new McpToolset({
  name: "Near Intents Swaps MCP Client",
  description: "Client for cross-chain swaps via NEAR Intents",
  transport: {
    mode: "stdio",
    command: "npx",
    args: ["-y", "@iqai/mcp-near-intents"],
    env: {
      ACCOUNT_ID: process.env.NEAR_ACCOUNT_ID,
      ACCOUNT_KEY: process.env.NEAR_ACCOUNT_KEY,
      NEAR_NETWORK_ID: process.env.NEAR_NETWORK_ID,
      NEAR_NODE_URL: process.env.NEAR_NODE_URL,
      PATH: process.env.PATH || "",
    },
  },
});

const tools = await toolset.getTools();
{
  "mcpServers": {
    "near-intents-mcp-server": {
      "command": "npx",
      "args": ["-y", "@iqai/mcp-near-intents"],
      "env": {
        "ACCOUNT_ID": "youraccount.near",
        "ACCOUNT_KEY": "your_near_account_private_key"
      }
    }
  }
}

Environment Variables

VariableRequiredDescription
ACCOUNT_IDYesYour NEAR account ID (e.g. yourname.near)
ACCOUNT_KEYYesYour NEAR account private key
NEAR_NETWORK_IDNoNetwork to connect to (default: mainnet)
NEAR_NODE_URLNoCustom NEAR RPC node URL
NEAR_GAS_LIMITNoGas limit for transactions (default: protocol limit)

Credentials

To get your NEAR credentials:

  1. Create a NEAR account at wallet.near.org or via the NEAR CLI
  2. Export your private key using the NEAR CLI:
    near generate-key yourname.near
    cat ~/.near-credentials/mainnet/yourname.near.json
  3. Use the private_key value as ACCOUNT_KEY

Available Tools

GET_NEAR_SWAP_SIMPLE_QUOTE
originAsset:stringdestinationAsset:stringamount:stringswapType:stringslippageTolerance:numberquoteWaitingTimeMs:number

Description

[STEP 1] Get a simple quote for a NEAR intent swap between different chains and assets. This is a dry run that doesn't require any addresses - perfect for users who want to check swap rates and fees before committing to a swap.

GET_NEAR_SWAP_FULL_QUOTE
swapType:stringoriginAsset:stringdestinationAsset:stringamount:stringrecipient:stringrecipientType:stringrefundTo:stringrefundType:stringslippageTolerance:numberdry:booleandepositType:stringdeadline:stringreferral:stringquoteWaitingTimeMs:number

Description

[STEP 2] Get a full quote with deposit address for a NEAR intent swap. This requires recipient and refund addresses and returns a unique deposit address where users can send their funds to initiate the swap. Use this when users are ready to proceed with the swap after checking the simple quote.

EXECUTE_NEAR_SWAP
txHash:stringdepositAddress:string

Description

[STEP 4] Submit a deposit transaction hash to initiate the swap after sending funds to the deposit address. This notifies the 1Click service that funds have been sent and triggers the swap execution process.

CHECK_NEAR_SWAP_STATUS
depositAddress:string

Description

[STEP 5] Check the current execution status of a NEAR intent swap. Returns the swap state (PENDING_DEPOSIT, PROCESSING, SUCCESS, REFUNDED, FAILED, etc.) along with detailed transaction information.

GET_NEAR_SWAP_TOKENS

No parameters

Description

[DISCOVERY] Get a list of tokens currently supported by the 1Click API for NEAR Intents. Returns token metadata including blockchain, contract address, current USD price, symbol, decimals, and price update timestamp. Use this to help users discover available tokens before requesting quotes.

Integration Example

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

dotenv.config();

async function main() {
  // Initialize McpNearIntents toolset
  const toolset = McpNearIntents({
    env: {
      ACCOUNT_ID: process.env.NEAR_ACCOUNT_ID,
      ACCOUNT_KEY: process.env.NEAR_ACCOUNT_KEY,
    },
  });

  // Get available McpNearIntents tools
  const nearIntentsTools = await toolset.getTools();

  // Create agent with McpNearIntents tools
  const { runner } = await AgentBuilder.create("near_intents_agent")
    .withModel("gemini-2.5-flash")
    .withDescription("A cross-chain swap agent powered by NEAR Intents")
    .withTools(...nearIntentsTools)
    .build();

  const response = await runner.ask(
    "Swap 10 USDC on Ethereum for NEAR tokens using the best available route",
  );

  console.log(response);
}

main().catch(console.error);

Further Resources