Core Concepts¶
This section explains the fundamental concepts you need to understand to work effectively with abi-to-mcp.
Overview¶
abi-to-mcp bridges the gap between smart contracts and AI assistants. To do this effectively, it must handle several key challenges:
- Type Translation - Converting Solidity types to JSON Schema and Python
- Operation Classification - Distinguishing read vs write operations
- Event Handling - Exposing historical data through resources
- Safety - Preventing accidental or unauthorized transactions
Key Concepts¶
-
Type Mapping
How Solidity types are converted to JSON Schema for validation and Python for code generation.
-
Tool Types
The difference between read, write, and payable tools and how they're handled.
-
Events & Resources
How contract events become queryable MCP resources.
-
Safety Features
Built-in protections for safe smart contract interaction.
-
Security Scanner
Detect rug pulls, honeypots, and 50+ risks before connecting your AI agent.
The MCP Protocol¶
The Model Context Protocol (MCP) defines how AI assistants connect to external tools. Key concepts:
Tools¶
Tools are functions the AI can call. In abi-to-mcp, each contract function becomes a tool:
For example:
Resources¶
Resources are data sources the AI can query. In abi-to-mcp, events become resources:
For example:
Schemas¶
Both tools and resources have JSON Schemas that define their parameters and return types. This allows:
- Validation - Ensure inputs are correct before calling
- Documentation - AI understands what parameters mean
- Type Safety - Catch errors early
The Generation Pipeline¶
graph LR
A[ABI JSON] --> B[Parser]
B --> C[Type Mapper]
C --> D[Tool Generator]
C --> E[Resource Generator]
D --> F[MCP Server]
E --> F
style A fill:#627EEA,color:#fff
style F fill:#4CAF50,color:#fff
- Parser - Reads ABI JSON and creates structured objects
- Type Mapper - Converts Solidity types to JSON Schema
- Tool Generator - Creates MCP tool definitions
- Resource Generator - Creates MCP resource definitions
- MCP Server - Complete runnable server
Understanding ABIs¶
An ABI (Application Binary Interface) is a JSON description of a smart contract's interface:
[
{
"type": "function",
"name": "balanceOf",
"inputs": [{"name": "account", "type": "address"}],
"outputs": [{"name": "", "type": "uint256"}],
"stateMutability": "view"
},
{
"type": "event",
"name": "Transfer",
"inputs": [
{"name": "from", "type": "address", "indexed": true},
{"name": "to", "type": "address", "indexed": true},
{"name": "value", "type": "uint256", "indexed": false}
]
}
]
abi-to-mcp reads this and generates corresponding MCP tools and resources.
Next Steps¶
Start with Type Mapping to understand how types are converted.