Skip to main content
Glama

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
NameRequiredDescriptionDefault
networkYesNetwork to switch to

Implementation Reference

  • 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] }; }
  • 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;
  • 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"); }

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/ExpertVagabond/solana-mcp-server'

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