Labsco
Suryansh-23 logo

Hyperlane MCP Server

โ˜… 6

from Suryansh-23

Integrates with the Hyperlane protocol for cross-chain messaging and smart contract interactions.

๐Ÿ”ฅ๐Ÿ”ฅ๐Ÿ”ฅโœ“ VerifiedAccount requiredAdvanced setup

Hyperlane MCP Server

A powerful Model Context Protocol (MCP) server that provides seamless integration with the Hyperlane protocol, enabling LLM assistants to interact with cross-chain messaging and smart contracts across multiple blockchains.

Table of Contents

Overview

The Hyperlane MCP Server bridges the gap between LLM assistants and the Hyperlane cross-chain infrastructure. It provides a standardized interface for deploying chains, managing validators and relayers, sending cross-chain messages, and deploying warp routes for asset transfers.

How It Works

Architecture

The server operates as an MCP (Model Context Protocol) server that:

  1. Connects to Multiple Blockchains: Uses Hyperlane's MultiProvider to manage connections to various blockchain networks
  2. Manages Local Registry: Maintains a local cache of chain metadata, deployed contracts, and warp route configurations
  3. Deploys Infrastructure: Handles deployment of Hyperlane core contracts, validators, and relayers
  4. Facilitates Cross-Chain Operations: Enables message passing and asset transfers between chains
  5. Provides Docker Integration: Runs validators and relayers in Docker containers for isolation

Core Components

  • LocalRegistry: Extends Hyperlane's registry system with local storage capabilities
  • HyperlaneDeployer: Handles deployment of core Hyperlane contracts
  • ValidatorRunner: Manages validator Docker containers
  • RelayerRunner: Manages relayer Docker containers
  • WarpRoute: Handles deployment and management of cross-chain asset routes

Features

Cross-Chain Messaging

  • Send messages between different blockchain networks
  • Monitor message delivery status
  • Handle message verification and execution

Contract Deployment & Management

  • Deploy Hyperlane core contracts to new chains
  • Deploy and configure warp routes for asset transfers
  • Manage contract configurations and upgrades

Infrastructure Management

  • Run validators for message verification
  • Run relayers for message delivery
  • Monitor validator and relayer health
  • Handle Docker container lifecycle

Asset Transfers

  • Deploy warp routes for cross-chain asset transfers
  • Execute multi-hop asset transfers
  • Support various token types (native, synthetic, collateral, etc.)

Available Tools

Chain Management

  • deploy-chain: Deploy Hyperlane core contracts to a new chain
  • run-validator: Start a validator for a specific chain
  • run-relayer: Start a relayer for cross-chain message delivery

Cross-Chain Operations

  • cross-chain-message-transfer: Send messages between chains
  • cross-chain-asset-transfer: Transfer assets using warp routes

Warp Route Management

  • deploy-warp-route: Deploy new warp routes for asset transfers

Resources

  • Warp Route Configs: Access via hyperlane-warp:///{symbol}/{/chain*} URI

Project Structure

hyperlane-mcp/
โ”œโ”€โ”€ src/                          # Source code
โ”‚   โ”œโ”€โ”€ index.ts                  # Main MCP server entry point
โ”‚   โ”œโ”€โ”€ localRegistry.ts          # Local registry implementation
โ”‚   โ”œโ”€โ”€ hyperlaneDeployer.ts      # Core contract deployment
โ”‚   โ”œโ”€โ”€ RunValidator.ts           # Validator Docker management
โ”‚   โ”œโ”€โ”€ RunRelayer.ts             # Relayer Docker management
โ”‚   โ”œโ”€โ”€ warpRoute.ts              # Warp route deployment
โ”‚   โ”œโ”€โ”€ msgTransfer.ts            # Message transfer logic
โ”‚   โ”œโ”€โ”€ assetTransfer.ts          # Asset transfer logic
โ”‚   โ”œโ”€โ”€ config.ts                 # Configuration utilities
โ”‚   โ”œโ”€โ”€ utils.ts                  # Utility functions
โ”‚   โ”œโ”€โ”€ types.ts                  # Type definitions
โ”‚   โ”œโ”€โ”€ logger.ts                 # Logging configuration
โ”‚   โ”œโ”€โ”€ gcr.ts                    # Google Container Registry utilities
โ”‚   โ”œโ”€โ”€ file.ts                   # File system utilities
โ”‚   โ”œโ”€โ”€ configOpts.ts             # Configuration options
โ”‚   โ””โ”€โ”€ consts.ts                 # Constants
โ”œโ”€โ”€ build/                        # Compiled JavaScript output
โ”œโ”€โ”€ node_modules/                 # Dependencies
โ”œโ”€โ”€ package.json                  # Project configuration
โ”œโ”€โ”€ tsconfig.json                 # TypeScript configuration
โ”œโ”€โ”€ .env                          # Environment variables (create this)
โ””โ”€โ”€ README.md                     # This file

