Skip to main content
Glama

get_relay_app_url

Generate a deep link to open the Relay web app with pre-filled bridge or swap parameters, enabling users to start new cross-chain transactions directly in their browser.

Instructions

Generate a deep link to the Relay web app with pre-filled bridge/swap parameters. The user can open this URL in their browser to START a new transaction via the Relay UI. This is NOT a transaction tracking URL — do NOT use it to check on an in-progress transaction. For tracking, use get_transaction_status with the requestId.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
destinationChainIdYesDestination chain ID (e.g. 8453 for Base). This determines the Relay app page.
fromChainIdNoOrigin chain ID (e.g. 1 for Ethereum). If omitted, user picks in the UI.
fromCurrencyNoOrigin token address. "0x0000000000000000000000000000000000000000" for native.
toCurrencyNoDestination token address. "0x0000000000000000000000000000000000000000" for native.
amountNoPre-filled input amount in human-readable units (e.g. "0.1" for 0.1 ETH).
toAddressNoRecipient wallet address.
tradeTypeNoTrade type. Defaults to EXACT_INPUT.

Implementation Reference

  • Main handler function for get_relay_app_url tool. Calls buildRelayAppUrl helper to generate the deep link URL, validates the result, and returns the URL to the user. Returns an error if the chain ID is invalid.
    async ({ destinationChainId, fromChainId, fromCurrency, toCurrency, amount, toAddress, tradeType }) => {
      const url = await buildRelayAppUrl({
        destinationChainId,
        fromChainId,
        fromCurrency,
        toCurrency,
        amount,
        toAddress,
        tradeType,
      });
    
      if (!url) {
        return {
          content: [
            {
              type: "text",
              text: `Error: Chain ID ${destinationChainId} not found. Use get_supported_chains to find valid chain IDs.`,
            },
          ],
          isError: true,
        };
      }
    
      const summary = `Open this link to complete the transaction in the Relay app: ${url}`;
    
      return {
        content: [
          { type: "text", text: summary },
          {
            type: "text",
            text: JSON.stringify({ url }, null, 2),
          },
        ],
      };
    }
  • Zod schema defining the input parameters for the get_relay_app_url tool. Includes required destinationChainId and optional parameters: fromChainId, fromCurrency, toCurrency, amount, toAddress, and tradeType (enum: EXACT_INPUT, EXPECTED_OUTPUT, EXACT_OUTPUT).
      destinationChainId: z
        .number()
        .describe("Destination chain ID (e.g. 8453 for Base). This determines the Relay app page."),
      fromChainId: z
        .number()
        .optional()
        .describe("Origin chain ID (e.g. 1 for Ethereum). If omitted, user picks in the UI."),
      fromCurrency: z
        .string()
        .optional()
        .describe('Origin token address. "0x0000000000000000000000000000000000000000" for native.'),
      toCurrency: z
        .string()
        .optional()
        .describe('Destination token address. "0x0000000000000000000000000000000000000000" for native.'),
      amount: z
        .string()
        .optional()
        .describe("Pre-filled input amount in human-readable units (e.g. \"0.1\" for 0.1 ETH)."),
      toAddress: z
        .string()
        .optional()
        .describe("Recipient wallet address."),
      tradeType: z
        .enum(["EXACT_INPUT", "EXPECTED_OUTPUT", "EXACT_OUTPUT"])
        .optional()
        .describe("Trade type. Defaults to EXACT_INPUT."),
    },
  • Registration function that registers the get_relay_app_url tool with the MCP server. Defines the tool name, description, schema, and handler function.
    export function register(server: McpServer) {
      server.tool(
        "get_relay_app_url",
        "Generate a deep link to the Relay web app with pre-filled bridge/swap parameters. The user can open this URL in their browser to START a new transaction via the Relay UI. This is NOT a transaction tracking URL — do NOT use it to check on an in-progress transaction. For tracking, use get_transaction_status with the requestId.",
        {
          destinationChainId: z
            .number()
            .describe("Destination chain ID (e.g. 8453 for Base). This determines the Relay app page."),
          fromChainId: z
            .number()
            .optional()
            .describe("Origin chain ID (e.g. 1 for Ethereum). If omitted, user picks in the UI."),
          fromCurrency: z
            .string()
            .optional()
            .describe('Origin token address. "0x0000000000000000000000000000000000000000" for native.'),
          toCurrency: z
            .string()
            .optional()
            .describe('Destination token address. "0x0000000000000000000000000000000000000000" for native.'),
          amount: z
            .string()
            .optional()
            .describe("Pre-filled input amount in human-readable units (e.g. \"0.1\" for 0.1 ETH)."),
          toAddress: z
            .string()
            .optional()
            .describe("Recipient wallet address."),
          tradeType: z
            .enum(["EXACT_INPUT", "EXPECTED_OUTPUT", "EXACT_OUTPUT"])
            .optional()
            .describe("Trade type. Defaults to EXACT_INPUT."),
        },
        async ({ destinationChainId, fromChainId, fromCurrency, toCurrency, amount, toAddress, tradeType }) => {
          const url = await buildRelayAppUrl({
            destinationChainId,
            fromChainId,
            fromCurrency,
            toCurrency,
            amount,
            toAddress,
            tradeType,
          });
    
          if (!url) {
            return {
              content: [
                {
                  type: "text",
                  text: `Error: Chain ID ${destinationChainId} not found. Use get_supported_chains to find valid chain IDs.`,
                },
              ],
              isError: true,
            };
          }
    
          const summary = `Open this link to complete the transaction in the Relay app: ${url}`;
    
          return {
            content: [
              { type: "text", text: summary },
              {
                type: "text",
                text: JSON.stringify({ url }, null, 2),
              },
            ],
          };
        }
      );
  • src/index.ts:12-12 (registration)
    Import statement for the get_relay_app_url tool registration function.
    import { register as registerGetRelayAppUrl } from "./tools/get-relay-app-url.js";
  • src/index.ts:28-28 (registration)
    Registration call that registers the get_relay_app_url tool with the MCP server instance.
    registerGetRelayAppUrl(server);

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/pedromcunha/relay-mcp'

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