Build MCP Server: NEAR Smart Contract Interaction
Description
## Overview
Create an MCP server that allows Claude to read smart contract state, call view methods, and help users understand contract interfaces.
## Why This Matters
Developers often need to inspect contracts, test view methods, or understand what a contract does. Claude should be able to help directly with contract exploration.
## Technical Requirements
### Core MCP Tools
```typescript
// 1. get_contract_metadata
// Fetches contract metadata and interface
// Input: { contract_id: string }
// Output: { methods, code_hash, storage_usage }
// 2. call_view_method
// Calls a view (read-only) method on any contract
// Input: { contract_id, method_name, args }
// Output: { result, gas_used }
// 3. decode_transaction
// Decodes and explains a transaction
// Input: { tx_hash: string }
// Output: { actions_explained, method_calls, transfers }
// 4. get_contract_state
// Reads raw contract state (with key patterns)
// Input: { contract_id, key_prefix?: string }
// Output: { state_entries }
// 5. explain_contract_interface
// Uses AI to explain what a contract does
// Input: { contract_id: string }
// Output: { summary, main_functions, example_usage }
```
### Implementation Details
- Support NEAR JSON-RPC for queries
- Parse and present ABIs when available
- Handle both legacy and new contract formats
- Decode base64-encoded arguments/results
## Deliverables
1. **Working MCP server** with all 5 tools
2. **Support for popular contract types** (NEP-141 tokens, NEP-171 NFTs)
3. **Human-readable output formatting**
4. **Documentation with examples**
## Budget: 15 NEAR