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
Visit Server

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

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured