Skip to main content
Glama
monad-vibe

Monad MCP Server

by monad-vibe

watch-contract-events

Monitor specific smart contract events on the Monad testnet by specifying the contract address, event name, and ABI. Track events starting from a chosen block number for accurate data analysis.

Instructions

Watch for smart contract events on Monad testnet

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
abiYesContract ABI
addressYesContract address to watch
eventNameYesName of the event to watch
fromBlockNoStart watching from this block number

Implementation Reference

  • The main handler function that implements the tool logic. It parses the ABI to find the event, queries past logs using viem's publicClient.getLogs, and returns the events as text content or an error message.
    async ({ address, eventName, abi, fromBlock }) => {
        try {
            const parsedAbi = JSON.parse(abi);
            const eventAbi = parsedAbi.find(
                (item: any) => item.type === 'event' && item.name === eventName
            );
    
            if (!eventAbi) {
                throw new Error(`Event ${eventName} not found in ABI`);
            }
    
            // Get past events
            const logs = await publicClient.getLogs({
                address: address as `0x${string}`,
                event: parseAbiItem(JSON.stringify(eventAbi)) as any,
                fromBlock: fromBlock ? BigInt(fromBlock) : undefined,
            });
    
            return {
                content: [
                    {
                        type: "text",
                        text: `Found ${logs.length} events for ${eventName} at ${address}:\n${JSON.stringify(logs, null, 2)}`,
                    },
                ],
            };
        } catch (error) {
            return {
                content: [
                    {
                        type: "text",
                        text: `Failed to watch events. Error: ${error instanceof Error ? error.message : String(error)}`,
                    },
                ],
            };
        }
  • Zod-based input schema defining the parameters for the watch-contract-events tool.
    {
        address: z.string().describe("Contract address to watch"),
        eventName: z.string().describe("Name of the event to watch"),
        abi: z.string().describe("Contract ABI"),
        fromBlock: z.string().optional().describe("Start watching from this block number"),
    },
  • Direct registration of the tool using server.tool() within the contractEventProvider function, specifying name, description, input schema, and handler.
    export function contractEventProvider(server: McpServer) {
        server.tool(
            "watch-contract-events",
            "Watch for smart contract events on Monad testnet",
            {
                address: z.string().describe("Contract address to watch"),
                eventName: z.string().describe("Name of the event to watch"),
                abi: z.string().describe("Contract ABI"),
                fromBlock: z.string().optional().describe("Start watching from this block number"),
            },
            async ({ address, eventName, abi, fromBlock }) => {
                try {
                    const parsedAbi = JSON.parse(abi);
                    const eventAbi = parsedAbi.find(
                        (item: any) => item.type === 'event' && item.name === eventName
                    );
    
                    if (!eventAbi) {
                        throw new Error(`Event ${eventName} not found in ABI`);
                    }
    
                    // Get past events
                    const logs = await publicClient.getLogs({
                        address: address as `0x${string}`,
                        event: parseAbiItem(JSON.stringify(eventAbi)) as any,
                        fromBlock: fromBlock ? BigInt(fromBlock) : undefined,
                    });
    
                    return {
                        content: [
                            {
                                type: "text",
                                text: `Found ${logs.length} events for ${eventName} at ${address}:\n${JSON.stringify(logs, null, 2)}`,
                            },
                        ],
                    };
                } catch (error) {
                    return {
                        content: [
                            {
                                type: "text",
                                text: `Failed to watch events. Error: ${error instanceof Error ? error.message : String(error)}`,
                            },
                        ],
                    };
                }
            }
        );
  • The contractProvider function calls contractEventProvider(server), which registers the watch-contract-events tool among contract tools.
    export function contractProvider(server: McpServer) {
        deployContractProvider(server);
        contractEventProvider(server);
    }
  • src/index.ts:23-27 (registration)
    In the main server initialization, contractProvider(server) is called, triggering the registration chain for the watch-contract-events tool.
    // Register available tools
    walletProvider(server);
    contractProvider(server);
    nftProvider(server);
    blockProvider(server);
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the tool 'watch for' events, implying a monitoring or subscription-like behavior, but doesn't clarify if this is a one-time query, a continuous stream, or how results are returned (e.g., real-time updates, batch retrieval). It also omits details like rate limits, authentication needs, or whether it's read-only (likely, but not stated). For a tool with potential ongoing behavior, this is a significant gap.

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 directly states the tool's function without unnecessary words. It is front-loaded with the core action ('Watch for smart contract events') and specifies the context ('on Monad testnet'), making it easy to parse quickly. Every part of the sentence contributes essential information.

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

Completeness2/5

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

Given the complexity of blockchain event monitoring (which often involves streaming or subscription behavior), no annotations, and no output schema, the description is incomplete. It doesn't explain what the tool returns (e.g., event logs, real-time notifications), how to handle the watch operation (e.g., polling, WebSocket), or error conditions. For a tool with 4 parameters and potential behavioral nuances, this leaves critical gaps for an AI agent to use it effectively.

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?

The input schema has 100% description coverage, with clear parameter definitions (e.g., 'Contract ABI', 'Contract address to watch'). The description adds no additional semantic context beyond what the schema provides, such as explaining ABI format requirements or eventName matching rules. Given the high schema coverage, a baseline score of 3 is appropriate, as the description doesn't compensate but doesn't detract either.

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 action ('Watch for') and resource ('smart contract events on Monad testnet'), making the purpose understandable. However, it doesn't explicitly differentiate from sibling tools like 'query-mon-nft' or 'get-block-by-number' which might also involve blockchain data retrieval, leaving room for ambiguity about when this specific event-watching capability is needed versus other querying methods.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites (e.g., needing a contract ABI), exclusions (e.g., not for historical data without 'fromBlock'), or comparisons to siblings like 'query-mon-nft' for NFT-specific queries. This lack of context makes it unclear when this tool is the appropriate choice.

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

Related 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/monad-vibe/monad-mcp-server'

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