Skip to main content
Glama

ValueRouter MCP Server

get_bridge_quote

Obtain a quote for bridging USDC or other tokens between blockchain networks by specifying source and destination chains, tokens, and amount using ValueRouter MCP Server.

Instructions

Get a quote for bridging USDC or other tokens between chains

Input Schema

NameRequiredDescriptionDefault
amountYesAmount to bridge in smallest unit (wei, lamports, etc.)
fromChainIdYesSource chain ID
fromTokenYes
slippageBpsNoSlippage tolerance in basis points (100 = 1%)
toChainIdYesDestination chain ID
toTokenYes
userAddressNoUser address for better quote accuracy (optional)

Input Schema (JSON Schema)

{ "additionalProperties": false, "properties": { "amount": { "description": "Amount to bridge in smallest unit (wei, lamports, etc.)", "type": "string" }, "fromChainId": { "description": "Source chain ID", "oneOf": [ { "type": "number" }, { "type": "string" } ] }, "fromToken": { "properties": { "address": { "type": "string" }, "chainId": { "oneOf": [ { "type": "number" }, { "type": "string" } ] }, "decimals": { "type": "number" }, "isNative": { "type": "boolean" }, "logoURI": { "type": "string" }, "name": { "type": "string" }, "symbol": { "type": "string" } }, "required": [ "address", "chainId", "symbol", "name", "decimals" ], "type": "object" }, "slippageBps": { "default": 100, "description": "Slippage tolerance in basis points (100 = 1%)", "type": "number" }, "toChainId": { "description": "Destination chain ID", "oneOf": [ { "type": "number" }, { "type": "string" } ] }, "toToken": { "properties": { "address": { "type": "string" }, "chainId": { "oneOf": [ { "type": "number" }, { "type": "string" } ] }, "decimals": { "type": "number" }, "isNative": { "type": "boolean" }, "logoURI": { "type": "string" }, "name": { "type": "string" }, "symbol": { "type": "string" } }, "required": [ "address", "chainId", "symbol", "name", "decimals" ], "type": "object" }, "userAddress": { "description": "User address for better quote accuracy (optional)", "type": "string" } }, "required": [ "fromChainId", "toChainId", "fromToken", "toToken", "amount" ], "type": "object" }

