NEAR MCP Server
The NEAR MCP Server enables AI agents to interact with the NEAR Protocol blockchain by monitoring smart contract events, processing them with AI, and responding back to contracts.
Watch NEAR Contract Events (
watch_near_event): Start monitoring a specific NEAR smart contract for named events (e.g.,run_agent,price_request) in real-time, with configurable polling frequency (via cron expression). Detected events are automatically processed with AI, and responses are sent back to the contract via a specified method.Stop Watching Events (
stop_watching_near_event): Stop an active event listener for a specific event on a given NEAR contract.List Active Subscriptions (
list_watched_near_events): Retrieve all currently active event watchers, optionally including detailed statistics about each subscription.Flexible Configuration: Customize polling intervals, response method and parameter names, network (mainnet/testnet/betanet), gas limits, and RPC endpoints.
Authentication: Uses NEAR account keys (
ACCOUNT_ID+ACCOUNT_KEY) for signing and submitting transactions back to the blockchain.
Integrates with the NEAR Protocol blockchain to enable AI agents to monitor smart contract events, manage event subscriptions, process blockchain data with AI, and send transactions back to contracts.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@NEAR MCP ServerWatch for 'run_agent' events on contract oracle.near"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
๐ NEAR MCP Server
๐ 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.
Related MCP server: thegraph-mcp
โจ 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 |
| Yes | Your NEAR account ID for authentication | - |
| Yes | Private key for your NEAR account (ed25519: or secp256k1: format) | - |
| No | NEAR network ("mainnet", "testnet", "betanet") |
|
| No | Custom NEAR RPC endpoint | - |
| 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
๐จโ๐ป 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 definitionssrc/services/: Event watcher, auth manager, and business logicsrc/types.ts: TypeScript type definitionssrc/index.ts: Server entry point
๐ AI-Driven Event Processing Workflow
The server enables an "AI in the loop" workflow:
๐ Smart contract transaction triggers an event and pauses execution
๐ค MCP server detects the event and requests AI processing from the client
๐ง AI client processes the event data and provides intelligent response
โฉ๏ธ Server sends AI response back to blockchain via transaction
โ 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
Available Tools
3 toolslist_watched_near_eventsA
List all currently watched NEAR events and their status
| Name | Required | Description | Default |
|---|---|---|---|
| includeStats | No | Include detailed statistics |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations provided, so description carries full burden. It correctly identifies as a read operation without side effects. However, it could mention output details like the structure of returned data or whether pagination applies.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
Single, concise sentence with no wasted words. Front-loaded with the core action and resource.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given the tool's simplicity (1 optional param, no output schema), the description is mostly complete. It could be improved by hinting at the return value format (e.g., list of events with fields).
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema coverage is 100% with one parameter 'includeStats' documented. The description does not add extra meaning beyond the schema, meeting the baseline for full coverage.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the action (list), the resource (currently watched NEAR events), and the included information (status). It distinctly separates from sibling tools stop_watching_near_event and watch_near_event.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description implies usage for viewing watched events but does not provide explicit when-to-use or when-not-to-use guidance compared to siblings. It lacks context on prerequisites or alternatives.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
stop_watching_near_eventC
Stop watching for specific events on a NEAR contract
| Name | Required | Description | Default |
|---|---|---|---|
| contractId | Yes | NEAR contract ID to stop monitoring | |
| eventName | Yes | Name of the event to stop watching |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations are provided, so the description must carry the full burden. It only states the action without describing side effects, idempotency, or prerequisites (e.g., whether a watch must exist).
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is a single sentence, front-loading the core purpose. While brief, it avoids unnecessary words and is efficiently structured.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For a simple tool with two required parameters and no output schema, the description is adequate. However, it could mention the expected result or behavior when no watch exists.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 100% for both parameters. The description adds no additional meaning beyond the schema's parameter descriptions, so the baseline score of 3 is appropriate.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description 'Stop watching for specific events on a NEAR contract' clearly states the tool's purpose with a specific verb and resource. However, it does not differentiate from the sibling tool 'watch_near_event' beyond the opposite action, which could be clearer.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
No guidance on when to use this tool versus alternatives like 'watch_near_event' or 'list_watched_near_events'. The description implies use for stopping a watch but lacks explicit context or prerequisites.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
watch_near_eventC
Start watching for specific events on a NEAR contract and process them with AI responses
| Name | Required | Description | Default |
|---|---|---|---|
| eventName | Yes | Name of the NEAR event to watch for | |
| contractId | Yes | NEAR contract ID to monitor | |
| responseMethodName | No | Contract method to call with the response (defaults to agent_response) | agent_response |
| responseParameterName | No | Name of the parameter to pass to the response method (defaults to response) | response |
| cronExpression | No | Cron expression for polling frequency (default: every 10 seconds) | */10 * * * * * |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations provided, so the description must disclose behavioral traits. It mentions 'process them with AI responses' but does not explain how responses are generated, polling behavior, or persistence. Lacks details on side effects or requirements.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
Single sentence that is clear and front-loaded. Could be slightly more structured, but efficiently conveys the core action.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given 5 parameters, no output schema, and no annotations, the description is incomplete. It does not explain the polling mechanism, lifecycle (e.g., how to stop), or what 'process with AI responses' entails. Sibling tools hint at a monitor/stop pattern.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 100%, so the schema already documents each parameter. The description does not add significant meaning beyond what is in the schema. Baseline 3 is appropriate.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
Clearly states the verb 'start watching' and the resource 'events on a NEAR contract', and adds the purpose 'process them with AI responses'. Differentiates from siblings by specifying the start action, but could be more explicit about the lifecycle.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
No guidance on when to use this tool vs siblings (list_watched_near_events, stop_watching_near_event). Does not provide context about prerequisites or when not to use.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
3 tool updates
v0.1.2- First observed
list_watched_near_events - First observed
stop_watching_near_event - First observed
watch_near_event
TDQS
Scored across 3 tools
Each tool has a clear, distinct purpose: listing, stopping, or starting event watches. No overlap or ambiguity.
All tools use a verb_near_event pattern (list_watched, stop_watching, watch). Minor inconsistency in tense (watched vs watching) but overall predictable.
3 tools is appropriate for a focused event-watching server. Not over- or under-scoped.
Covers the basic lifecycle: create (watch), read (list), delete (stop). Missing update but that is often unnecessary for event filters.
Maintenance
Related MCP Connectors
MCP server connecting AI agents to non-custodial staking data across 130+ networks.
MCP server giving AI agents one-connection access to crypto & DeFi data: DeFi protocol TVL, stableco
MCP server for AI agents to plan, verify, and deploy Cloudflare-native apps.
MCP server connecting AI agents to 100+ apps (Gmail, Slack, Notion, GitHub) via one-click OAuth.
Related MCP Servers
AlicenseCqualityCmaintenanceAn MCP server providing unified access to blockchain operations, bridging, swapping, and crypto trading strategies for AI agents.37179GPL 3.0- AlicenseAqualityDmaintenanceAn MCP server that powers AI agents with indexed blockchain data from The Graph.3MIT
- AlicenseAqualityDmaintenanceAn MCP server enabling AI agents to interact with the 0G blockchain, including balance checks, transaction details, block info, and network statistics.51MIT
- FlicenseAqualityDmaintenanceMCP server enabling AI agents to perform cross-chain token swaps through NEAR's intent-based architecture using the Defuse Protocol, with token discovery, quote retrieval, swap execution, and status tracking.57 npm1-