switch_network
Change the active Solana blockchain network for transactions and queries. Select from mainnet, devnet, testnet, or localhost to configure your connection.
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 handleSwitchNetwork function that executes the tool logic: extracts the network from args, calls initializeConnection to switch the Solana RPC endpoint, and returns success confirmation with current network and RPC URL.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:251-261 (schema)Input schema definition for the switch_network tool, validating the 'network' parameter as a string enum with allowed Solana networks.inputSchema: { type: "object", properties: { network: { type: "string", enum: ["mainnet", "devnet", "testnet", "localhost"], description: "Network to switch to" } }, required: ["network"] }
- src/index.ts:248-262 (registration)Tool registration in the 'tools' array, which is returned by the list_tools handler to advertise the switch_network tool to MCP clients.{ 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 call_tool request handler's switch statement, dispatching calls to switch_network to the appropriate handler function.case "switch_network": result = await handleSwitchNetwork(args); break;
- src/index.ts:47-51 (helper)Helper function called by the handler to actually switch the network by creating a new Solana Connection to the specified RPC URL.function initializeConnection(network: string = "devnet") { currentNetwork = network; const rpcUrl = NETWORKS[network as keyof typeof NETWORKS] || NETWORKS.devnet; connection = new Connection(rpcUrl, "confirmed"); }