Skip to main content
Glama

get_rpc_proxy_url

Retrieve an EVM RPC proxy URL for a specific wallet and blockchain chain ID to use with development tools like Forge, Hardhat, ethers.js, or viem.

Instructions

Get the EVM RPC proxy URL for a wallet and chain. Use this URL as --rpc-url for Forge, Hardhat, ethers.js, or viem.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
wallet_idYesWallet ID (UUID)
chain_idYesEVM chain ID (e.g. 1 for Ethereum mainnet, 137 for Polygon)

Implementation Reference

  • The handler function that executes the logic to fetch and construct the RPC proxy URL.
    async (args) => {
      const result = await apiClient.get('/v1/connect-info');
      if (!('ok' in result) || !result.ok) {
        return toToolResult(result);
      }
    
      const data = result.data as ConnectInfoData;
      if (!data.rpcProxy?.enabled || !data.rpcProxy?.baseUrl) {
        return {
          content: [{
            type: 'text' as const,
            text: JSON.stringify({
              error: 'RPC proxy is not enabled. Ask the operator to enable it in Admin Settings.',
            }),
          }],
          isError: true,
        };
      }
    
      const url = `${data.rpcProxy.baseUrl}/${args.wallet_id}/${args.chain_id}`;
      return {
        content: [{
          type: 'text' as const,
          text: JSON.stringify({
            url,
            walletId: args.wallet_id,
            chainId: args.chain_id,
            usage: `Use this URL as --rpc-url: ${url}`,
          }),
        }],
      };
    },
  • The registration function for the 'get_rpc_proxy_url' tool.
    export function registerGetRpcProxyUrl(
      server: McpServer,
      apiClient: ApiClient,
      walletContext?: WalletContext,
    ): void {
      server.tool(
        'get_rpc_proxy_url',
        withWalletPrefix(
          'Get the EVM RPC proxy URL for a wallet and chain. Use this URL as --rpc-url for Forge, Hardhat, ethers.js, or viem.',
          walletContext?.walletName,
        ),
        {
          wallet_id: z.string().describe('Wallet ID (UUID)'),
          chain_id: z.number().describe('EVM chain ID (e.g. 1 for Ethereum mainnet, 137 for Polygon)'),
        },
        async (args) => {
          const result = await apiClient.get('/v1/connect-info');
          if (!('ok' in result) || !result.ok) {
            return toToolResult(result);
          }
    
          const data = result.data as ConnectInfoData;
          if (!data.rpcProxy?.enabled || !data.rpcProxy?.baseUrl) {
            return {
              content: [{
                type: 'text' as const,
                text: JSON.stringify({
                  error: 'RPC proxy is not enabled. Ask the operator to enable it in Admin Settings.',
                }),
              }],
              isError: true,
            };
          }
    
          const url = `${data.rpcProxy.baseUrl}/${args.wallet_id}/${args.chain_id}`;
          return {
            content: [{
              type: 'text' as const,
              text: JSON.stringify({
                url,
                walletId: args.wallet_id,
                chainId: args.chain_id,
                usage: `Use this URL as --rpc-url: ${url}`,
              }),
            }],
          };
        },
      );
    }
  • Input schema definition for the 'get_rpc_proxy_url' tool.
    {
      wallet_id: z.string().describe('Wallet ID (UUID)'),
      chain_id: z.number().describe('EVM chain ID (e.g. 1 for Ethereum mainnet, 137 for Polygon)'),
    },

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/minhoyoo-iotrust/WAIaaS'

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