MCP NEAR Agent
Interact with the NEAR Protocol blockchain with AI-driven event processing and account management.
- Package:
@iqai/mcp-near-agent - Provider: IQ AI
Overview
The NEAR Agent MCP server lets your agent interact with the NEAR Protocol blockchain. It supports account management, transaction execution, and AI-driven event processing using your NEAR account credentials.
Getting Started
Install the package:
pnpm add @iqai/mcp-near-agentUse the server in your agent:
import { McpNearAgent } from "@iqai/adk";
const toolset = McpNearAgent({
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 Agent MCP Client",
description: "Client for NEAR Protocol blockchain integration",
transport: {
mode: "stdio",
command: "npx",
args: ["-y", "@iqai/mcp-near-agent"],
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-agent-mcp-server": {
"command": "npx",
"args": ["-y", "@iqai/mcp-near-agent"],
"env": {
"ACCOUNT_ID": "your_near_account_id",
"ACCOUNT_KEY": "your_near_account_private_key"
}
}
}
}Environment Variables
| Variable | Required | Description |
|---|---|---|
ACCOUNT_ID | Yes | Your NEAR account ID (e.g. myaccount.near) |
ACCOUNT_KEY | Yes | Your NEAR account private key |
NEAR_NETWORK_ID | No | Network to connect to (default: mainnet) |
NEAR_NODE_URL | No | Custom NEAR RPC node URL |
NEAR_GAS_LIMIT | No | Gas limit for transactions (default: protocol limit) |
Credentials
To get your NEAR account credentials:
- Create a NEAR account at wallet.near.org or app.mynearwallet.com
- Export your account's private key from the wallet or NEAR CLI
- Your
ACCOUNT_IDis your NEAR account name (e.g.yourname.near)
Available Tools
watch_near_eventeventName:stringcontractId:stringresponseMethodName:stringresponseParameterName:stringcronExpression:string
watch_near_eventeventName:stringcontractId:stringresponseMethodName:stringresponseParameterName:stringcronExpression:string
Description
Start watching for specific events on a NEAR contract and process them with AI responses
stop_watching_near_eventcontractId:stringeventName:string
stop_watching_near_eventcontractId:stringeventName:string
Description
Stop watching for specific events on a NEAR contract
list_watched_near_eventsincludeStats:boolean
list_watched_near_eventsincludeStats:boolean
Description
List all currently watched NEAR events and their status
Integration Example
import { AgentBuilder, McpNearAgent } from "@iqai/adk";
import * as dotenv from "dotenv";
dotenv.config();
async function main() {
// Initialize McpNearAgent toolset
const toolset = McpNearAgent({
env: {
ACCOUNT_ID: process.env.NEAR_ACCOUNT_ID,
ACCOUNT_KEY: process.env.NEAR_ACCOUNT_KEY,
},
});
// Get available McpNearAgent tools
const nearAgentTools = await toolset.getTools();
// Create agent with McpNearAgent tools
const { runner } = await AgentBuilder.create("near_agent")
.withModel("gemini-2.5-flash")
.withDescription(
"An agent that interacts with the NEAR Protocol blockchain",
)
.withTools(...nearAgentTools)
.build();
const response = await runner.ask("What is the balance of my NEAR account?");
console.log(response);
}
main().catch(console.error);