Skip to main content
Glama
Bankless

Bankless Onchain MCP Server

Official
by Bankless

build_event_topic

Generates event topic signatures for blockchain events by specifying the event name and argument types, enabling accurate data retrieval and analysis on supported networks.

Instructions

Builds an event topic signature based on event name and arguments

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
argumentsYesEvent arguments types
nameYesEvent name (e.g., "Transfer(address,address,uint256)")
networkYesThe blockchain network (e.g., "ethereum", "base")

Implementation Reference

  • The main handler function that executes the tool logic: validates inputs implicitly via caller, processes arguments, makes authenticated POST request to Bankless API to build the event topic signature, and handles various errors.
    export async function buildEventTopic(
        network: string,
        name: string,
        arguments_: z.infer<typeof OutputSchema>[]
    ): Promise<string> {
        const token = process.env.BANKLESS_API_TOKEN;
    
        if (!token) {
            throw new BanklessAuthenticationError('BANKLESS_API_TOKEN environment variable is not set');
        }
    
        const endpoint = `${BASE_URL}/chains/${network}/contract/build-event-topic`;
    
        const cleanedOutputs = processOutputs(arguments_);
    
        try {
            const response = await axios.post(
                endpoint,
                {
                    name,
                    arguments: cleanedOutputs
                },
                {
                    headers: {
                        'Content-Type': 'application/json',
                        'X-BANKLESS-TOKEN': `${token}`
                    }
                }
            );
    
            return response.data;
        } catch (error) {
            if (axios.isAxiosError(error)) {
                const statusCode = error.response?.status || 'unknown';
                const errorMessage = error.response?.data?.message || error.message;
    
                if (statusCode === 401 || statusCode === 403) {
                    throw new BanklessAuthenticationError(`Authentication Failed: ${errorMessage}`);
                } else if (statusCode === 404) {
                    throw new BanklessResourceNotFoundError(`Not Found: ${errorMessage}`);
                } else if (statusCode === 422) {
                    throw new BanklessValidationError(`Validation Error: ${errorMessage}`, error.response?.data);
                } else if (statusCode === 429) {
                    // Extract reset timestamp or default to 60 seconds from now
                    const resetAt = new Date();
                    resetAt.setSeconds(resetAt.getSeconds() + 60);
                    throw new BanklessRateLimitError(`Rate Limit Exceeded: ${errorMessage}`, resetAt);
                }
    
                throw new Error(`Bankless API Error (${statusCode}): ${errorMessage}`);
            }
            throw new Error(`Failed to build event topic: ${error instanceof Error ? error.message : String(error)}`);
        }
    }
  • Input schema using Zod for validating the tool's parameters: network, event name, and array of argument types.
    export const BuildEventTopicSchema = z.object({
        network: z.string().describe('The blockchain network (e.g., "ethereum", "base")'),
        name: z.string().describe('Event name (e.g., "Transfer(address,address,uint256)")'),
        arguments: z.array(OutputSchema).describe('Event arguments types')
    });
  • src/index.ts:104-108 (registration)
    Tool registration in the MCP server's ListTools handler, specifying name, description, and input schema.
    {
        name: "build_event_topic",
        description: "Builds an event topic signature based on event name and arguments",
        inputSchema: zodToJsonSchema(events.BuildEventTopicSchema),
    },
  • src/index.ts:206-216 (registration)
    Dispatch handler in the MCP server's CallToolRequestHandler that parses arguments with the schema and invokes the buildEventTopic function.
    case "build_event_topic": {
        const args = events.BuildEventTopicSchema.parse(request.params.arguments);
        const result = await events.buildEventTopic(
            args.network,
            args.name,
            args.arguments
        );
        return {
            content: [{type: "text", text: JSON.stringify(result, null, 2)}],
        };
    }
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. It states what the tool does ('builds') but doesn't disclose behavioral traits such as whether it's a pure computation or makes external calls, what format the output is in (e.g., hex string), error conditions, or performance characteristics. For a tool with no annotation coverage, this leaves the agent guessing about key operational aspects.

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 purpose without unnecessary words. It's front-loaded with the core action and resource, making it easy to parse. Every part of the sentence contributes to understanding what the tool does.

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 no annotations and no output schema, the description is incomplete for a tool that likely produces a complex output (an 'event topic signature'). It doesn't explain what the output is (e.g., a hash, string format), how it's used, or any limitations. For a 3-parameter tool with no structured behavioral data, this leaves critical gaps in understanding the tool's full 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 all three parameters (network, name, arguments) with detailed descriptions. The description adds minimal value by mentioning 'event name and arguments', which is redundant with the schema. Baseline 3 is appropriate as the schema does the heavy lifting, though no additional semantic context is provided.

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 ('builds') and the resource ('event topic signature'), specifying it's based on 'event name and arguments'. It distinguishes from siblings like get_events (which retrieves events) or get_transaction_info (which analyzes transactions), but doesn't explicitly contrast with them. The purpose is specific enough to understand what the tool produces.

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 event details first), context (e.g., for blockchain analysis), or when not to use it. With siblings like get_events or read_contract that might provide related data, the lack of comparative guidance is a significant gap.

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/Bankless/onchain-mcp'

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