Files & Folders Created

The server creates and manages several directories and files during operation:

Cache Directory Structure

~/.hyperlane-mcp/                 # Main cache directory
โ”œโ”€โ”€ chains/                       # Chain configurations
โ”‚   โ”œโ”€โ”€ {chainName}.yaml          # Chain metadata
โ”‚   โ”œโ”€โ”€ {chainName}.deploy.yaml   # Deployed contract addresses
โ”‚   โ””โ”€โ”€ {chainName}-core-config.yaml # Core deployment config
โ”œโ”€โ”€ routes/                       # Warp route configurations
โ”‚   โ””โ”€โ”€ {symbol}-{hash}.yaml      # Warp route configs
โ”œโ”€โ”€ agents/                       # Agent configurations
โ”‚   โ””โ”€โ”€ {chainName}-agent-config.json # Validator/relayer configs
โ””โ”€โ”€ logs/                         # Runtime data and logs
    โ”œโ”€โ”€ hyperlane_db_validator_{chain}/ # Validator database
    โ”œโ”€โ”€ hyperlane_db_relayer/     # Relayer database
    โ””โ”€โ”€ hyperlane-validator-signatures-{chain}/ # Validator signatures

File Types Created

Chain Configuration Files

  • {chainName}.yaml: Contains chain metadata (RPC URLs, chain ID, native token info)
  • {chainName}.deploy.yaml: Deployed contract addresses (mailbox, ISM, hooks, etc.)
  • {chainName}-core-config.yaml: Core deployment configuration

Warp Route Files

  • {symbol}-{hash}.yaml: Warp route configuration for cross-chain asset transfers

Agent Configuration Files

  • {chainName}-agent-config.json: Configuration for validators and relayers

Docker Volumes

  • Validator databases: Persistent storage for validator state
  • Relayer databases: Persistent storage for relayer state
  • Signature storage: Validator checkpoint signatures

Temporary Files

  • Docker containers: Validator and relayer containers (managed automatically)
  • Log files: Runtime logs from validators and relayers

Examples

1. Deploy a New Chain

Deploy Hyperlane core contracts to a new blockchain called "mytestnet" with chain ID 12345, RPC URL "https://rpc.mytestnet.com", native token symbol "MTN", and token name "MyTestNet Token". This should be marked as a testnet.

2. Send Cross-Chain Message

Send a cross-chain message from Ethereum to Polygon. The recipient address should be 0x742d35Cc6634C0532925a3b8D4C9db96c4b4d8b6 and the message body should be "Hello from Ethereum!"

3. Deploy Warp Route

Deploy a warp route for asset transfers between Ethereum and Arbitrum chains. Use collateral token type for Ethereum and synthetic token type for Arbitrum.

4. Transfer Assets

Transfer assets using the USDC warp route from Ethereum to Arbitrum. Transfer 100 USDC to recipient address 0x742d35Cc6634C0532925a3b8D4C9db96c4b4d8b6. First, fetch the warp route configuration for USDC on these chains using the resources.

5. Run Infrastructure

Start a validator for the "mytestnet" chain that we deployed earlier.
Start a relayer to handle message delivery between Ethereum and mytestnet chains. Use "mytestnet" as the validator chain name.

6. Multi-Chain Asset Transfer

Transfer 50 USDC from Ethereum to Polygon, then from Polygon to Arbitrum, using the existing USDC warp routes. The final recipient should be 0x742d35Cc6634C0532925a3b8D4C9db96c4b4d8b6.

7. Check Warp Route Resources

Show me the available warp route configurations for USDC token across Ethereum and Polygon chains.

8. Deploy Custom Token Route

Deploy a new warp route for a custom token called "MyToken" (symbol: MTK) between three chains: Ethereum (collateral type), Polygon (synthetic type), and Arbitrum (synthetic type).

Authors

Disclaimer

The software is provided as is. No guarantee, representation or warranty is being made, express or implied, as to the safety or correctness of the software. It has not been audited and as such there can be no assurance it will work as intended. Users may experience delays, failures, errors, omissions, loss of transmitted information or loss of funds. The creators are not liable for any of the foregoing. Users should proceed with caution and use at their own risk.