network_switch
Switch Hedera blockchain networks to configure SDK connections, mirror nodes, and RPC endpoints for development, testing, or production deployment.
Instructions
Switch between Hedera networks seamlessly.
NETWORKS: mainnet (production), testnet (testing), previewnet (preview), local (development) UPDATES: All SDK connections, Mirror Node URLs, RPC endpoints automatically
USE FOR: Multi-network development, testing across environments, production deployment.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| network | Yes | Target network |
Implementation Reference
- src/tools/network.ts:35-56 (handler)The core handler function that switches the Hedera network by executing the 'network use' command via hederaCLI service.export async function switchNetwork(args: { network: 'mainnet' | 'testnet' | 'previewnet' | 'local'; }): Promise<ToolResult> { try { logger.info('Switching network', { network: args.network }); const result = await hederaCLI.executeCommand({ command: 'network use', args: { network: args.network, }, }); return result; } catch (error) { logger.error('Failed to switch network', { error }); return { success: false, error: error instanceof Error ? error.message : 'Unknown error', }; } }
- src/index.ts:583-585 (registration)The switch case in the main tool execution handler that routes calls to the switchNetwork function.case 'network_switch': result = await switchNetwork(args as { network: 'mainnet' | 'testnet' | 'previewnet' | 'local' }); break;
- src/index.ts:198-217 (schema)The tool schema definition used in optimizedToolDefinitions array, which is served via ListToolsRequest.{ name: 'network_switch', description: `Switch between Hedera networks seamlessly. NETWORKS: mainnet (production), testnet (testing), previewnet (preview), local (development) UPDATES: All SDK connections, Mirror Node URLs, RPC endpoints automatically USE FOR: Multi-network development, testing across environments, production deployment.`, inputSchema: { type: 'object' as const, properties: { network: { type: 'string', enum: ['mainnet', 'testnet', 'previewnet', 'local'], description: 'Target network', }, }, required: ['network'], }, },
- src/tools/network.ts:72-86 (schema)The local tool definition in networkTools array exported from the network module.name: 'network_switch', description: 'Switch to a different Hedera network. Available networks: mainnet (production), testnet (testing), previewnet (preview features), local (local development).', inputSchema: { type: 'object' as const, properties: { network: { type: 'string', description: 'Network to switch to', enum: ['mainnet', 'testnet', 'previewnet', 'local'], }, }, required: ['network'], }, },
- src/index.ts:30-30 (registration)Import statement that brings the switchNetwork handler into the main index.ts file.import { getCurrentNetwork, switchNetwork } from './tools/network.js';