get_network_info
Retrieve current Solana network details including chain ID, version, and cluster information to verify blockchain connectivity and status.
Instructions
Get current network information
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/index.ts:820-833 (handler)The main handler function that executes the get_network_info tool logic. It ensures the Solana connection is initialized, fetches the network version and epoch information, and returns details about the current network including RPC URL.async function handleGetNetworkInfo() { ensureConnection(); const version = await connection.getVersion(); const epochInfo = await connection.getEpochInfo(); return { network: currentNetwork, rpcUrl: NETWORKS[currentNetwork as keyof typeof NETWORKS], version: version["solana-core"], epoch: epochInfo.epoch, slotIndex: epochInfo.slotIndex, slotsInEpoch: epochInfo.slotsInEpoch }; }
- src/index.ts:263-270 (registration)Registration of the get_network_info tool in the tools array used by ListToolsRequestSchema. Defines the tool name, description, and empty input schema (no parameters required).{ name: "get_network_info", description: "Get current network information", inputSchema: { type: "object", properties: {} } },
- src/index.ts:1321-1323 (registration)Dispatch logic in the CallToolRequestSchema handler's switch statement that maps the tool name to its handler function.case "get_network_info": result = await handleGetNetworkInfo(); break;
- src/index.ts:33-37 (helper)Helper constant defining Solana network RPC URLs, used by the handler to provide the current network's RPC endpoint.const NETWORKS = { mainnet: "https://api.mainnet-beta.solana.com", devnet: "https://api.devnet.solana.com", testnet: "https://api.testnet.solana.com", localhost: "http://127.0.0.1:8899"
- src/index.ts:56-61 (helper)Helper function called by the handler to lazily initialize the Solana connection if not already done.function ensureConnection() { if (!connectionInitialized) { initializeConnection(); connectionInitialized = true; } }