Skip to main content
Glama

getBridgeRoutes

Find cross-chain bridge routes for token transfers between EVM chains. Compare costs, times, and options to identify optimal paths using LI.FI data.

Instructions

크로스체인 브릿지 경로를 조회합니다 (LI.FI 기반, 비용/시간/경로 비교, 최적 경로 추천)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
fromChainYes출발 체인
toChainYes도착 체인
tokenYes토큰 심볼 (USDC, ETH 등) 또는 컨트랙트 주소
amountYes전송 수량 (사람이 읽을 수 있는 단위, 예: '100')

Implementation Reference

  • The main handler function for the getBridgeRoutes tool, which processes input arguments, resolves token addresses, converts amounts, and calls the fetchBridgeRoutes utility.
    async function handler(args: z.infer<typeof inputSchema>): Promise<ToolResult<BridgeRoutesData>> {
      const { fromChain, toChain, token, amount } = args;
    
      if (fromChain === toChain) {
        return makeError("Source and destination chains must be different", "INVALID_INPUT");
      }
    
      // 토큰 주소 해석
      let fromTokenAddress: string;
      let toTokenAddress: string;
      let decimals = 18;
    
      const upper = token.trim().toUpperCase();
      if (upper === "ETH" || upper === "POL" || upper === "MATIC") {
        fromTokenAddress = NATIVE_TOKEN_ADDRESS;
        toTokenAddress = NATIVE_TOKEN_ADDRESS;
      } else if (token.startsWith("0x") && token.length === 42) {
        fromTokenAddress = token;
        toTokenAddress = token;
        const meta = resolveTokenMeta(token, fromChain);
        if (meta) decimals = meta.decimals;
      } else {
        const meta = resolveTokenMeta(token, fromChain);
        if (!meta) return makeError(`Token '${token}' not found`, "TOKEN_NOT_FOUND");
        decimals = meta.decimals;
        const addresses = meta.addresses;
        fromTokenAddress = addresses[fromChain];
        toTokenAddress = addresses[toChain];
        if (!fromTokenAddress) return makeError(`Token '${token}' not available on ${fromChain}`, "TOKEN_NOT_FOUND");
        if (!toTokenAddress) return makeError(`Token '${token}' not available on ${toChain}`, "TOKEN_NOT_FOUND");
      }
    
      // 수량 변환 (사람 → raw)
      const rawAmount = BigInt(Math.floor(parseFloat(amount) * Math.pow(10, decimals))).toString();
    
      try {
        const result = await fetchBridgeRoutes(fromChain, toChain, fromTokenAddress, toTokenAddress, rawAmount);
        if (!result || result.routes.length === 0) {
          return makeError("No bridge routes found", "API_ERROR");
        }
    
        const routes: RouteInfo[] = result.routes.map((r) => ({
          bridge: r.bridge,
          estimatedTime: r.estimatedTime,
          feeUsd: r.feeUsd,
          gasCostUsd: r.gasCostUsd,
          amountOut: (Number(BigInt(r.amountOut)) / Math.pow(10, decimals)).toFixed(6),
          amountOutUsd: r.amountOutUsd,
        }));
    
        const data: BridgeRoutesData = {
          fromChain,
          toChain,
          token,
          amount,
          routes,
          bestRoute: routes[0] ?? null,
        };
    
        return makeSuccess(fromChain as SupportedChain, data, false);
      } catch (err) {
        const message = sanitizeError(err);
        return makeError(`Failed to fetch bridge routes: ${message}`, "API_ERROR");
      }
    }
  • Zod schema defining the input arguments for the getBridgeRoutes tool.
    const inputSchema = z.object({
      fromChain: z.enum(SUPPORTED_CHAINS).describe("출발 체인"),
      toChain: z.enum(SUPPORTED_CHAINS).describe("도착 체인"),
      token: z.string().describe("토큰 심볼 (USDC, ETH 등) 또는 컨트랙트 주소"),
      amount: z.string().describe("전송 수량 (사람이 읽을 수 있는 단위, 예: '100')"),
    });
  • Registration function for the getBridgeRoutes tool, which binds the handler and schema to the MCP server.
    export function register(server: McpServer) {
      server.tool(
        "getBridgeRoutes",
        "크로스체인 브릿지 경로를 조회합니다 (LI.FI 기반, 비용/시간/경로 비교, 최적 경로 추천)",
        inputSchema.shape,
        async (args) => {
          const result = await handler(args as z.infer<typeof inputSchema>);
          return { content: [{ type: "text" as const, text: JSON.stringify(result, null, 2) }] };
        },
      );
    }
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full disclosure burden. It successfully identifies the third-party provider (LI.FI) and evaluation criteria (cost/time comparison, optimal recommendation). However, it omits safety profile confirmation (read-only vs transactional), rate limits, or real-time vs cached data disclosure.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Single efficient sentence with action front-loaded (조회합니다) and supporting details parenthetically organized. No redundant words. Korean language allows dense information packing without losing clarity.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a 4-parameter query tool with complete schema coverage, the description adequately covers functionality, provider, and value-add features. While output schema is absent, the description hints at return value (optimal route recommendation). Minor gap: explicit read-only confirmation would strengthen given lack of annotations.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100% with clear Korean descriptions for all 4 parameters (출발/도착 체인, token formats, human-readable amount). The description adds no additional parameter constraints or relationships beyond the schema, warranting the baseline score for high-coverage schemas.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description uses a specific verb (조회합니다/query) with clear resource (cross-chain bridge routes), specifies the provider (LI.FI), and delineates key features (cost/time comparison, optimal recommendation). It clearly distinguishes from siblings like getSwapQuote by emphasizing cross-chain bridging and route comparison.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage through 'cross-chain' and 'LI.FI based' keywords, suggesting when to use it (for bridging across chains). However, it lacks explicit 'when to use vs alternatives' guidance, particularly regarding differentiation from getSwapQuote or when bridging is preferable vs swapping.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/calintzy/evmscope'

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