A Model Context Protocol (MCP) server for Celo blockchain data access and functionality
Project description
Celo MCP Server
A Model Context Protocol (MCP) server for interacting with the Celo blockchain. This server provides comprehensive access to Celo blockchain data, token operations, NFT management, smart contract interactions, and transaction handling.
Installation
- Clone the repository:
git clone <repository-url>
cd celo-mcp
- Install dependencies:
pip install -e .
- Set up environment variables (optional):
export CELO_RPC_URL="https://forno.celo.org" # Default: Celo mainnet
export CELO_TESTNET_RPC_URL="https://alfajores-forno.celo-testnet.org" # Alfajores testnet
Usage
Running the Server
# Run the MCP server
python -m celo_mcp.server
# Or use the CLI entry point
celo-mcp-server
Available Tools
Blockchain Data Operations
-
get_network_status
- Get current network status and connection information
- No parameters required
-
get_block
- Fetch block information by number, hash, or "latest"
- Parameters:
block_identifier,include_transactions(optional)
-
get_transaction
- Get transaction details by hash
- Parameters:
tx_hash
-
get_account
- Get account information including balance and nonce
- Parameters:
address
-
get_latest_blocks
- Get information about recent blocks
- Parameters:
count(optional, default: 10, max: 100)
Token Operations
-
get_token_info
- Get detailed token information (name, symbol, decimals, supply)
- Parameters:
token_address
-
get_token_balance
- Get token balance for a specific address
- Parameters:
token_address,address
-
get_celo_balances
- Get CELO and stable token balances for an address
- Parameters:
address
NFT Operations
-
get_nft_info
- Get NFT information including metadata and collection details
- Parameters:
contract_address,token_id
-
get_nft_balance
- Get NFT balance for an address (supports ERC721 and ERC1155)
- Parameters:
contract_address,address,token_id(optional for ERC1155)
Smart Contract Operations
-
call_contract_function
- Call a read-only contract function
- Parameters:
contract_address,function_name,abi,function_args(optional),from_address(optional)
-
estimate_contract_gas
- Estimate gas for a contract function call
- Parameters:
contract_address,function_name,abi,from_address,function_args(optional),value(optional)
Transaction Operations
-
estimate_transaction
- Estimate gas and cost for a transaction
- Parameters:
to,from_address,value(optional),data(optional)
-
get_gas_fee_data
- Get current gas fee data including EIP-1559 fees
- No parameters required
Architecture
The server is built with a modular architecture:
src/celo_mcp/
├── blockchain_data/ # Core blockchain data access
│ ├── client.py # Celo blockchain client
│ ├── models.py # Data models
│ └── service.py # Blockchain data service
├── tokens/ # Token operations
│ ├── models.py # Token-related models
│ └── service.py # Token service (ERC20, Celo stable tokens)
├── nfts/ # NFT operations
│ ├── models.py # NFT-related models
│ └── service.py # NFT service (ERC721, ERC1155)
├── contracts/ # Smart contract interactions
│ ├── models.py # Contract-related models
│ └── service.py # Contract service
├── transactions/ # Transaction management
│ ├── models.py # Transaction-related models
│ └── service.py # Transaction service
├── server.py # Main MCP server
└── utils.py # Utility functions
Key Features
Token Support
- ERC20 Standard: Full support for ERC20 tokens
- Celo Stable Tokens: Built-in support for cUSD, cEUR, and cREAL
- Balance Queries: Get token balances with proper decimal formatting
- Token Information: Retrieve name, symbol, decimals, and total supply
NFT Support
- Multi-Standard: Support for both ERC721 and ERC1155 standards
- Automatic Detection: Automatically detects NFT standard using ERC165
- Metadata Fetching: Retrieves and parses NFT metadata from URIs
- IPFS Support: Built-in IPFS gateway support for metadata
- Collection Information: Get collection-level information
Smart Contract Interactions
- Function Calls: Call read-only contract functions
- Gas Estimation: Estimate gas costs for contract interactions
- ABI Management: Parse and manage contract ABIs
- Event Handling: Retrieve and decode contract events
- Transaction Building: Build contract transactions
Transaction Management
- Gas Estimation: Accurate gas estimation for transactions
- EIP-1559 Support: Modern fee structure with base fee and priority fee
- Transaction Simulation: Simulate transactions before execution
- Fee Calculation: Dynamic fee calculation based on network conditions
Error Handling
The server includes comprehensive error handling:
- Input validation for all parameters
- Network error handling with retries
- Graceful degradation for optional features
- Detailed error messages for debugging
Caching
Performance optimization through caching:
- Contract ABI caching
- Token metadata caching
- NFT metadata caching with IPFS support
- Network data caching with appropriate TTLs
Security Considerations
- Read-only operations by default
- No private key handling in the server
- Input validation and sanitization
- Rate limiting considerations for external API calls
Development
Running Tests
# Install development dependencies
pip install -e ".[dev]"
# Run tests
pytest
# Run with coverage
pytest --cov=celo_mcp
Code Quality
# Format code
black src/
isort src/
# Lint code
flake8 src/
mypy src/
Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests for new functionality
- Ensure all tests pass
- Submit a pull request
License
This project is licensed under the MIT License - see the LICENSE file for details.
Support
For questions, issues, or contributions, please:
- Check the existing issues on GitHub
- Create a new issue with detailed information
- Join the community discussions
Acknowledgments
- Built on the Model Context Protocol (MCP) framework
- Uses Web3.py for Ethereum/Celo blockchain interactions
- Supports the Celo ecosystem and its stable token infrastructure
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file celo_mcp-0.1.11.tar.gz.
File metadata
- Download URL: celo_mcp-0.1.11.tar.gz
- Upload date:
- Size: 188.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8ae227554c9671fc4bee550176689567e5ebb46a27f48bfcf80e99ca71557b39
|
|
| MD5 |
7b1c7518b188b7fb1fefedd5137005c0
|
|
| BLAKE2b-256 |
6e0c215b69527551bd30d8d50ed2e7caccd29afb44cbf78d9f870f2986329037
|
Provenance
The following attestation bundles were made for celo_mcp-0.1.11.tar.gz:
Publisher:
publish.yml on celo-org/celo-mcp
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
celo_mcp-0.1.11.tar.gz -
Subject digest:
8ae227554c9671fc4bee550176689567e5ebb46a27f48bfcf80e99ca71557b39 - Sigstore transparency entry: 220192020
- Sigstore integration time:
-
Permalink:
celo-org/celo-mcp@2a4240af1a8b06268c0f0ad4d33ce44d98b8e7f5 -
Branch / Tag:
refs/tags/v0.1.11 - Owner: https://github.com/celo-org
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@2a4240af1a8b06268c0f0ad4d33ce44d98b8e7f5 -
Trigger Event:
push
-
Statement type:
File details
Details for the file celo_mcp-0.1.11-py3-none-any.whl.
File metadata
- Download URL: celo_mcp-0.1.11-py3-none-any.whl
- Upload date:
- Size: 36.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
088f962a4f6fa13fc14c905da5723c95b8f73ca889b54cf17f4638ccc06df6b1
|
|
| MD5 |
59ea2a36da1bd03bfa60706e4995ab6b
|
|
| BLAKE2b-256 |
bdd5271e4c91ff7f96ea412fe657e066232ae6c10053604c8e0a8446e12bcff5
|
Provenance
The following attestation bundles were made for celo_mcp-0.1.11-py3-none-any.whl:
Publisher:
publish.yml on celo-org/celo-mcp
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
celo_mcp-0.1.11-py3-none-any.whl -
Subject digest:
088f962a4f6fa13fc14c905da5723c95b8f73ca889b54cf17f4638ccc06df6b1 - Sigstore transparency entry: 220192022
- Sigstore integration time:
-
Permalink:
celo-org/celo-mcp@2a4240af1a8b06268c0f0ad4d33ce44d98b8e7f5 -
Branch / Tag:
refs/tags/v0.1.11 - Owner: https://github.com/celo-org
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@2a4240af1a8b06268c0f0ad4d33ce44d98b8e7f5 -
Trigger Event:
push
-
Statement type: