NEAR MCP Server
The NEAR MCP Server is an open-source toolkit offers a standardized way for AI applications to integrate with NEAR. It provides 23 tools which enable agents to sign on-chain transactions, manage access keys, exchange tokens, interact with contracts, and more!
MCP stands for Model Context Protocol, an open-source standard for connecting AI agents with external services
Not to be confused with the MPC (Multi-Party Computation) service used by chain signatures
Usage Guide
Since the NEAR MCP Server needs to handle private keys, it is designed to run locally on your machine or on a trusted remote server. Currently there is no hosted version of the NEAR MCP server.
Quickstart
You can either install the MCP server globally and start it, or run it directly using npx
.
- Local
# Install and Run
npm install -g @nearai/near-mcp@latest
near-mcp run
# Without Installing
npx @nearai/near-mcp@latest run
By default the MCP server will run a local input/output server, to start a web server instead add the --port 4000 --remote
flags
npx @nearai/near-mcp@latest run --port 4000 --remote
Local MCP Server
Once the NEAR MPC starts locally it starts what is called a stdio server
. To connect your AI agent to the server you will need to use an MCP client library:
Loading...
In order to use the NEAR MCP server, you will need to manually parse its tool:
Loading...
You can then use the tools as part of your prompt:
Loading...
By default the MCP server will have no accounts loaded, your agent can either import and account using the system_import_account
tool, or you can specify which keystore to load by setting the NEAR_KEYSTORE
environment variable
NEAR_KEYSTORE=/path/to/keystore npx @nearai/near-mcp@latest run
Example Prompts
The Agent using the MCP server will readily have tool to answer prompts like:
- What is the balance of
agency.testnet
? - Add the account
example.testnet
using the private keyed25519:...
- Transfer 0.1 NEAR from
agency.testnet
toexample.testnet
- Call the
ft_transfer
method on theusdc.fakes.testnet
contract - What are the public methods of
social.near
?
Integrate With AI Clients
You can use the NEAR MCP server with any standard MCP client. Here are instructions for some popular clients:
- Cursor IDE
- Claude Code
- Claude Desktop
Go to Settings > MCP Servers, and add a new server with the following details:
- Name: near-mcp
- Command: npx
- Arguments: ["-y", "@nearai/near-mcp@latest", "run"]
- Environment Variables: (optional) Add any necessary environment variables, e.g.,
NEAR_KEYSTORE
.
You can now use the NEAR MCP tools in your prompts.
1. Install Claude Code
npm install -g @anthropic-ai/claude-code
2. Add MCP Server to Claude Code
claude mcp add near-mcp npx @nearai/near-mcp@latest run
3. Start Claude Code and Run Tests
claude
Add to your JSON config:
{
"mcpServers": {
"near-mcp": {
"command": "npx",
"args": ["-y", "@nearai/near-mcp@latest", "run"],
"env": {}
}
}
}
Remote MCP Server
Read these instructions to deploy the MCP server remotely on Phala Cloud.
Contributing
Visit NEAR AI's GitHub repository to create issues or submit pull requests.