Floe Working Capital

Gives AI agents (Claude, Cursor, custom) full access to working capital to pay x402 receipts.

@floelabs/mcp-server

npm version License: MIT Base Mainnet

MCP server for the Floe credit protocol. Gives AI agents (Claude, Cursor, custom) full access to DeFi lending on Base.

Quick Start

Option 1: Remote (recommended)

Point your MCP client directly at the hosted endpoint — no installation needed.

Claude Desktop / Claude Code:

{
  "mcpServers": {
    "floe": {
      "url": "https://mcp.floelabs.xyz/mcp",
      "headers": {
        "Authorization": "Bearer floe_live_YOUR_API_KEY"
      }
    }
  }
}

Option 2: Local via npx

Run the server locally. It proxies all requests to the Floe API.

FLOE_API_KEY=floe_live_YOUR_API_KEY npx @floelabs/mcp-server

Claude Desktop config:

{
  "mcpServers": {
    "floe": {
      "command": "npx",
      "args": ["@floelabs/mcp-server"],
      "env": {
        "FLOE_API_KEY": "floe_live_YOUR_API_KEY"
      }
    }
  }
}

Cursor config (.cursor/mcp.json):

{
  "mcpServers": {
    "floe": {
      "command": "npx",
      "args": ["@floelabs/mcp-server"],
      "env": {
        "FLOE_API_KEY": "floe_live_YOUR_API_KEY"
      }
    }
  }
}

Option 3: Install globally

npm install -g @floelabs/mcp-server
FLOE_API_KEY=floe_live_YOUR_API_KEY floe-mcp

Get an API Key

  1. Go to dev-dashboard.floelabs.xyz
  2. Connect your wallet
  3. Create an API key — you'll get a floe_live_... key

Environment Variables

VariableRequiredDefaultDescription
FLOE_API_KEYYesYour Floe API key (floe_live_...)
FLOE_API_BASE_URLNohttps://credit-api.floelabs.xyzAPI endpoint
MCP_PORTNo3100HTTP server port (non-stdio mode)

What Can Agents Do?

CategoryCapabilities
MarketsBrowse lending markets, check rates, view liquidity
IntentsCreate lend/borrow offers, accept existing offers, cancel intents
LoansMonitor loan health, repay, add/withdraw collateral, liquidate
TransactionsBuild unsigned txs, simulate, broadcast signed txs, check receipts
AnalysisCheck intent compatibility, calculate risk metrics, estimate interest

Tools (36)

Read Tools

ToolDescription
get_marketsList active lending markets with rates and liquidity
get_market_detailsDetailed market info including oracle prices
get_open_lend_intentsBrowse lend offers available for borrowing against
get_open_borrow_intentsBrowse borrow requests from borrowers seeking lenders
get_intent_detailsGet full details of a specific intent by hash
get_loanGet loan details by numeric ID
get_user_loansGet all loans for a wallet (borrower + lender)
get_loan_healthCheck loan LTV, health status, liquidation risk
get_liquidation_quoteGet liquidation eligibility and details
get_token_priceCurrent oracle price for collateral tokens
get_wallet_balanceToken balances for a wallet
get_accrued_interestInterest accrued on a loan

Write Tools (return unsigned transactions)

ToolDescription
create_lend_intentCreate a lending offer
create_borrow_intentCreate a borrowing request
create_counter_intentAccept an existing offer (solver matches automatically)
repay_loanRepay a loan with slippage protection
add_collateralAdd collateral to improve loan health
withdraw_collateralWithdraw excess collateral
liquidate_loanLiquidate an unhealthy loan
revoke_intentCancel an active intent
approve_tokenApprove token spending for the protocol

Analysis Tools

ToolDescription
check_compatibilityCheck if two intents can match
calculate_riskRisk metrics: LTV, liquidation price, buffer
estimate_interestInterest estimate for given loan terms

Utility Tools

ToolDescription
simulate_transactionDry-run a transaction (eth_call)
broadcast_transactionSubmit a signed transaction
get_transaction_statusCheck transaction receipt

Agent Awareness Tools

Let's an agent answer "do I have credit?", "is this call worth it?", and "where am I in the loan lifecycle?" before committing capital. All require an agent API key (floe_*); the calling identity is taken from the bearer token.

