Skip to main content
Glama

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
NameRequiredDescriptionDefault
message_typeYesType of messaging operation to generate code for
include_exampleNoInclude 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"],
    }
  • 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"
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It mentions the tool 'generates' code, implying a creation operation, but doesn't specify whether this is read-only or has side effects (e.g., file writes), what permissions are needed, or any rate limits. The description adds minimal context beyond the basic action, leaving key behavioral traits unclear.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that front-loads the core purpose ('Generate TypeScript code for Arbitrum cross-chain messaging') and adds supporting details without waste. Every word contributes to understanding the tool's scope, making it appropriately sized and well-structured.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity (cross-chain messaging code generation), lack of annotations, and no output schema, the description is moderately complete. It covers the purpose and supported message types but misses details like output format (e.g., code snippets or files), error handling, or dependencies. For a code-generation tool with 2 parameters, this is adequate but has clear gaps in behavioral context.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents both parameters ('message_type' with enum values and 'include_example' with default). The description adds some semantic context by mentioning 'L1->L2 retryable tickets and L2->L1 messages', which loosely maps to the 'message_type' enum, but doesn't provide additional details like code format or examples. This meets the baseline for high schema coverage.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: 'Generate TypeScript code for Arbitrum cross-chain messaging.' It specifies the verb ('Generate') and resource ('TypeScript code'), and mentions the domain ('Arbitrum cross-chain messaging'). However, it doesn't explicitly differentiate from siblings like 'generate_bridge_code' or 'generate_frontend', which reduces clarity about its unique scope.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage by listing supported message types ('L1->L2 retryable tickets and L2->L1 messages'), suggesting it's for cross-chain messaging scenarios. However, it lacks explicit guidance on when to use this tool versus alternatives (e.g., 'generate_bridge_code' for general bridging or 'generate_frontend' for UI code), and doesn't mention prerequisites or exclusions, leaving usage context somewhat vague.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Quantum3-Labs/ARBuilder'

If you have feedback or need assistance with the MCP directory API, please join our Discord server