Skip to main content
Glama
buildwithgrove

Grove's MCP Server for Pocket Network

call_rpc_method

Execute JSON-RPC methods on blockchain services to retrieve data and interact with networks like Ethereum, Polygon, Solana, and Cosmos.

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")
networkNoNetwork type (defaults to mainnet)
paramsNoArray of parameters for the RPC method

Implementation Reference

  • The handler function logic for executing the 'call_rpc_method' tool. It extracts blockchain, method, params, and network from arguments, retrieves the corresponding blockchain service, and calls the underlying callRPCMethod on the service.
    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'; 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, }; }
  • Tool registration definition including name, description, and input schema for 'call_rpc_method'. This is returned by registerBlockchainHandlers and added to the MCP server's tool list.
    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'], }, },
  • Input schema defining the parameters for the 'call_rpc_method' tool: blockchain (required), method (required), params (array), network (optional enum).
    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'], },
  • Core helper function that performs the actual JSON-RPC call via HTTP POST to the blockchain service endpoint, handles responses, errors, 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, }, }; } }
  • src/index.ts:88-101 (registration)
    Main server registration where registerBlockchainHandlers is called to include 'call_rpc_method' in the tools list provided to MCP clients via ListToolsRequest.
    const tools: Tool[] = [ ...registerBlockchainHandlers(server, blockchainService), ...registerDomainHandlers(server, domainResolver), ...registerTransactionHandlers(server, advancedBlockchain), ...registerTokenHandlers(server, advancedBlockchain), ...registerMultichainHandlers(server, advancedBlockchain), ...registerContractHandlers(server, advancedBlockchain), ...registerUtilityHandlers(server, advancedBlockchain), ...registerEndpointHandlers(server, endpointManager), ...registerSolanaHandlers(server, solanaService), ...registerCosmosHandlers(server, cosmosService), ...registerSuiHandlers(server, suiService), ...registerDocsHandlers(server, docsManager), ];

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