net_listening
Check if the EVM client is actively listening for network connections to monitor blockchain connectivity status.
Instructions
Returns true if client is actively listening for network connections
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/index.ts:881-908 (handler)The MCP tool handler for 'net_listening'. It invokes the Ethereum RPC method 'net_listening' using makeRPCCall, formats the boolean result into a response, and handles any errors by returning an error message.async () => { try { const result = await makeRPCCall("net_listening"); return { content: [ { type: "text", text: formatResponse( { is_listening: result, }, "Network Status", ), }, ], }; } catch (error: any) { return { content: [ { type: "text", text: `Error: ${error.message}`, }, ], }; } },
- src/index.ts:877-909 (registration)Registration of the 'net_listening' tool on the MCP server, including name, description, empty input schema, and handler function.server.tool( "net_listening", "Returns true if client is actively listening for network connections", {}, async () => { try { const result = await makeRPCCall("net_listening"); return { content: [ { type: "text", text: formatResponse( { is_listening: result, }, "Network Status", ), }, ], }; } catch (error: any) { return { content: [ { type: "text", text: `Error: ${error.message}`, }, ], }; } }, );
- src/index.ts:89-96 (helper)Helper function that performs the actual RPC call to the Ethereum provider using 'provider.send', which is invoked by the net_listening handler with method 'net_listening'.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}`); } }