generate_messaging_code
Generate TypeScript code for Arbitrum cross-chain messaging operations including L1 to L2 retryable tickets and L2 to L1 messages with status checking.
Instructions
Generate TypeScript code for Arbitrum cross-chain messaging. Supports L1->L2 retryable tickets and L2->L1 messages.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| message_type | Yes | Type of messaging operation to generate code for | |
| include_example | No | Include example usage with sample contract call |
Implementation Reference
- The execute() method of GenerateMessagingCodeTool class handles the request for messaging code based on the provided message_type parameter.
def execute(self, **kwargs) -> dict[str, Any]: """Generate messaging code based on the specified type.""" message_type = kwargs.get("message_type") _include_example = kwargs.get("include_example", True) if not message_type: return {"error": "message_type is required"} templates = { "l1_to_l2": L1_TO_L2_MESSAGE_TEMPLATE, "l2_to_l1": L2_TO_L1_MESSAGE_TEMPLATE, "l2_to_l1_claim": L2_TO_L1_CLAIM_TEMPLATE, "l2_to_l3": L2_TO_L3_MESSAGE_TEMPLATE, "l3_to_l2": L3_TO_L2_MESSAGE_TEMPLATE, "l3_to_l2_claim": L3_TO_L2_CLAIM_TEMPLATE, "check_status": MESSAGE_STATUS_TEMPLATE, } template = templates.get(message_type) if not template: return {"error": f"Unknown message_type: {message_type}"} # Determine required env vars based on message type env_vars = ["PRIVATE_KEY"] if message_type in ("l1_to_l2", "l2_to_l1_claim", "check_status"): env_vars = ["L1_RPC_URL", "L2_RPC_URL", "PRIVATE_KEY"] elif message_type == "l2_to_l1": env_vars = ["L2_RPC_URL", "PRIVATE_KEY"] elif message_type == "l2_to_l3": env_vars = ["L2_RPC_URL", "L3_RPC_URL", "PRIVATE_KEY"] elif message_type == "l3_to_l2": env_vars = ["L3_RPC_URL", "PRIVATE_KEY"] elif message_type == "l3_to_l2_claim": env_vars = ["L2_RPC_URL", "L3_RPC_URL", "PRIVATE_KEY"] result = { "code": template, "message_type": message_type, "dependencies": { "ethers": "^5.7.0", "@arbitrum/sdk": "^4.0.0", }, "env_vars": env_vars, "notes": self._get_notes(message_type), "related_types": self._get_related_types(message_type), "disclaimer": TEMPLATE_DISCLAIMER, } return result - The input_schema defines the expected input for the tool, including message_type and include_example.
input_schema = { "type": "object", "properties": { "message_type": { "type": "string", "enum": [ "l1_to_l2", "l2_to_l1", "l2_to_l1_claim", "l2_to_l3", "l3_to_l2", "l3_to_l2_claim", "check_status", ], "description": "Type of messaging operation to generate code for", }, "include_example": { "type": "boolean", "description": "Include example usage with sample contract call", "default": True, }, }, "required": ["message_type"], } - src/mcp/tools/generate_messaging_code.py:559-562 (registration)The GenerateMessagingCodeTool class definition, setting the name property to 'generate_messaging_code'.
class GenerateMessagingCodeTool(BaseTool): """Generate Arbitrum cross-chain messaging code.""" name = "generate_messaging_code"