Skip to main content
Glama

net_version

Identify the current network ID for EVM-compatible blockchains like Ethereum, Polygon, and Arbitrum to verify which blockchain network you're connected to.

Instructions

Returns the current network id

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Inline asynchronous handler function for the 'net_version' MCP tool. It calls makeRPCCall('net_version') to fetch the network ID via RPC, formats the result using formatResponse, and returns it in the expected MCP content structure. Handles errors by returning an error message.
    server.tool("net_version", "Returns the current network id", {}, async () => {
      try {
        const result = await makeRPCCall("net_version");
    
        return {
          content: [
            {
              type: "text",
              text: formatResponse(
                {
                  network_id: result,
                },
                "Network Version",
              ),
            },
          ],
        };
      } catch (error: any) {
        return {
          content: [
            {
              type: "text",
              text: `Error: ${error.message}`,
            },
          ],
        };
      }
    });
  • src/index.ts:848-875 (registration)
    Registration of the 'net_version' tool on the MCP server using server.tool(). Includes tool name, description 'Returns the current network id', empty input schema {}, and the inline handler function.
    server.tool("net_version", "Returns the current network id", {}, async () => {
      try {
        const result = await makeRPCCall("net_version");
    
        return {
          content: [
            {
              type: "text",
              text: formatResponse(
                {
                  network_id: result,
                },
                "Network Version",
              ),
            },
          ],
        };
      } catch (error: any) {
        return {
          content: [
            {
              type: "text",
              text: `Error: ${error.message}`,
            },
          ],
        };
      }
    });
  • makeRPCCall utility function that wraps ethers.JsonRpcProvider.send() to perform RPC calls. Directly used in the net_version handler to invoke the 'net_version' RPC method.
    async function makeRPCCall(method: string, params: any[] = []): Promise<any> {
      try {
        const result = await provider.send(method, params);
        return result;
      } catch (error: any) {
        throw new Error(`RPC call failed: ${error.message}`);
      }
    }
  • formatResponse utility function that converts data objects into formatted Markdown strings for tool responses. Used in net_version handler to format {network_id: result} with title 'Network Version'.
    function formatResponse(data: any, title: string): string {
      let result = `**${title}**\n\n`;
    
      if (typeof data === "object" && data !== null) {
        if (Array.isArray(data)) {
          // Handle arrays
          result += `**Count:** ${data.length}\n\n`;
          data.forEach((item, index) => {
            result += `**${index + 1}.**\n`;
            if (typeof item === "object" && item !== null) {
              result += formatObject(item, "  ");
            } else {
              result += `  ${item}\n`;
            }
            result += "\n";
          });
        } else {
          // Handle objects
          result += formatObject(data, "");
        }
      } else {
        result += `${data}\n`;
      }
    
      return result;
    }
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 returns a value, implying a read-only operation, but does not specify whether it requires authentication, has rate limits, or details about the return format (e.g., numeric ID, string). This leaves significant gaps in understanding the tool's behavior beyond its basic function.

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, clear sentence with zero waste—it directly states the tool's function without fluff or redundancy. It is appropriately sized for a simple, parameterless tool and front-loads the essential information, making it easy for an agent to parse quickly.

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 tool's simplicity (0 parameters, no output schema, no annotations), the description is minimally complete but lacks depth. It explains what the tool does but does not provide context on the return value format or how it differs from similar tools like 'eth_chainId'. For a basic read operation, this is adequate but leaves room for improvement in guiding the agent effectively.

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

Parameters4/5

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

The tool has 0 parameters, and the schema description coverage is 100%, so the description does not need to compensate for missing parameter documentation. The baseline for 0 parameters is 4, as there are no parameters to explain, and the description appropriately focuses on the tool's output without unnecessary parameter details.

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 ('Returns') and the resource ('the current network id'), making the purpose immediately understandable. It distinguishes from siblings like 'eth_chainId' by specifying 'network id' rather than 'chain id', though the distinction could be more explicit. It avoids tautology by not just restating the tool name 'net_version'.

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, such as 'eth_chainId' or other network-related siblings. It lacks context on prerequisites, typical use cases, or any explicit when/when-not instructions, leaving the agent to infer usage based on the tool name alone.

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/JamesANZ/evm-mcp'

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