net_peerCount
Check how many peers are currently connected to your EVM client to monitor network connectivity and node status across Ethereum, Polygon, Arbitrum, and other compatible chains.
Instructions
Returns number of peers currently connected to the client
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/index.ts:911-945 (registration)Registration of the net_peerCount tool including its handler function. The handler calls the Ethereum JSON-RPC method net_peerCount via the makeRPCCall helper, parses the hexadecimal result to decimal, formats it using formatResponse, and returns structured content or error message.server.tool( "net_peerCount", "Returns number of peers currently connected to the client", {}, async () => { try { const result = await makeRPCCall("net_peerCount"); const peerCount = parseInt(result, 16); return { content: [ { type: "text", text: formatResponse( { peer_count_hex: result, peer_count_decimal: peerCount, }, "Connected Peers", ), }, ], }; } catch (error: any) { return { content: [ { type: "text", text: `Error: ${error.message}`, }, ], }; } }, );