mcp-server-justlend
OfficialAn MCP server that lets AI agents interact with the JustLend DAO lending protocol on TRON — supplying, borrowing, managing positions, participating in V2 Moolah isolated markets and vaults, analyzing portfolios — plus general TRON chain utilities.
JustLend V1 lending: supply, withdraw, borrow, repay, enter/exit collateral markets, check allowances, claim mining rewards, estimate energy/bandwidth costs.
Market & account data: live APY/TVL/utilization for all markets, protocol summary, detailed account positions with health factor, batch wallet token balances, mining reward breakdowns.
JST governance: view proposals, check voting power and vote status, approve/deposit JST, cast votes, withdraw votes from completed proposals.
Energy services: energy rental market dashboard, on-chain rental parameters, rental price calculation, rent/return energy, plus direct energy purchase with quotes, orders, history, and payment-risk reconciliation.
sTRX staking: stake TRX to sTRX, unstake, claim rewards, check withdrawal eligibility, view dashboard and account info.
TRX ↔ WTRX wrap/unwrap: convert between native TRX and WTRX at 1:1.
JustLend V2 (Moolah) vaults: list vaults, deposit/withdraw/redeem ERC4626 vault shares, approve vault spending, view vault APY/TVL/history/mining APY.
JustLend V2 (Moolah) markets: list/detail isolated markets, supply/withdraw collateral, borrow/repay, get user positions and risk ratios, approve proxy spending.
Moolah liquidations: list pending liquidations, get liquidation quotes, execute public liquidations, approve liquidator token, view liquidation records.
Moolah dashboard & history: aggregated V2 portfolio, time-series APY/TVL, paginated transaction records, mining accrual/claimable airdrop rounds and on-chain claims.
Historical records (mainnet): paginated V1 lending, sTRX staking, voting, energy rental, liquidation history, and claimable V1 airdrops.
General TRON chain tools: TRX/TRC20/TRC1155 balances, block/transaction queries, contract read/write/deploy, multicall, token metadata, TRX/TRC20 transfers, Stake 2.0 freeze/unfreeze/withdraw, address conversion/validation.
Wallet management: choose browser or agent signing, list/switch wallets, get wallet address/mode/network; browser mode is currently disabled for safety.
Flexible transports: stdio for local MCP clients (Claude Desktop, Codex, Claude Code, Cursor) and authenticated HTTP/SSE for remote/multi-client use.
Supports jBTC and jWBTC tokens on the JustLend lending protocol, enabling supply, borrow, and position management for Bitcoin assets.
Supports BTT token on the JustLend lending protocol, enabling supply, borrow, and position management for BitTorrent assets.
Supports jETH and jETHB tokens on the JustLend lending protocol, enabling supply, borrow, and position management for Ethereum assets.
Supports USDT token on the JustLend lending protocol, enabling supply, borrow, and position management for Tether USD assets.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@mcp-server-justlendwhat's my current health factor on JustLend?"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
mcp-server-justlend
A Model Context Protocol (MCP) server that enables AI agents to interact with the JustLend DAO lending protocol on TRON. Supply assets, borrow against collateral, manage positions, participate in V2 (Moolah) isolated markets and vaults, and analyze DeFi portfolios — all through a unified AI interface.
Beyond JustLend-specific operations, the server also exposes a full set of general-purpose TRON chain utilities — balance queries, block/transaction data, token metadata, TRX transfers, smart contract reads/writes, staking (Stake 2.0), multicall, and more.
Overview
JustLend DAO is the largest lending protocol on TRON. This MCP server wraps the full protocol functionality into tools and guided prompts that local MCP clients such as Claude Desktop, Codex, Claude Code, and Cursor can use.
📌 Current Version: v1.1.3 — JustLend V1 + V2 (Moolah), plus TRX↔WTRX wrap/unwrap
JustLend V1 (Compound V2 fork): the original pool-based protocol —
jUSDT,jTRX,jUSDD,jSUN,jWBTC, etc. Full supply / borrow / repay / withdraw / collateral management and mining rewards.JustLend V2 (Moolah) (Morpho Blue fork): isolated markets with
MarketParams (loanToken, collateralToken, oracle, irm, lltv)and ERC4626 vaults that auto-allocate across markets. Full vault deposit / redeem, collateral supply / borrow / repay / liquidate, and public liquidations.
Key Capabilities
JustLend V1 (pool-based, Compound V2 fork)
Market Data: Real-time APYs, TVL, utilization rates, prices for all markets
Smart fallback: contract queries first, API fallback for reliability
TTL caching (30–60s) to reduce RPC calls
Account Data: Full position analysis via Multicall3 batch queries (~2.5s vs ~8s legacy)
Health factor, collateral, borrow positions
On-chain Oracle prices with API fallback
Batch Wallet Balances: Query all TRC20 token balances in a single Multicall3 RPC call
Mining Rewards: Advanced mining reward calculation (based on justlend-app logic)
Detailed breakdown by market and reward token (USDD, TRX, WBTC, etc.)
USD value calculation with live token prices
Supply / Borrow / Repay / Withdraw: Full lending operations with pre-flight checks
Collateral Management: Enter/exit markets, manage what counts as collateral
Portfolio Analysis: AI-guided risk assessment, health factor monitoring, optimization
JST Voting / Governance: View proposals, cast votes, deposit/withdraw JST for voting power, reclaim votes
Energy Rental + Direct Purchase: Rent energy on-chain, or query/quote/buy energy through the separately configured direct-purchase service
sTRX Staking: Stake TRX to receive sTRX, unstake sTRX, claim staking rewards, check withdrawal eligibility
Precision-safe BigInt/string math for TRX Sun conversion and 18-decimal sTRX balances/exchange-rate display
JustLend V2 — Moolah (New in v1.1.0)
ERC4626 Vaults (TRX / USDT / USDD on mainnet; TRX + USDT on nile): auto-compounding yield with a curator that allocates deposits across isolated markets. Deposit / withdraw (by asset amount or
max) / redeem (by shares) with TRC20 approvals handled as a separate tool so LLMs can reason about each step.Isolated Markets: each market is a
(loanToken, collateralToken, oracle, irm, lltv)tuple. Supply collateral → borrow → repay → withdraw collateral, plus a compositemoolah_borrowthat handles collateral+borrow as two sequential txs. TRX routes through theTrxProviderProxycontract; TRC20 goes throughMoolahProxydirectly.Public Liquidations: list undercollateralized positions (
risk > 1.0), quote loan-token requirement for a target seize, execute liquidation. Includes an explicitapprove_liquidator_tokenstep.Dashboard + History: aggregated user position, APY / TVL time-series for vaults and markets, paginated V2 transaction records.
Gas estimation:
estimate_moolah_energyreturns typical historical energy / bandwidth / TRX cost for every V2 write op.
Historical records (New in v1.1.0)
Paginated REST wrappers for V1 lending / sTRX / voting / energy-rental / liquidation history, plus V2 Moolah records. Each endpoint's numeric action/op codes are enriched with human-readable names (
actionName/opName) client-side so MCP tools are self-describing.
Browser Wallet Signing
Disabled by default: the legacy
tronlink-signerloopback bridge lacks request-level authenticationSafe current mode: use agent-wallet with
AGENT_WALLET_PASSWORD; browser signing will return only after an authenticated bridge is available
General TRON Chain
Balances: TRX balance (with Sun/TRX conversion), TRC20/TRC1155 token balances
Blocks: Latest block, block by number/hash, block number, chain ID
Transactions: Fetch transaction details, receipts, wait for confirmation
Contracts: Read/write any contract, fetch on-chain ABI, multicall (v2 & v3), deploy, estimate energy
Token Metadata: TRC20 info (name/symbol/decimals/supply), TRC721 metadata, TRC1155 URI
Transfers: Send TRX, transfer TRC20 tokens, approve spenders
Transfer/approval paths validate recipient, token, and spender TRON addresses before signing
Staking (Stake 2.0): Freeze/unfreeze TRX for BANDWIDTH or ENERGY, withdraw expired unfreeze
Address Utilities: Hex ↔ Base58 conversion, address validation, resolution
Wallet: Sign messages and transactions through agent-wallet; the unauthenticated browser bridge is disabled
Related MCP server: Kaskad Protocol MCP Server
Supported Markets
JustLend V1 (pool-based)
The protocol currently exposes 18 active + 6 legacy = 24 markets. This roster was cross-checked against the expanded JustLend app market table and live /lend/jtoken API on 2026-08-19. Call get_supported_markets for the live list with addresses; the active markets are:
jToken | Underlying | Description |
jTRX | TRX | Native TRON token |
jUSDT | USDT | Tether USD |
jUSDD | USDD | Decentralized USD (USDD/TRX supply‑mining rewards) |
jUSD1 | USD1 | World Liberty Financial USD |
jTUSD | TUSD | TrueUSD |
jwstUSDT | wstUSDT | Wrapped staked USDT (yields underlying staking APY) |
jsTRX | sTRX | Staked TRX (yields underlying staking APY) |
jBTC | BTC | Bitcoin (wrapped) |
jWBTC | WBTC | Wrapped Bitcoin |
jETH | ETH | Ethereum — dApp UI displays as "ETH" (formerly "ETHOLD") |
jETHB | ETHB | Bridged Ethereum — dApp UI displays as "ETHB" (formerly "ETH") |
jSUN | SUN | SUN token |
jJST | JST | JUST governance token |
jWIN | WIN | WINkLink |
jBTT | BTT | BitTorrent token |
jNFT | NFT | APENFT |
jHTX | HTX | HTX token |
jU | U | U token |
Paused / legacy markets (closed to new supply/borrow, queryable for read & to unwind positions): jUSDCOLD, jUSDD_OLD, jBUSDOLD, jSUNOLD, jUSDJ, jWBTT.
JustLend V2 (Moolah) — vaults
Vault | Underlying | Mainnet | Nile |
TRX | native TRX | ✅ | ✅ |
USDT | TRC20 USDT | ✅ | ✅ (different underlying address from mainnet) |
USDD | TRC20 USDD | ✅ | ❌ (not deployed on nile) |
Markets are not enumerated here because they are created dynamically on-chain; use get_moolah_markets to list them at runtime (each market returns a marketId / id plus loanSymbol / collateralSymbol / lltv / rates).
Prerequisites
Node.js 20.0.0 or higher
Optional: TronGrid API key for reliable mainnet access (strongly recommended)
Installation
git clone https://github.com/justlend/mcp-server-justlend.git
cd mcp-server-justlend
npm installQuick Setup
For a guided setup experience (build, configure, generate .mcp.json, print Codex setup command):
bash scripts/setup-mcp-test.sh
# Add --claude-desktop to also print Claude Desktop JSONThe script checks Node.js 20+, installs dependencies, builds the project, generates local Claude Code config, and prints the local Codex registration command.
Configuration
Wallet Setup (First-Use Choice)
On first use, select agent mode via set_wallet_mode with mode="agent".
Browser mode is disabled until its local bridge supports request-level authentication.
The encrypted wallet is stored in ~/.agent-wallet/. Configure AGENT_WALLET_PASSWORD
so its encryption password is not persisted beside the wallet data.
You can also manage wallets via CLI or MCP tools:
CLI (agent-wallet)
# Import an existing private key or mnemonic
npx agent-wallet add
# Generate a new wallet
npx agent-wallet generate
# List all wallets
npx agent-wallet list
# Switch active wallet
npx agent-wallet activate <wallet-id>MCP Tools (runtime)
Tool | Description |
| Shows current address, or returns first-use wallet selection guidance |
| Returns a safety notice while the unauthenticated browser bridge is disabled |
| Select supported |
| Show current signing mode and addresses |
| List all wallets with IDs, types, addresses |
| Switch active wallet by ID |
Importing an existing private key is intentionally not exposed as an MCP tool because MCP arguments can be logged by clients and transports. Use the CLI instead:
npx agent-wallet import# (Optional) For automated/CI setups, set the wallet password
export AGENT_WALLET_PASSWORD="your_wallet_password"
# Strongly recommended — avoids TronGrid 429 rate limiting on mainnet
export TRONGRID_API_KEY="your_trongrid_api_key"Energy direct-purchase API
Direct purchase uses the official production endpoint from the app release by default:
https://tegrow.ablesdxd.link. Limits, durations, prices, payment address, and pool capacity are still
loaded live; no economic values are hard-coded. Set JUSTLEND_ENERGY_API_URL only to override the
production service. Custom/test endpoints require an explicit trust opt-in:
export JUSTLEND_ENERGY_API_URL="https://energy-api.example" # optional override
export JUSTLEND_ALLOW_UNTRUSTED_HOSTS=1 # temporary/custom endpoints onlyRecommended tool sequence:
get_energy_purchase_config— load live limits, durations, prices, and pool capacity.quote_energy_purchase— obtain an authoritative read-only quote.Show the exact payer, receivers, duration, and TRX amount to the user.
buy_energy_direct— setconfirmPayment=trueonly after explicit user confirmation.get_energy_purchase_order— track a token-bearing result.get_energy_purchase_history— recover accepted/in-progress orders by payer when a retry has no token.get_energy_payment_risk— reconcile any remaining ambiguous payment before signing again.
The server signs the native TRX payment but never broadcasts it locally. The configured backend
validates and may broadcast the signed transaction. Ambiguous submissions retry only the same signed
transaction. For ambiguous submissions, the exact signed request (including the signature and raw
transaction) is stored locally with 0600 permissions under
~/.mcp-server-justlend/energy-payment-risks.json. It remains broadcastable until transaction expiry,
is redacted from MCP output, and is removed only after public purchase history confirms the payment/order
or the backend deterministically rejects it before broadcast. Use get_energy_payment_risk before any
new payment when a previous result is uncertain. Risk reconciliation reports chainStatus as
observed/included from FullNode first and solidified only after SolidityNode finality; RPC
errors or a missing transaction never authorize a newly signed payment.
Client Configuration
Build the local server first:
npm run buildAll local client examples below use the built stdio entrypoint:
node /absolute/path/to/mcp-server-justlend/build/index.jsClaude Desktop
Add to ~/Library/Application Support/Claude/claude_desktop_config.json:
{
"mcpServers": {
"justlend": {
"command": "node",
"args": ["/absolute/path/to/mcp-server-justlend/build/index.js"],
"env": {
"TRONGRID_API_KEY": "SET_VIA_SYSTEM_ENV"
}
}
}
}Codex
Recommended: register the local stdio server with codex mcp add:
codex mcp add justlend --env TRONGRID_API_KEY=your_trongrid_api_key -- \
node /absolute/path/to/mcp-server-justlend/build/index.jsIf you do not want to set a TronGrid key yet, omit the --env flag:
codex mcp add justlend -- node /absolute/path/to/mcp-server-justlend/build/index.jsUseful maintenance commands:
codex mcp list
codex mcp get justlend
codex mcp remove justlendClaude Code
Add to .mcp.json in the project root:
{
"mcpServers": {
"justlend": {
"command": "node",
"args": ["/absolute/path/to/mcp-server-justlend/build/index.js"],
"env": {
"TRONGRID_API_KEY": "SET_VIA_SYSTEM_ENV"
}
}
}
}Cursor
Add to .cursor/mcp.json:
{
"mcpServers": {
"justlend": {
"command": "node",
"args": ["/absolute/path/to/mcp-server-justlend/build/index.js"],
"env": {
"TRONGRID_API_KEY": "SET_VIA_SYSTEM_ENV"
}
}
}
}Usage
The server supports two transport modes. Both share the same Tools, Resources, and wallet initialization — the difference is how clients connect.
Stdio Mode (Local AI Clients)
npm startThe server communicates via stdin/stdout. This is the standard mode for local MCP clients like Claude Desktop, Codex, Claude Code, and Cursor, which launch the server as a child process.
HTTP/SSE Mode (Remote / Multi-Client)
MCP_API_KEY=my-secret-key npm run start:httpThe server starts an Express HTTP service with Server-Sent Events (SSE) transport. Suitable for web applications, remote clients, or scenarios where multiple clients need to connect concurrently.
HTTP mode is fail-closed: MCP_API_KEY is required, the server binds to 127.0.0.1 by default, and CORS is disabled unless you explicitly set MCP_CORS_ORIGIN.
Endpoint | Method | Description |
| GET | SSE connection endpoint — returns a |
| POST | Send MCP messages for a session |
| GET | Health check (no auth required) |
Environment variables:
Variable | Default | Description |
|
| HTTP listen port |
|
| HTTP listen host. Keep the default unless you intentionally want remote exposure. |
| (required) | Bearer token for authentication. HTTP mode refuses to start without it. |
| (disabled) | Allowed CORS origin. If unset, no CORS headers are sent. |
|
| Maximum concurrent SSE sessions |
|
| Session idle timeout in ms (default: 30 min) |
Example with authentication:
MCP_API_KEY=my-secret-key PORT=8080 npm run start:http# Connect from client
curl -H "Authorization: Bearer my-secret-key" http://localhost:8080/sseDevelopment
npm run dev # Stdio with auto-reload
npm run dev:http # HTTP/SSE with auto-reloadAPI Reference
Machine-readable tool catalog for AI agents:
mcp-api-list.md— a complete, offline-loadable list of every tool with its input schema (parameter / type / required / default), common output schema, MCP side-effect annotations (read-only vs. on-chain write / destructive) and HITL guidance. It is generated from source (npm run gen:api-list, seescripts/gen-mcp-api-list.ts) so it never drifts from the actual tool definitions. Agents can load it to plan tool routing without connecting to the server.
Structured output contract
All 104 tools declare an MCP outputSchema. Successful calls preserve the existing text content for older clients and also return a versioned envelope in structuredContent:
{
"schemaVersion": "1.0.0",
"tool": "get_supported_markets",
"result": {}
}Schema-aware clients should consume structuredContent; consumers should pin the schema major. Tool-specific payloads live under result. Error calls preserve isError: true and the existing JSON error body with errorCode, retryable, and hint when classified.
Tools (104 total)
The full, authoritative per-tool catalog — every tool's input and output schema, side-effect class (read-only / on-chain write / destructive) and HITL guidance — lives in mcp-api-list.md, generated from source (npm run gen:api-list) so it never drifts. Counts by category:
Category | Tools | Covers |
Wallet & Network | 10 | wallet selection, signing mode (browser/agent), active wallet, network |
Market Data | 13 | per-market & protocol APY/TVL/rates (contract query + API fallback) |
Lending Operations | 10 | supply / borrow / repay / withdraw / collateral / approve (V1 jTokens) |
JST Voting / Governance | 10 | proposals, vote status, WJST approve / vote / withdraw |
Energy | 15 | rental dashboard and writes; direct-purchase config, quote, history, order/risk, confirmed buy |
sTRX Staking | 7 | sTRX dashboard & account, stake / unstake / claim / withdraw |
WTRX Wrap / Unwrap | 2 |
|
JustLend V2 (Moolah) — Vaults | 6 | ERC4626 vault read + deposit / withdraw / redeem / approve |
JustLend V2 (Moolah) — Markets | 8 | isolated markets: supply-collateral / borrow / repay / approve |
JustLend V2 (Moolah) — Liquidation | 5 | pending liquidations, quote, liquidate, approve |
JustLend V2 (Moolah) — Dashboard & History | 6 | portfolio, positions, dashboard & history |
JustLend V2 (Moolah) — Mining, Rewards & Estimator | 5 | mining APY / accrual, claim, gas estimate |
Historical Records (V1 + airdrop) — mainnet-only | 7 | transaction / vote / reward history, claimable airdrops |
Every write / destructive tool is marked destructiveHint: true and must be gated behind host-side human confirmation (HITL); see mcp-api-list.md for the exact per-tool side-effect class.
Architecture
mcp-server-justlend/
├── src/
│ ├── core/
│ │ ├── chains.ts # Network configs + V1 jTokens + V2 Moolah addresses (mainnet + nile)
│ │ ├── abis.ts # jToken, Comptroller, Oracle, TRC20 + 4 Moolah ABIs
│ │ ├── tools/ # MCP tool registrations (104 tools)
│ │ │ ├── index.ts # Barrel: registers all 13 tool modules with structured outputs
│ │ │ ├── wallet-tools.ts # Wallet, network, transfer
│ │ │ ├── market-tools.ts # V1 market data, balance, mining
│ │ │ ├── lending-tools.ts # V1 supply / borrow / repay / collateral / approve / estimate
│ │ │ ├── voting-tools.ts # V1 governance proposals & voting
│ │ │ ├── energy-tools.ts # Energy rental + direct purchase
│ │ │ ├── staking-tools.ts # sTRX staking
│ │ │ ├── wtrx-tools.ts # TRX ↔ WTRX
│ │ │ ├── moolah-vault-tools.ts # V2 vault (6 tools)
│ │ │ ├── moolah-market-tools.ts # V2 market (8 tools)
│ │ │ ├── moolah-liquidation-tools.ts # V2 liquidation (5 tools)
│ │ │ ├── moolah-dashboard-tools.ts # V2 dashboard + history + estimator (6 tools)
│ │ │ ├── moolah-mining-tools.ts # V2 mining / rewards (5 tools)
│ │ │ ├── records-tools.ts # V1 + airdrop records (7 tools, mainnet-only)
│ │ │ ├── structured-output.ts # Common MCP outputSchema + structuredContent
│ │ │ └── shared.ts # Shared helpers
│ │ ├── prompts.ts # AI-guided workflow prompts (14: 10 V1-era + 4 V2 Moolah)
│ │ ├── resources.ts # Static protocol info resource
│ │ ├── browser-signer.ts # fail-closed compatibility shim; legacy bridge disabled
│ │ └── services/
│ │ ├── # — Global + utilities —
│ │ ├── global.ts # Global state: network, wallet mode
│ │ ├── clients.ts # TronWeb client factory (cached)
│ │ ├── wallet.ts # Wallet routing: browser / agent-wallet signing
│ │ ├── cache.ts # TTL cache layer (30–60s) for prices, markets, sTRX
│ │ ├── http.ts # fetchWithTimeout
│ │ ├── utils.ts # toSun/fromSun, formatJson, hexToNumber, isAddress, …
│ │ ├── bigint-math.ts# BigInt helpers: divRound, formatPercentRatio, USD cent math
│ │ ├── resource-prices.ts # Energy / bandwidth prices in sun
│ │ ├── # — JustLend V1 —
│ │ ├── price.ts # On-chain Oracle prices with API fallback
│ │ ├── markets.ts # APY, TVL, utilization — contract + API fallback
│ │ ├── account.ts # User positions via Multicall3 batch queries
│ │ ├── lending.ts # V1 supply / borrow / repay / withdraw / collateral / estimator
│ │ ├── rewards.ts # Mining reward calculation (USDD, TRX, WBTC)
│ │ ├── voting.ts # JST governance: proposals, cast vote, deposit/withdraw WJST
│ │ ├── energy-rental.ts # Energy rental: query, calculate, rent, return
│ │ ├── energy-purchase.ts # Explicit API client, sign-only payment, idempotent submit, risk recovery
│ │ ├── strx-staking.ts # sTRX staking: stake, unstake, rewards, withdrawal check
│ │ ├── records.ts # V1 + cross-cutting paginated REST history + airdrop scan
│ │ ├── # — JustLend V2 (Moolah) —
│ │ ├── moolah-backend.ts # REST wrapper for zenvora.ablesdxd.link
│ │ ├── moolah-query.ts # On-chain view reads (market state, vault totalAssets, health, etc.)
│ │ ├── moolah-vault.ts # Vault write ops (deposit / withdraw / redeem / approve)
│ │ ├── moolah-market.ts # Market write ops (supply collateral / borrow / repay / composite)
│ │ ├── moolah-liquidation.ts# liquidate + approveLiquidatorToken
│ │ ├── moolah-dashboard.ts # Aggregated dashboard + history helpers
│ │ ├── moolah-estimate.ts # Typical energy / bandwidth for all V2 write ops
│ │ ├── # — General TRON chain —
│ │ ├── address.ts # Hex ↔ Base58 conversion, validation
│ │ ├── balance.ts # TRX balance (rich), TRC20/TRC1155 balances
│ │ ├── blocks.ts # Block queries, block number, chain ID
│ │ ├── transactions.ts# getTransaction, getTransactionInfo, waitForTransaction
│ │ ├── transfer.ts # transferTRX, transferTRC20, approveTRC20
│ │ ├── tokens.ts # TRC20/TRC721/TRC1155 metadata
│ │ ├── contracts.ts # readContract, writeContract, multicall, estimateEnergy + callValueToSafeNumber
│ │ ├── multicall-abi.ts # Multicall2 & Multicall3 ABIs
│ │ └── staking.ts # Stake 2.0: freeze, unfreeze, withdrawExpireUnfreeze
│ ├── server/
│ │ ├── server.ts # MCP server init
│ │ ├── http-server.ts # Express HTTP/SSE transport (uses auth.ts for Bearer check)
│ │ └── auth.ts # Constant-time Bearer-token comparison (crypto.timingSafeEqual)
│ └── index.ts # Stdio entry point
├── bin/cli.js # CLI entry for npx
├── scripts/
│ └── setup-mcp-test.sh # Quick setup: build + generate .mcp.json config
└── tests/
└── core/
├── chains.test.ts
└── services/
├── services.test.ts # Client cache, legacy balance tests
├── address.test.ts # Pure: address format conversion (16 tests)
├── utils.test.ts # Pure: unit conversions, formatters (26 tests)
├── cache.test.ts # Unit: TTL cache behavior
├── price.test.ts # Unit: price service fallback logic
├── markets-fallback.test.ts # Unit: market data fallback chain
├── strx-fallback.test.ts # Unit: sTRX dashboard fallback
├── account-multicall.test.ts # Unit: Multicall3 account queries
├── balance.test.ts # Integration: TRX & TRC20 balances
├── blocks.test.ts # Integration: block queries
├── contracts.test.ts # Mixed: pure ABI helpers + integration reads
├── tokens.test.ts # Integration: TRC20 token metadata
├── transactions.test.ts # Integration: transaction fetch
├── transfer.test.ts # Write: skipped by default (TEST_TRANSFER=1)
├── staking.test.ts # Write: skipped by default (TEST_STAKING=1)
├── energy-rental.test.ts # Integration: energy rental queries; Write: skipped (TEST_ENERGY_RENTAL=1)
├── strx-staking.test.ts # Integration: sTRX queries; Write: skipped (TEST_STRX_STAKING=1)
└── wallet.test.ts # Unit: agent-wallet integration testsTesting
# Run all tests (pure/unit tests always pass; integration tests need network)
npm test
# Run individual test files (recommended to avoid TronGrid rate limits)
npx vitest run tests/core/services/utils.test.ts
npx vitest run tests/core/services/address.test.ts
npx vitest run tests/core/services/balance.test.ts
npx vitest run tests/core/services/blocks.test.ts
npx vitest run tests/core/services/contracts.test.ts
npx vitest run tests/core/services/transactions.test.ts
npx vitest run tests/core/services/tokens.test.ts
# Energy rental & sTRX staking read tests
npx vitest run tests/core/services/energy-rental.test.ts
npx vitest run tests/core/services/strx-staking.test.ts
# Enable write/staking tests (uses real funds — use Nile testnet!)
# Requires agent-wallet to be configured: npx agent-wallet start
TEST_TRANSFER=1 npx vitest run tests/core/services/transfer.test.ts
TEST_STAKING=1 npx vitest run tests/core/services/staking.test.ts
TEST_ENERGY_RENTAL=1 npx vitest run tests/core/services/energy-rental.test.ts
TEST_STRX_STAKING=1 npx vitest run tests/core/services/strx-staking.test.ts
# Moolah V2 end-to-end write-path test on nile (vault deposit/withdraw +
# market supply-collateral/borrow/repay). Requires a funded nile wallet:
# see forTest/docs/v1.1.0/nile-write-path-runbook.md for the runbook.
TEST_MOOLAH_WRITE=1 npx vitest run tests/integration/moolah-writes.nile.test.tsRate limiting: Integration tests make real RPC calls to TronGrid. Without
TRONGRID_API_KEYthe free tier limits to a few requests per second. Run test files individually, or setTRONGRID_API_KEYto avoid 429 errors.
Troubleshooting
Symptom | Likely cause | Fix |
MCP client doesn't list any tools (stdio) | Server not launched, or wrong command/path in client config | Verify the client |
| TronGrid free-tier rate limit | Set |
HTTP/SSE returns | Missing/wrong | HTTP mode is fail-closed: set |
Server refuses to start: | HTTP/SSE transport started without an API key | Set |
| Concurrent SSE sessions exceed | Close idle clients or raise |
Write tool errors with "no wallet" / wallet selection guide | No wallet mode chosen yet | Run |
Write tool fails with a pre-flight | The transaction would revert on-chain (fail-closed by design) | Read the returned revert reason; fix the precondition (e.g. call |
| TRC20 allowance below the amount | Call |
Wrong network / unexpected addresses | Active network not set as intended | Check with |
Amounts look off by 6–18 orders of magnitude | Double-applying token | Balance/amount tool outputs are already human-readable (decimals applied) and carry |
For deeper inspection, run the server under the MCP Inspector and watch stderr — startup diagnostics, auth failures, and schema errors are logged there (stdout is reserved for the MCP protocol frames in stdio mode).
Security Considerations
Private keys are managed by @bankofai/agent-wallet — never stored in environment variables or exposed via MCP tools
Wallet encryption: Keys are stored in
~/.agent-wallet/with password-based encryptionWrite operations are clearly marked with
destructiveHint: truein MCP annotationsTransaction summaries before signing: contract write paths pass signer-facing summaries with network, contract, function, arguments, callValue, feeLimit, and simulation status
Address validation before signing: transfer and approval services reject invalid recipient/token/spender addresses before contract loading or wallet signing
Precision-safe value handling: sTRX staking uses string/BigInt parsing for TRX Sun conversion and 18-decimal sTRX display/estimates
Self-describing amounts: balance/amount fields return human-readable values with explicit
_unit+decimals(andrawwhere applicable) so agents never re-apply decimals or misjudge magnitude. New tools should build amounts withdescribeAmount(raw, decimals, unit)fromcore/services/bigint-math.ts.Health factor checks in prompts prevent dangerous borrowing
Always test on Nile testnet before mainnet operations
Be cautious with unlimited approvals (
approve_underlyingwithmax)
Example Conversations
"What are the best supply rates on JustLend right now?"
→ AI calls get_all_markets, sorts by supplyAPY, presents ranking
"I want to supply 10,000 USDT to earn interest"
→ AI uses supply_assets prompt: checks balance → approves USDT → supplies → verifies
"Am I at risk of liquidation?"
→ AI calls get_account_summary, analyzes health factor, warns if < 1.5
"Borrow 500 USDT against my TRX collateral"
→ AI uses borrow_assets prompt: checks collateral → calculates new health factor → executes if safe
"What is the TRX balance of address TXxx...?" → AI calls the general-purpose TRX balance tool, returns balance in both TRX and Sun
"Freeze 100 TRX for ENERGY" → AI calls staking service to freeze via Stake 2.0, returns transaction hash
"Show me the latest governance proposals"
→ AI calls get_proposal_list, displays proposals sorted by ID with status and vote counts
"I want to vote for proposal #425 with 1000 JST"
→ AI checks get_vote_info → if no votes, suggests approve_jst_for_voting + deposit_jst_for_votes → then cast_vote
"Withdraw my votes from completed proposals"
→ AI calls get_user_vote_status to find withdrawable proposals → calls withdraw_votes_from_proposal for each
"How much does it cost to rent 300,000 energy for 7 days?"
→ AI calls calculate_energy_rental_price with energyAmount=300000, durationHours=168, returns cost breakdown
"Rent 500,000 energy to address TXxx... for 14 days"
→ AI uses rent_energy prompt: checks balance → checks rental status → calculates price → rents energy → verifies
"Cancel my energy rental to TXxx..."
→ AI calls get_energy_rent_info to verify active rental → calls return_energy_rental → confirms refund
"Stake 1000 TRX to earn sTRX rewards"
→ AI uses stake_trx prompt: checks balance → checks exchange rate & APY → stakes TRX → verifies sTRX received
"Do I have any sTRX rewards to claim?"
→ AI calls get_strx_account to check claimable rewards → calls claim_strx_rewards if available
"Can I withdraw my unstaked TRX?"
→ AI calls check_strx_withdrawal_eligibility to check unbonding status and completed withdrawal rounds
"Deposit 500 USDT into the JustLend V2 vault" (Moolah)
→ AI uses moolah_supply prompt: lists vaults with APY → selects USDT → checks allowance → calls approve_moolah_vault → calls moolah_vault_deposit → verifies shares via get_moolah_vault
"What's my risk on the TRX→USDT market?" (Moolah)
→ AI calls get_moolah_user_position for the market, interprets the risk ratio (0–1 where 1.0 = liquidatable), warns at >0.85
"Find me a liquidation opportunity" (Moolah)
→ AI calls get_moolah_pending_liquidations with minRiskLevel=1.0 → for a target, calls get_moolah_liquidation_quote → estimates profit → if viable, guides through approve_liquidator_token + moolah_liquidate
"How much did I supply to JustLend in the last month?"
→ AI calls get_lending_records paginated and filters action type 1 (supply) from the returned actionName
Changelog
See CHANGELOG.md for the per-version history (Keep a Changelog format, SemVer).
License
MIT License Copyright (c) 2026 JustLend SPDX-License-Identifier: MIT
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceA comprehensive MCP server providing unified access to over 144 tools for lending, trading, and staking across six major DeFi protocols on the Stacks Bitcoin Layer 2. It enables AI agents to perform complex blockchain operations and interact with the DeFi ecosystem using natural language commands.3
- FlicenseNot gradedqualityDmaintenanceFirst-party MCP server for Kaskad Protocol — a DeFi lending protocol on Igra L2 (Kaspa). Enables AI agents to autonomously supply, borrow, repay, withdraw, and stake. Includes 16 tools covering live market reads, governance params, health factor monitoring, emission state, and full write access to on-chain lending operations. Compatible with Claude, OpenClaw, and any MCP-compatible client.
- AlicenseBqualityBmaintenanceA comprehensive MCP server that enables AI agents to interact with the TRON blockchain, including tools for blockchain data, token transfers, smart contracts, staking, and wallet management.972315MIT
- AlicenseCqualityDmaintenanceMCP server for TRON blockchain integration, enabling AI assistants to check balances, manage transactions, interact with smart contracts, and access real-time blockchain data.331MIT
Related MCP Connectors
TRON Energy marketplace + DEX swap aggregator for AI agents. 27 MCP tools.
TRON energy exchange for AI agents. 54 tools, 30 prompts, 21 resources. A2A + ACP.
MCP server for Gainium — manage trading bots, deals, and balances via AI assistants
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
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/justlend/mcp-server-justlend'
If you have feedback or need assistance with the MCP directory API, please join our Discord server