Skip to main content
Glama

gage-sdk and gage-mcp

gage-sdk on npm gage-mcp on npm CI License: MIT

Borrow and earn on gage from your own code or AI agent. gage makes fixed-cost loans with no liquidation: a loan is never closed early because a price moves, and if it is not repaid by the end of its term the lenders keep the collateral and nothing else is taken. It runs on Robinhood Chain.

Package

What it is

gage-sdk

TypeScript: read gage, prepare each transaction unsigned for any wallet, or carry an action out with your own signer.

gage-mcp

The same tools for an AI agent over MCP, with a wallet of the agent's own that signs under spend limits.

Quickstart: your app

npm install gage-sdk viem
import { createGage, privateKeySigner } from "gage-sdk";

const gage = createGage(); // Robinhood Chain; createGage({ network: "testnet" }) for its testnet

// What 1 NVDA borrows for 7 days. Reads only: no key.
const { assets } = await gage.assets();
const nvda = assets.find((a) => a.symbol === "NVDA")!;
const quote = await gage.borrowQuote({ token: nvda.token, maxCollateral: "1000000000000000000", term: 604800 });
console.log(quote.summary); // Pledge 1 NVDA, receive 187.80 USDG, repay 189.86 USDG within 7 days

// Borrow it with your own key: the exact approval first, every step simulated before it is sent.
const signer = privateKeySigner(process.env.WALLET_KEY!);
const { action: _, ...terms } = quote.prepare;
const { loan } = await gage.run({ action: "borrow", ...terms }, signer);

Amounts are raw integers as decimal strings (USDG has 6 decimals, tokens their own), times are seconds.

Related MCP server: pai

Quickstart: your AI agent

npx -y gage-mcp init                      # the agent's own wallet on this computer: prints its address, never its key
claude mcp add gage -- npx -y gage-mcp    # Claude Code
codex mcp add gage -- npx -y gage-mcp     # Codex

Fund that wallet with only what the agent may use, and a little ETH for gas. The agent then borrows and earns when you ask, under spend limits: at most 100 USDG a loan, loop or deposit, and 250 USDG of loans and 250 USDG of deposits in any 24 hours, unless you change them (off lifts one).

To sign every step yourself instead, connect your agent to gage's hosted server, https://mcp.gage.cash/mcp: it prepares, and you confirm each step on gage.cash.

What you can do

To

Use

Borrow

quote a loan at the lowest fixed cost the partner vaults accept (borrowQuote), borrow, or leverage (a loop in one transaction, USDG only); cancel a listing no vault has funded yet

Repay or move on

reclaim (repay early, collateral back), cash_out (sell the collateral, repay, keep the rest), roll into a new loan, or auto_roll near the end of each term

Earn

earnVaults and vaultFreeCash, then earn_deposit and earn_redeem with the partner vaults that lend; earn_exit_now sells one of a vault's loans for a holder it cannot pay now

Puts

putQuote and put_open where a lend asset offers puts, then put_close, put_roll, put_auto_roll

LP lane

fixed-cost USDG loans against Uniswap, SushiSwap, Ramses and Fables positions: lpPositions, lpQuote, lp_borrow and its thirteen other actions, LP vaults and curators

Park

an out-of-range position into a partner vault and back (park, unpark), as one batch from the LP's wallet

Lend markets

the stock tokens and stablecoins gage lends besides USDG (lendAsset), new stablecoin markets found on chain

Collect

collect: loan credits, collateral back, vault earnings, exit sales and sGAGE

Look up

capabilities (terms, fees, rules), assets, loan, portfolio, balances, waitForFill

Rate gage

feedback: a score from 0 to 100 in ERC-8004, once a wallet

Every action can be prepared (prepare: the next unsigned transaction, for any wallet) or carried out (run, with your signer). gageTools(gage) gives your own agent framework the tools gage's MCP servers serve.

What it will not do

  • Hold your key, or sign anything gage's own planner did not build: no tool sends arbitrary calldata.

  • Fund a loan directly: lending is a deposit into a partner vault.

  • Read or act on private loans.

  • Approve more than a transaction needs. Leaving a loan to roll by itself is the one standing approval, and its plan says so.

Defaults

  • Robinhood Chain (4663) since 0.6.0, with real money. The testnet is network: "testnet", or GAGE_NETWORK=testnet for gage-mcp.

  • Every step is simulated before it is sent, and a refusal comes as a fixed code (TERM_NOT_ALLOWED, INSUFFICIENT_BALANCE, …), listed in each package's README.

  • gage-mcp signs under its spend limits unless its owner lifts them.

Examples

packages/sdk/examples and packages/mcp/examples, typechecked and tested in CI, every action they ask for checked against the schema the SDK takes:

Example

What it shows

reads.ts, quote.ts

The market, a wallet, a loan, a quote. Reads only.

borrow.ts

One click at the lowest fixed cost, the exact quote, a loop, a refusal's minimum.

loan.ts

Repay, roll over, roll over by itself, cash out.

deposit.ts, exit-now.ts

A deposit into a partner vault; a withdrawal, exit now and collecting what it paid.

put.ts, lp.ts, park.ts

Puts, the LP lane, park and unpark.

generations.ts

Every asset gage lends, and a loan paid out in one.

sign-yourself.ts, spend-limit.ts

Signing each prepared step with any wallet; a spend limit for an agent.

agent-tools.ts, hosted-review.ts, stdio-client.ts

Tools for your own agent framework, gage's hosted service and its review links, gage-mcp over stdio.

Run one from packages/sdk after pnpm install && pnpm build: npx tsx examples/quote.ts NVDA.

Docs and changes

Develop

Node 22 or later and pnpm 9:

pnpm install
pnpm build
pnpm typecheck
pnpm lint
pnpm test

How this repository is kept

gage's main repository, where the contracts, the app and gage's services live, is the source of these two packages. Each release is copied here as one commit, and npm's copy is published from this repository with provenance. Issues and pull requests are welcome: see CONTRIBUTING.md.

Asking gage for something

  • A token gage should accept: List a token.

  • An integration, a Rates API key, or your site's origin for browser access to the rates service: Integrate with gage. A key is sent to your private contact, never posted in an issue.

  • Help with a loan, a deposit or the app: support. The docs: docs.gage.cash.

Security

Report a vulnerability privately, never in an issue or a pull request: see SECURITY.md. Both packages are in scope of gage's bug bounty.

License

MIT

Related MCP Connectors

Related MCP Servers

  • A
    license
    Not graded
    quality
    A
    maintenance
    Enables AI agents to manage API keys and child keys with budgets and spending caps, set plans and model routing, handle wallet payments and top-ups, and verify signed receipts through MCP tools.
    265 npm
    2
    MIT
  • A
    license
    Not graded
    quality
    B
    maintenance
    Enables agents to propose policy-gated treasury payments and swaps, check pending human approvals, read transaction receipts, and locally verify their integrity through MCP tools.
    MIT
  • A
    license
    Not graded
    quality
    B
    maintenance
    Exposes agent-enabled local self-custody wallets to any MCP client, letting agents list wallets, read policies and balances, review spend history, and send native coins or tokens under enforced per-transaction and rolling 24-hour limits. No key or mnemonic ever crosses the tool boundary.
    MIT