Skip to main content
Glama

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
NameRequiredDescriptionDefault
networkYesTarget network

Implementation Reference

  • 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;
  • 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'], }, },
  • 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';

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/justmert/hashpilot'

If you have feedback or need assistance with the MCP directory API, please join our Discord server