NEAR MCP Server

NEAR MCP Server

The NEAR MCP Server enables AI agents to interact with the NEAR Protocol blockchain, providing smart contract interaction, transaction handling, and event listening with AI-driven processing.

Category
访问服务器

README

🌊 NEAR MCP Server

npm version License: ISC

📖 Overview

The NEAR MCP Server enables AI agents to interact with the NEAR Protocol blockchain. This server provides smart contract interaction, transaction handling, and event listening capabilities with AI-driven processing.

By implementing the Model Context Protocol (MCP), this server allows Large Language Models (LLMs) to monitor blockchain events, process them with AI intelligence, and respond back to smart contracts, bridging the gap between AI and decentralized applications.

✨ Features

  • Event Watching: Monitor NEAR smart contracts for specific events in real-time.
  • AI-Driven Processing: Automatically process blockchain events with AI and send responses back to contracts.
  • Subscription Management: Manage multiple event subscriptions with detailed statistics.
  • Flexible Configuration: Customizable polling intervals, response methods, and network settings.

📦 Installation

🚀 Using npx (Recommended)

To use this server without installing it globally:

npx @iqai/mcp-near

🔧 Build from Source

git clone https://github.com/IQAIcom/mcp-near.git
cd mcp-near
pnpm install
pnpm run build

⚡ Running with an MCP Client

Add the following configuration to your MCP client settings (e.g., claude_desktop_config.json).

📋 Minimal Configuration

{
  "mcpServers": {
    "near": {
      "command": "npx",
      "args": ["-y", "@iqai/mcp-near"],
      "env": {
        "ACCOUNT_ID": "your-account.near",
        "ACCOUNT_KEY": "ed25519:your_private_key_here"
      }
    }
  }
}

⚙️ Advanced Configuration (Local Build)

{
  "mcpServers": {
    "near": {
      "command": "node",
      "args": ["/absolute/path/to/mcp-near/dist/index.js"],
      "env": {
        "ACCOUNT_ID": "your-account.near",
        "ACCOUNT_KEY": "ed25519:your_private_key_here",
        "NEAR_NETWORK_ID": "mainnet",
        "NEAR_NODE_URL": "https://rpc.mainnet.near.org"
      }
    }
  }
}

🔐 Configuration (Environment Variables)

Variable Required Description Default
ACCOUNT_ID Yes Your NEAR account ID for authentication -
ACCOUNT_KEY Yes Private key for your NEAR account (ed25519: or secp256k1: format) -
NEAR_NETWORK_ID No NEAR network ("mainnet", "testnet", "betanet") mainnet
NEAR_NODE_URL No Custom NEAR RPC endpoint -
NEAR_GAS_LIMIT No Gas limit for transactions -

💡 Usage Examples

🔔 Event Watching

  • "Watch for 'run_agent' events on contract oracle.near"
  • "Start monitoring price_request events on my-contract.testnet"
  • "Set up a listener for transfer events with 5-second polling"

📊 Subscription Management

  • "List all my active event subscriptions"
  • "Show statistics for my event watchers"
  • "Stop watching events on contract oracle.near"

🤖 AI-Driven Workflows

  • "Process incoming oracle requests and respond with AI analysis"
  • "Monitor for user queries and provide intelligent responses"

🛠️ MCP Tools

<!-- AUTO-GENERATED TOOLS START -->

list_watched_near_events

List all currently watched NEAR events and their status

Parameter Type Required Description
includeStats boolean No Include detailed statistics

stop_watching_near_event

Stop watching for specific events on a NEAR contract

Parameter Type Required Description
contractId string Yes NEAR contract ID to stop monitoring
eventName string Yes Name of the event to stop watching

watch_near_event

Start watching for specific events on a NEAR contract and process them with AI responses

Parameter Type Required Default Description
eventName string Yes Name of the NEAR event to watch for
contractId string Yes NEAR contract ID to monitor
responseMethodName string No "agent_response" Contract method to call with the response (defaults to agent_response)
responseParameterName string No "response" Name of the parameter to pass to the response method (defaults to response)
cronExpression string No "*/10 * * * * *" Cron expression for polling frequency (default: every 10 seconds)

<!-- AUTO-GENERATED TOOLS END -->

👨‍💻 Development

🏗️ Build Project

pnpm run build

👁️ Development Mode (Watch)

pnpm run watch

✅ Linting & Formatting

pnpm run lint
pnpm run format

🧪 Running Tests

pnpm test

📁 Project Structure

  • src/tools/: Individual tool definitions
  • src/services/: Event watcher, auth manager, and business logic
  • src/types.ts: TypeScript type definitions
  • src/index.ts: Server entry point

🔄 AI-Driven Event Processing Workflow

The server enables an "AI in the loop" workflow:

  1. 🔗 Smart contract transaction triggers an event and pauses execution
  2. 🤖 MCP server detects the event and requests AI processing from the client
  3. 🧠 AI client processes the event data and provides intelligent response
  4. ↩️ Server sends AI response back to blockchain via transaction
  5. ✅ Original smart contract resumes with the AI-provided data

📚 Resources

⚠️ Disclaimer

This project interacts with the NEAR blockchain and requires private keys for transaction signing. Users should exercise caution, secure their credentials, and verify all transactions independently. Blockchain operations involve risk and may incur gas fees.

📄 License

ISC

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选