ToolDescription
get_credit_remainingCurrent available credit, headroom to auto-borrow, utilization in bps
get_loan_stateCoarse state: idle | borrowing | at_limit | repaying
get_spend_limitCurrently active session spend cap, if any
set_spend_limitSet a session-level USDC ceiling (resets the session window)
clear_spend_limitRemove the session spend cap
list_credit_thresholdsList registered credit-utilization thresholds
register_credit_thresholdRegister a webhook trigger at a utilization threshold (cap: 20 per agent)
delete_credit_thresholdRemove a registered threshold
estimate_x402_costPreflight an x402 URL — returns cost + reflection against your credit, no payment

Transaction Flow

All write tools return unsigned transactions — the server never holds private keys.

1. Call a write tool (e.g., create_counter_intent)
   → Returns { transactions: [...], summary, warnings, expiresAt }

2. (Optional) Call simulate_transaction to dry-run

3. Sign each transaction locally with your wallet

4. Call broadcast_transaction with the signed hex
   → Returns { transactionHash, status, blockNumber }

Example: Accept a Lend Offer

Agent: "Borrow 1000 USDC on Floe"

1. get_open_lend_intents → browse offers
2. create_counter_intent(offer_hash, wallet) → unsigned txs
3. simulate_transaction(from, to, data) → { success: true, gasEstimate }
4. Sign locally → signed hex
5. broadcast_transaction(signed_hex) → confirmed

Signing with viem

import { createWalletClient, http } from "viem";
import { privateKeyToAccount } from "viem/accounts";
import { base } from "viem/chains";

const wallet = createWalletClient({
  account: privateKeyToAccount(PRIVATE_KEY),
  chain: base,
  transport: http(),
});

// Sign and send each transaction in order
for (const { transaction: tx } of response.transactions) {
  const hash = await wallet.sendTransaction({
    to: tx.to,
    data: tx.data,
    value: BigInt(tx.value),
  });
  // Wait for confirmation before next step
}

Programmatic Usage

MCP Client SDK

import { Client } from "@modelcontextprotocol/sdk/client";
import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js";

const client = new Client({ name: "my-agent" });
await client.connect(new StreamableHTTPClientTransport(
  new URL("https://mcp.floelabs.xyz/mcp"),
  { requestInit: { headers: { "Authorization": "Bearer floe_live_..." } } }
));

const markets = await client.callTool("get_markets", {});
const counter = await client.callTool("create_counter_intent", {
  offer_hash: "0x...",
  wallet_address: "0x...",
});

LangChain / LangGraph

from langchain_mcp_adapters import MultiServerMCPClient

async with MultiServerMCPClient({
    "floe": {"url": "https://mcp.floelabs.xyz/mcp", "headers": {"Authorization": "Bearer floe_live_..."}}
}) as client:
    tools = client.get_tools()
    # Use tools in your agent

Architecture

Your Agent → MCP Server → credit-api.floelabs.xyz → Envio Indexer / Base RPC
                ↑                    ↑
           This package         Private backend
          (open source)        (holds secrets)

The MCP server is a thin HTTP client. All protocol logic, indexer queries, and RPC calls happen in the private Floe API backend. This package contains only tool definitions and fetch() calls.

Protocol Overview

Floe is an intent-based lending protocol:

  1. Lenders post offers specifying amount, minimum rate, and max LTV
  2. Borrowers post requests specifying amount, collateral, and max rate
  3. Solvers automatically match compatible intent pairs on-chain
  4. Loans are created with the matched terms, collateral locked
  5. Borrowers repay principal + interest to unlock collateral

Key concepts:

  • Intent: An on-chain offer to lend or borrow
  • Counter-Intent: An intent created to match an existing offer
  • Health Factor: Ratio of collateral value to debt — below threshold triggers liquidation
  • LTV (Loan-to-Value): Borrower's debt as % of collateral value

Contract Addresses (Base Mainnet)

ContractAddress
LendingIntentMatcher0x17946cD3e180f82e632805e5549EC913330Bb175
PriceOracle0xEA058a06b54dce078567f9aa4dBBE82a100210Cc
LendingViews0x9101027166bE205105a9E0c68d6F14f21f6c5003

Links

License

MIT

Servidores relacionados

NotebookLM Web Importer

Importa páginas web y videos de YouTube a NotebookLM con un clic. Utilizado por más de 200,000 usuarios.

Instalar extensión de Chrome