Are you an LLM? Read llms.txt for a summary of the docs, or llms-full.txt for the full context.
Skip to content

MCP server for AI agents

@tevm/mcp exposes Tevm's native ZEVM engine and bundled solc compiler over the Model Context Protocol (MCP) stdio transport. An AI coding agent can spin up isolated local or forked chains, compile Solidity, deploy contracts, send transactions, inspect storage, and trace reverts without touching your host environment or external dev nodes.

@tevm/mcp Session Architecture
AI Coding AgentClaude, Cursor,Codex, AntigravityMCP over stdio@tevm/mcp Server14 Zod-validated EVM toolsevm_create_session / forkevm_compile / deploy / callevm_mine / trace_callSessionManager (TTL cleanup)Session A (local · 31337)isolated ZevmEngineSession B (fork · mainnet)isolated ZevmEnginesolc Compilerevm_compile_solidity
Each MCP session handle maps to its own isolated native ZEVM engine. Closing or expiring a session releases its native handle.

Configure your MCP client

Point any MCP-compatible host (Claude Desktop, Claude Code, Cursor, Codex, Antigravity) at the @tevm/mcp stdio CLI:

{
  "mcpServers": {
    "tevm": {
      "command": "npx",
      "args": ["-y", "@tevm/mcp"]
    }
  }
}

Available tools (14)

Session lifecycle

ToolPurpose
evm_create_sessionCreate a fresh isolated local EVM (chainId: 31337, block 0). Returns a UUID handle.
evm_fork_chainFork any HTTP JSON-RPC endpoint at an optional blockNumber and chain preset. Returns a UUID handle.
evm_close_sessionRelease the session's native ZEVM handle immediately.

Compilation & execution

ToolPurpose
evm_compile_solidityCompile one Solidity source file with bundled solc into ABI, creation bytecode, and deployed bytecode.
evm_deploy_contractDeploy bytecode (or compile + deploy Solidity source) into the session txpool. Returns predicted address, gasLimit, and txHash. Mine with evm_mine to commit.
evm_call_contractRead-only contract call (accepts full ABI or a single human-readable signature). Returns decoded output, raw output, and gas estimate.
evm_send_transactionExecute a state-changing function and add it to the txpool. Returns estimated gas and txHash.
evm_mineMine pending transactions and optionally advance block timestamps.

Inspection & debugging

ToolPurpose
evm_get_accountRead balance, nonce, code, and an optional storage slot.
evm_set_accountCheatcode setter for balance, nonce, code, or storage without sending a transaction.
evm_get_blockFetch the latest block or a block by number/hash (optionally with full transactions).
evm_get_transaction_receiptFetch mined receipt status, actual gas used, logs, and deployed contract address.
evm_get_txpoolInspect pending and queued transactions waiting for evm_mine.
evm_trace_callRun debug_traceCall and return a context-window-bounded head/tail opcode trace plus decoded revert errors — even when the call reverts.

Programmatic usage

Embed the session manager and tool executor directly in custom agent harnesses:

import { createSessionManager, executeTool } from '@tevm/mcp'
 
const sessions = createSessionManager()
let handle = ''
 
try {
  const created = (await executeTool('evm_create_session', {}, sessions)) as {
    handle: string
    chainId: number
  }
  handle = created.handle
 
  const compiled = (await executeTool(
    'evm_compile_solidity',
    {
      source: 'pragma solidity ^0.8.20; contract Box { uint256 public x = 7; }',
      contractName: 'Box',
    },
    sessions,
  )) as { abi: unknown[]; bytecode: string }
 
  await executeTool(
    'evm_deploy_contract',
    { session: handle, bytecode: compiled.bytecode },
    sessions,
  )
  await executeTool('evm_mine', { session: handle }, sessions)
} finally {
  if (handle) await sessions.close(handle)
}

Next: Tracing & engine events · HTTP, WebSocket & IPC server