switch_network
Switch between Solana blockchain networks including mainnet, devnet, testnet, and localhost to configure your development or transaction environment.
Instructions
Switch Solana network
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| network | Yes | Network to switch to |
Implementation Reference
- src/index.ts:808-818 (handler)The handler function that implements the switch_network tool logic. It extracts the network from args, calls initializeConnection to switch the RPC endpoint, and returns success with current network details.async function handleSwitchNetwork(args: any) { const { network } = args; initializeConnection(network); return { success: true, network: currentNetwork, rpcUrl: NETWORKS[network as keyof typeof NETWORKS] }; }
- src/index.ts:248-262 (schema)The tool schema definition in the tools array, including name, description, and inputSchema with network enum validation.{ name: "switch_network", description: "Switch Solana network", inputSchema: { type: "object", properties: { network: { type: "string", enum: ["mainnet", "devnet", "testnet", "localhost"], description: "Network to switch to" } }, required: ["network"] } },
- src/index.ts:1318-1320 (registration)Registration in the main tool dispatcher switch statement within the CallToolRequestSchema handler.case "switch_network": result = await handleSwitchNetwork(args); break;
- src/index.ts:47-51 (helper)Helper function called by handleSwitchNetwork to actually create the new Connection to the specified network RPC.function initializeConnection(network: string = "devnet") { currentNetwork = network; const rpcUrl = NETWORKS[network as keyof typeof NETWORKS] || NETWORKS.devnet; connection = new Connection(rpcUrl, "confirmed"); }
- src/index.ts:33-37 (helper)Network configuration object used by switch_network to map network names to RPC URLs.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"