Skip to main content
Glama

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

Implementation Reference

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

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