Implementation Reference

  • The primary handler function for the 'get_bridge_quote' tool. It validates the input arguments using QuoteRequestSchema and delegates to QuoteService.getQuote for the actual quote computation, returning a formatted MCPToolResult.
    private async getBridgeQuote(args: any): Promise<MCPToolResult> { try { const request = QuoteRequestSchema.parse(args); const result = await this.quoteService.getQuote(request); return createSuccessResponse(result); } catch (error) { return createErrorResponse( error instanceof Error ? error.message : String(error), 'QUOTE_ERROR' ); } }
  • Zod schema definition for validating the input parameters of the get_bridge_quote tool (QuoteRequest). Used in the handler for parsing arguments.
    export const QuoteRequestSchema = z.object({ fromChainId: z.union([z.number(), z.string()]), toChainId: z.union([z.number(), z.string()]), fromToken: TokenSchema, toToken: TokenSchema, amount: z.string(), // Amount in smallest unit (wei, lamports, etc.) slippageBps: z.number().optional().default(100), // 1% default slippage userAddress: z.string().optional(), // For better quote accuracy }); export type QuoteRequest = z.infer<typeof QuoteRequestSchema>;
  • src/index.ts:100-163 (registration)
    Tool registration in the MCP server's listTools response, defining the name, description, and JSON input schema for get_bridge_quote.
    { name: 'get_bridge_quote', description: 'Get a quote for bridging USDC or other tokens between chains', inputSchema: { type: 'object', properties: { fromChainId: { oneOf: [ { type: 'number' }, { type: 'string' }, ], description: 'Source chain ID', }, toChainId: { oneOf: [ { type: 'number' }, { type: 'string' }, ], description: 'Destination chain ID', }, fromToken: { type: 'object', properties: { address: { type: 'string' }, chainId: { oneOf: [{ type: 'number' }, { type: 'string' }] }, symbol: { type: 'string' }, name: { type: 'string' }, decimals: { type: 'number' }, logoURI: { type: 'string' }, isNative: { type: 'boolean' }, }, required: ['address', 'chainId', 'symbol', 'name', 'decimals'], }, toToken: { type: 'object', properties: { address: { type: 'string' }, chainId: { oneOf: [{ type: 'number' }, { type: 'string' }] }, symbol: { type: 'string' }, name: { type: 'string' }, decimals: { type: 'number' }, logoURI: { type: 'string' }, isNative: { type: 'boolean' }, }, required: ['address', 'chainId', 'symbol', 'name', 'decimals'], }, amount: { type: 'string', description: 'Amount to bridge in smallest unit (wei, lamports, etc.)', }, slippageBps: { type: 'number', description: 'Slippage tolerance in basis points (100 = 1%)', default: 100, }, userAddress: { type: 'string', description: 'User address for better quote accuracy (optional)', }, }, required: ['fromChainId', 'toChainId', 'fromToken', 'toToken', 'amount'], additionalProperties: false, }, },
  • Core helper method in QuoteService that performs the actual bridge quote calculation, including bridge fees, gas estimation, slippage, route simulation, and response formatting.
    async getQuote(request: QuoteRequest): Promise<QuoteResponse> { const { fromChainId, toChainId, fromToken, toToken, amount, slippageBps = 100 } = request; const fromChainIdTyped = fromChainId as SupportedChainId; const toChainIdTyped = toChainId as SupportedChainId; // Validate chains if (!CHAIN_INFO[fromChainIdTyped] || !CHAIN_INFO[toChainIdTyped]) { throw new Error(`Unsupported chain: ${fromChainId} or ${toChainId}`); } // Calculate bridge fees const bridgeFeeAmount = this.calculateBridgeFee(amount); const estimatedGas = await this.estimateGasFees(fromChainIdTyped, toChainIdTyped); // For now, we'll simulate quote calculation // In production, this would call actual DEX aggregators and bridge services const quote = await this.calculateQuote( fromChainIdTyped, toChainIdTyped, fromToken, toToken, amount, slippageBps ); const toAmountBig = BigInt(quote.toAmount); const slippageAmount = (toAmountBig * BigInt(slippageBps)) / BigInt(10000); const toAmountMin = (toAmountBig - slippageAmount).toString(); return { fromChainId, toChainId, fromToken, toToken, fromAmount: amount, toAmount: quote.toAmount, toAmountMin, bridgeFee: bridgeFeeAmount, gasFee: estimatedGas, totalFee: (BigInt(bridgeFeeAmount) + BigInt(estimatedGas)).toString(), estimatedTime: this.estimateCompletionTime(fromChainIdTyped, toChainIdTyped), priceImpact: quote.priceImpact, route: quote.route, validUntil: Date.now() + 60 * 1000, // 1 minute }; }
  • Private helper method that computes the detailed quote including toAmount, priceImpact, and simulated bridge/swap route.
    private async calculateQuote( fromChainId: SupportedChainId, toChainId: SupportedChainId, fromToken: Token, toToken: Token, amount: string, slippageBps: number ): Promise<{ toAmount: string; priceImpact: string; route: { steps: { type: "swap" | "bridge"; chainId: SupportedChainId; fromToken: Token; toToken: Token; amount: string; protocol: string; }[]; }; }> { // For USDC-to-USDC bridging, it's 1:1 minus fees if (fromToken.symbol === 'USDC' && toToken.symbol === 'USDC') { const bridgeFee = this.calculateBridgeFee(amount); const toAmount = (BigInt(amount) - BigInt(bridgeFee)).toString(); return { toAmount, priceImpact: '0.01', // 1% for bridge fee route: { steps: [{ type: "bridge", chainId: fromChainId, fromToken, toToken, amount, protocol: "ValueRouter" }] }, }; } // For other token swaps, we'd need to call external APIs // For now, simulate with some basic calculations const mockToAmount = (BigInt(amount) * BigInt(95) / BigInt(100)).toString(); // 5% slippage simulation return { toAmount: mockToAmount, priceImpact: '0.05', // 5% price impact route: { steps: [ { type: "swap", chainId: fromChainId, fromToken, toToken: { ...toToken, chainId: fromChainId }, amount, protocol: "DEX" }, { type: "bridge", chainId: toChainId, fromToken: { ...toToken, chainId: fromChainId }, toToken, amount: mockToAmount, protocol: "ValueRouter" } ] }, }; }

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/RWAValueRouter/MCP'

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