near-contract
Enables interaction with NEAR smart contracts: read contract metadata, call view methods, decode transactions, and explore contract interfaces on mainnet or testnet.
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-contract What's the balance of alice.near on wrap.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.
MCP Server: NEAR Smart Contract Interaction
An MCP (Model Context Protocol) server that allows Claude to read NEAR smart contract state, call view methods, decode transactions, and understand contract interfaces.
Features
Contract Metadata: Fetch code hash, storage usage, and detect implemented standards (NEP-141, NEP-171, etc.)
View Method Calls: Call any read-only method on any NEAR contract
Transaction Decoding: Decode and explain transaction actions, gas usage, and outcomes
State Reading: Read raw contract state with optional key prefix filtering
Interface Explanation: AI-friendly explanation of contract purpose and functions
Related MCP server: MCP Crypto Wallet EVM
Installation
npm install @near-mcp/contract-interactionOr run directly:
npx @near-mcp/contract-interactionClaude Desktop Configuration
Add to your Claude Desktop config (~/Library/Application Support/Claude/claude_desktop_config.json on macOS):
{
"mcpServers": {
"near-contract": {
"command": "npx",
"args": ["@near-mcp/contract-interaction"]
}
}
}Available Tools
1. get_contract_metadata
Fetches contract metadata including code hash, storage usage, and detected methods/standards.
Input:
{
"contract_id": "wrap.near",
"network": "mainnet"
}Output:
{
"contract_id": "wrap.near",
"network": "mainnet",
"code_hash": "ABC123...",
"storage_usage_bytes": 12345,
"storage_usage_near": "0.12345 NEAR",
"detected_methods": ["ft_transfer", "ft_balance_of", "ft_metadata"],
"detected_standards": ["NEP-141 (Fungible Token Standard)"]
}2. call_view_method
Calls a view (read-only) method on any NEAR smart contract.
Input:
{
"contract_id": "wrap.near",
"method_name": "ft_balance_of",
"args": { "account_id": "example.near" },
"network": "mainnet"
}Output:
{
"contract_id": "wrap.near",
"method": "ft_balance_of",
"args": { "account_id": "example.near" },
"result": "1000000000000000000000000",
"blockHeight": 123456789,
"blockHash": "ABC...",
"logs": []
}3. decode_transaction
Decodes and explains a NEAR transaction, including all actions and their effects.
Input:
{
"tx_hash": "ABC123...",
"sender_id": "example.near",
"network": "mainnet"
}Output:
{
"hash": "ABC123...",
"signerId": "example.near",
"receiverId": "wrap.near",
"actions": [
{
"type": "FunctionCall",
"description": "Calls method \"ft_transfer\" with 0.0100 NEAR attached",
"details": {
"method_name": "ft_transfer",
"args_decoded": { "receiver_id": "bob.near", "amount": "1000000" },
"gas": 30000000000000,
"deposit": "1"
}
}
],
"outcome": {
"status": "Success",
"gasUsed": "2.5432 TGas",
"tokensBurned": "0.000254 NEAR"
}
}4. get_contract_state
Reads raw contract state entries, optionally filtered by key prefix.
Input:
{
"contract_id": "example.near",
"key_prefix": "",
"network": "mainnet"
}Output:
{
"contract_id": "example.near",
"network": "mainnet",
"total_entries": 42,
"state_entries": [
{
"key": "base64...",
"keyDecoded": "STATE",
"value": "base64...",
"valueDecoded": "{\"owner\": \"alice.near\"}"
}
],
"truncated": false
}5. explain_contract_interface
Analyzes a contract and provides a human-readable explanation of its purpose and main functions.
Input:
{
"contract_id": "wrap.near",
"network": "mainnet"
}Output:
{
"contract_id": "wrap.near",
"network": "mainnet",
"summary": "Wrapped NEAR (wNEAR) - A fungible token contract implementing the NEP-141 standard...",
"detected_standards": ["NEP-141 (Fungible Token Standard)", "NEP-145 (Storage Management)"],
"main_functions": {
"token_operations": ["ft_transfer", "ft_transfer_call"],
"queries": ["ft_balance_of", "ft_total_supply", "ft_metadata"],
"storage": ["storage_deposit", "storage_withdraw"]
},
"token_info": {
"name": "Wrapped NEAR",
"symbol": "wNEAR",
"decimals": 24
},
"example_usage": [
"Check token balance: call_view_method(\"wrap.near\", \"ft_balance_of\", {\"account_id\": \"user.near\"})",
"Get token info: call_view_method(\"wrap.near\", \"ft_metadata\", {})"
]
}Supported Contract Standards
The server automatically detects contracts implementing:
NEP-141: Fungible Token Standard
NEP-171: Non-Fungible Token Standard
NEP-145: Storage Management
NEP-148: Fungible Token Metadata
Networks
Both mainnet and testnet are supported. Default is mainnet.
{ "network": "testnet" }Development
# Install dependencies
npm install
# Build
npm run build
# Run locally
npm startLicense
MIT
Available Tools
5 toolscall_view_methodA
Calls a view (read-only) method on any NEAR smart contract
Inputs: contract_id (required), method_name (required), args, network.
decode_transactionA
Decodes and explains a NEAR transaction, including all actions and their effects
Inputs: tx_hash (required), sender_id (required), network.
explain_contract_interfaceB
Analyzes a contract and provides a human-readable explanation of its purpose and main functions
Inputs: contract_id (required), network.
get_contract_metadataB
Fetches contract metadata including code hash, storage usage, and detected methods/standards
Inputs: contract_id (required), network.
get_contract_stateA
Reads raw contract state entries, optionally filtered by key prefix
Inputs: contract_id (required), network, key_prefix.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 5 tools
Tools are mostly distinct: metadata, state, view methods, interface explanation, and transaction decoding each target a different aspect. The slight overlap between get_contract_metadata and explain_contract_interface (both reveal methods) is mitigated by metadata being raw and explain being high-level.
All tool names follow a consistent verb_noun pattern in snake_case: get_contract_metadata, call_view_method, decode_transaction, get_contract_state, explain_contract_interface. No mixed conventions or ambiguous verbs.
Five tools is well-scoped for a contract inspection/analysis server. Each tool serves a clear purpose without redundancy, and the count is within the ideal range for a focused MCP server.
The tool surface covers the core needs for understanding NEAR contracts: metadata, raw state, view methods, interface explanation, and transaction decoding. A minor gap is the lack of a tool to simulate or estimate gas for view calls, but the current set is coherent and functional.
Maintenance
Related MCP Connectors
Resolve any EVM contract ABI (even unverified, via decompilation), read, simulate, prepare txs.
Read-only smart-contract security intelligence for autonomous agents.
Work with your DealSharp negotiation projects, documents and tools from Claude.
NFTs on NEAR that each control a native Bitcoin address: buy, lend, borrow, inherit, with caps
Related MCP Servers
- AlicenseBqualityDmaintenanceEnables Claude to interact with Ethereum nodes, allowing users to check ENS token balances, view smart contract code, and decode transactions through natural language.51MIT
- AlicenseBqualityDmaintenanceProvides Claude with access to Ethereum and EVM-compatible blockchain operations, enabling wallet management, transaction handling, contract interactions, and blockchain queries through natural language.35136 npm10MIT
- AlicenseNot gradedqualityDmaintenanceEnables Claude to access, analyze, and visualize Solana blockchain data through natural language conversations.18MIT
- AlicenseNot gradedqualityDmaintenanceEnables Claude Desktop and MCP clients to interact with NEAR blockchain accounts for balance checks, account info, access keys, transaction status, and sending signed transactions.MIT