Skip to main content
Glama
buildwithgrove

Grove's MCP Server for Pocket Network

call_rpc_method

Execute JSON-RPC methods on blockchain services to query data or perform operations across supported networks.

Instructions

Call a JSON-RPC method on a specific blockchain service

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
blockchainYesBlockchain name (e.g., "ethereum", "polygon")
methodYesRPC method name (e.g., "eth_blockNumber", "eth_getBalance")
paramsNoArray of parameters for the RPC method
networkNoNetwork type (defaults to mainnet)

Implementation Reference

  • Registers the 'call_rpc_method' MCP tool including name, description, and input schema definition.
    {
      name: 'call_rpc_method',
      description: 'Call a JSON-RPC method on a specific blockchain service',
      inputSchema: {
        type: 'object',
        properties: {
          blockchain: {
            type: 'string',
            description: 'Blockchain name (e.g., "ethereum", "polygon")',
          },
          method: {
            type: 'string',
            description: 'RPC method name (e.g., "eth_blockNumber", "eth_getBalance")',
          },
          params: {
            type: 'array',
            description: 'Array of parameters for the RPC method',
          },
          network: {
            type: 'string',
            enum: ['mainnet', 'testnet'],
            description: 'Network type (defaults to mainnet)',
          },
        },
        required: ['blockchain', 'method'],
      },
    },
  • Executes the 'call_rpc_method' tool: performs safety validation, retrieves the appropriate blockchain service, calls the underlying callRPCMethod, and returns formatted result.
    case 'call_rpc_method': {
      const blockchain = args?.blockchain as string;
      const method = args?.method as string;
      const params = (args?.params as any[]) || [];
      const network = (args?.network as 'mainnet' | 'testnet') || 'mainnet';
    
      // SAFETY CHECK: Validate RPC call before execution
      const safetyCheck = validateRPCCall(blockchain, method, params);
      if (!safetyCheck.safe) {
        return {
          content: [
            {
              type: 'text',
              text: `⛔ UNSAFE RPC CALL BLOCKED\n\n` +
                    `Reason: ${safetyCheck.reason}\n\n` +
                    `Suggestion: ${safetyCheck.suggestion}\n\n` +
                    `This protection prevents session crashes from large responses.`,
            },
          ],
          isError: true,
        };
      }
    
      const service = blockchainService.getServiceByBlockchain(blockchain, network);
    
      if (!service) {
        return {
          content: [
            {
              type: 'text',
              text: `Blockchain service not found: ${blockchain} (${network})`,
            },
          ],
          isError: true,
        };
      }
    
      const result = await blockchainService.callRPCMethod(service.id, method, params);
    
      return {
        content: [
          {
            type: 'text',
            text: JSON.stringify(result, null, 2),
          },
        ],
        isError: !result.success,
      };
    }
  • Core helper function implementing the RPC method call: sends JSON-RPC POST request to the service endpoint, handles HTTP and JSON-RPC errors comprehensively, and returns structured EndpointResponse.
    async callRPCMethod(
      serviceId: string,
      method: string,
      params: any[] = []
    ): Promise<EndpointResponse> {
      const service = this.getServiceById(serviceId);
      if (!service) {
        return {
          success: false,
          error: `Service not found: ${serviceId}`,
        };
      }
    
      const rpcUrl = service.rpcUrl;
    
      try {
        const response = await fetch(rpcUrl, {
          method: 'POST',
          headers: {
            'Content-Type': 'application/json',
          },
          body: JSON.stringify({
            jsonrpc: '2.0',
            method,
            params,
            id: 1,
          }),
        });
    
        // Handle HTTP errors (rate limiting, server errors, etc.)
        if (!response.ok) {
          const errorText = await response.text().catch(() => 'Unable to read error response');
          let errorMessage = `HTTP ${response.status}: ${response.statusText}`;
    
          // Common HTTP error interpretations
          if (response.status === 429) {
            errorMessage = `Rate limit exceeded (HTTP 429). The endpoint may be experiencing high traffic.`;
          } else if (response.status === 503) {
            errorMessage = `Service temporarily unavailable (HTTP 503). The endpoint may be overloaded.`;
          } else if (response.status >= 500) {
            errorMessage = `Server error (HTTP ${response.status}). The RPC endpoint encountered an internal error.`;
          }
    
          return {
            success: false,
            error: errorMessage,
            data: {
              httpStatus: response.status,
              httpStatusText: response.statusText,
              responseBody: errorText.substring(0, 500), // Limit error body size
            },
            metadata: {
              timestamp: new Date().toISOString(),
              endpoint: rpcUrl,
            },
          };
        }
    
        const data = await response.json();
    
        // Handle JSON-RPC errors
        if (data.error) {
          return {
            success: false,
            error: data.error.message || 'RPC error',
            data: data.error,
            metadata: {
              timestamp: new Date().toISOString(),
              endpoint: rpcUrl,
            },
          };
        }
    
        return {
          success: true,
          data: data.result,
          metadata: {
            timestamp: new Date().toISOString(),
            endpoint: rpcUrl,
          },
        };
      } catch (error) {
        return {
          success: false,
          error: error instanceof Error ? error.message : 'Unknown error',
          data: {
            errorType: error instanceof Error ? error.constructor.name : 'UnknownError',
            errorStack: error instanceof Error ? error.stack : undefined,
          },
          metadata: {
            timestamp: new Date().toISOString(),
            endpoint: rpcUrl,
          },
        };
      }
    }
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. It states this is a 'call' operation but doesn't specify whether it's read-only or mutating, what authentication might be required, rate limits, error handling, or what the response format looks like. This is inadequate for a tool that presumably interacts with external blockchain services.

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 states the core purpose without unnecessary words. It's appropriately sized and front-loaded with the 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?

For a tool that calls external JSON-RPC methods on blockchain services with no annotations and no output schema, the description is insufficient. It doesn't explain what kind of methods can be called, what the response format will be, error conditions, or how this differs from more specialized sibling tools. The context signals show this is a 4-parameter tool with complex blockchain interactions, requiring more guidance.

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 four parameters thoroughly. The description doesn't add any meaningful parameter semantics beyond what's in the schema - it doesn't explain relationships between parameters, provide examples of valid method names, or clarify the structure of the params array.

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 ('Call a JSON-RPC method') and target ('on a specific blockchain service'), providing a specific verb+resource combination. However, it doesn't explicitly differentiate from sibling tools like 'call_contract_view' or 'call_endpoint', which appear to be related RPC-style calls.

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?

No guidance is provided about when to use this tool versus alternatives like 'call_contract_view', 'call_endpoint', or other blockchain-specific query tools. The description gives no context about appropriate use cases or prerequisites for this generic RPC method.

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/buildwithgrove/mcp-pocket'

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