MGO — Multi-chain Gas Optimizer

السجل الرسمي المالية والمدفوعات

Cheapest EVM chain across up to 9 networks with savings %. Free demo tools, paid tools via x402.

التثبيت

أضف هذا إلى إعدادات MCP في عميلك (Claude Desktop: claude_desktop_config.json، وCursor: ‏.cursor/mcp.json، ويستخدم VS Code وغيره الصيغة نفسها «mcpServers»).

NPM package chain-ops-mgo
Claude Code
claude mcp add mgo-multi-chain-gas-optimizer -e 'MGO_PRIVATE_KEY=<your mgo_private_key>' -e 'MGO_MAX_PRICE=<MGO_MAX_PRICE>' -- npx -y chain-ops-mgo@1.2.0
إعداد JSON (Claude Desktop وCursor وVS Code)
{
    "mcpServers": {
        "mgo-multi-chain-gas-optimizer": {
            "command": "npx",
            "args": [
                "-y",
                "chain-ops-mgo@1.2.0"
            ],
            "env": {
                "MGO_PRIVATE_KEY": "<your mgo_private_key>",
                "MGO_MAX_PRICE": "<MGO_MAX_PRICE>"
            }
        }
    }
}

متغيرات البيئة

  • MGO_PRIVATE_KEY سري Optional. EVM private key (0x...) holding USDC on Base; enables auto-pay for the paid tools.
  • MGO_MAX_PRICE Optional. Hard cap per call in micro-USDC (default 10000 = $0.01).

التوثيق

مأخوذ من ملف README للمشروع على GitHub ويُحدَّث أسبوعيًا. تفتح الروابط على GitHub.

المحتويات
  1. chain-ops-mgo
  2. MCP server (Claude Desktop, Cursor, any MCP client)
  3. Install (library)
  4. Quick Start
  5. Endpoints
  6. Auto-pay options
  7. Manual mode (advanced)
  8. Payment
  9. Links
  10. License

chain-ops-mgo

Multi-chain Gas Optimizer — Compare real-time gas prices across 9 EVM chains and get the cheapest-chain recommendation. Pay-per-call via x402 on Base. No API key, no signup.

When to use: call it before any EVM transaction (bridge, deploy, swap) to route to the lowest-fee chain — e.g. "Use Optimism — saves 97% vs Ethereum". Built for AI agents: one USDC microtransaction per call. Ships as a Node client and a stdio MCP server.

MCP server (Claude Desktop, Cursor, any MCP client)

No install needed:

{
  "mcpServers": {
    "mgo-gas": {
      "command": "npx",
      "args": ["-y", "chain-ops-mgo"],
      "env": { "MGO_PRIVATE_KEY": "0x...", "MGO_MAX_PRICE": "10000" }
    }
  }
}

Tools: get_gas_demo, get_cheapest_chain (free), get_gas_basic ($0.001), get_gas_premium ($0.002). Without MGO_PRIVATE_KEY the paid tools return the x402 payment requirements instead of data. With it (plus @chain-ops/agent-sdk and viem installed) they pay automatically, capped at MGO_MAX_PRICE micro-USDC (default 10000 = $0.01). Prefer not to run anything? The same tools are hosted at https://api.mgo.chain-ops.xyz/mcp (official MCP Registry: xyz.chain-ops/mgo).

Install (library)

Free endpoints only:

npm install chain-ops-mgo

Auto-payment (recommended for paid endpoints):

npm install chain-ops-mgo @chain-ops/agent-sdk viem

Quick Start

Free — no payment
const { getCheapestChain } = require('chain-ops-mgo');

const result = await getCheapestChain();
console.log(result);
// {
//   chain: 'Optimism', chainId: 10, nativeToken: 'ETH',
//   gasPriceGwei: '0.0010',
//   dexSwapCostNative: '0.00000016',
//   dexSwapCostUsdc: 0.00039,        // from the free /prices feed; omitted if unavailable
//   savingsVs: 'Ethereum',
//   savingsPercent: '97.4%'
// }
const { getGasBasicWithPayment } = require('chain-ops-mgo');

const data = await getGasBasicWithPayment({
  account: process.env.PRIVATE_KEY, // 0x...
  network: 'base',
});

console.log(data.recommendation.action);
// "Use Optimism — saves 97.4% vs Ethereum"

The SDK handles the x402 402-handshake (parse requirements, sign the EIP-3009 USDC authorization, retry). One USDC microtransaction per call ($0.001 basic, $0.002 premium), hard-capped at maxPrice (default $0.01).

Endpoints

FunctionPriceChainsNotes
getGasDemo()Free4Raw gas prices (native units), rate limited 10/hr
getPrices()Free—Native token USD prices (ETH, BNB, POL, AVAX, HYPE), 60s cache
getCheapestChain()Free4Cheapest chain for a DEX swap, USD via getPrices()
getGasBasicWithPayment({ account })$0.001 USDC4Auto-pay via SDK + recommendation
getGasPremiumWithPayment({ account })$0.002 USDC9Auto-pay via SDK + 9 chains incl. BNB, Polygon, Avalanche, zkSync, Hyperliquid
getGasBasic({ paymentHeader })$0.001 USDC4Manual mode — bring your own x402 header
getGasPremium({ paymentHeader })$0.002 USDC9Manual mode — bring your own x402 header

Auto-pay options

await getGasPremiumWithPayment({
  account: '0x...',         // private key OR a viem Account object
  network: 'base',          // currently only 'base'
  maxPrice: 5_000n,         // optional cap in micro-USDC ($0.005); default 10_000n
});

If @chain-ops/agent-sdk is not installed, the auto-pay functions throw a clear error pointing to the install command. Free functions work without it.

Manual mode (advanced)

If you build your own x402 client, you can supply a pre-built header:

const { getGasBasic } = require('chain-ops-mgo');

const data = await getGasBasic({
  paymentHeader: { 'PAYMENT-SIGNATURE': '<base64 x402 v2 payload>' }, // or 'X-PAYMENT' for v1
});

Without a payment header, paid functions throw Error: Payment required with err.status === 402 and err.paymentInfo (the decoded PAYMENT-REQUIRED header: accepts[], resource, ...).

Payment

Uses x402 protocol on Base (eip155:8453) with USDC. No API key, no subscription, no account required.

License

MIT

الأسئلة الشائعة

ما هو MGO — Multi-chain Gas Optimizer؟

Cheapest EVM chain across up to 9 networks with savings %. Free demo tools, paid tools via x402.

كيف أثبّت MGO — Multi-chain Gas Optimizer؟

يعمل على جهازك. في Claude Code: claude mcp add mgo-multi-chain-gas-optimizer -e 'MGO_PRIVATE_KEY=<your mgo_private_key>' -e 'MGO_MAX_PRICE=<MGO_MAX_PRICE>' -- npx -y chain-ops-mgo@1.2.0. وفي العملاء الآخرين، الصق إعداد JSON من هذه الصفحة في إعدادات MCP الخاصة بهم.

هل يحتاج MGO — Multi-chain Gas Optimizer إلى مفتاح API؟

نعم. يتطلب MGO_PRIVATE_KEY، وتضبطها في إعداداته.

هل MGO — Multi-chain Gas Optimizer مفتوح المصدر؟

نعم. شيفرته متاحة على GitHub بترخيص MIT.

من يصون MGO — Multi-chain Gas Optimizer؟

ينشره dlrjsdl200-byte. يدرجه AI.tn لكنه لا يصونه ولا يوصي به.

من سجل MCP الرسمي. الإدراج ليس توصية: راجع شيفرة الخادم وصلاحياته قبل منحه الوصول إلى بياناتك.