DeFi Copilot MCP server for Stellar DeFi intelligence

DeFi Copilot MCP server for Stellar DeFi intelligence

defi-copilot•byfxjrin

An MCP server that lets AI agents query yield and swap data, execute swaps, and manage Blend Finance deposits on Stellar, with pay-per-request settlement via x402.

License: MIT•Runtime: Awaiting documentation review•Category: finance crypto

WHAT IT DOES

  • •Provides get_best_yield and get_best_swap tools that return yield strategies and optimal swap routes, each priced at 0.001 USDC.
  • •Offers tools to execute swaps on the Stellar DEX and deposit, withdraw, or check Blend Finance positions.
  • •Includes wallet tools to create or view an agent wallet, fund it, transfer XLM or USDC, and view transaction history.
  • •Handles payments automatically via the x402 protocol, with per-request pricing in USDC.

BEST FOR

  • •AI agents that need pay-per-request DeFi yield and swap intelligence on Stellar.
  • •Conversational assistants that want to execute Stellar DEX swaps and manage Blend Finance deposits.
  • •Users who want to switch between Stellar testnet and mainnet within a conversation.

ABOUT DEFI-COPILOT

DeFi Copilot MCP server for Stellar DeFi intelligence is cataloged as an MCP server attributed to fxjrin. An MCP server that lets AI agents query yield and swap data, execute swaps, and manage Blend Finance deposits on Stellar, with pay-per-request settlement via x402. It is categorized under finance crypto. See the capability inspector for recorded interfaces and their independent review status; consult upstream documentation for the current interface.

HOW TO INSTALL

Installation configuration is not reviewed. No executable setup is offered for this entry; inspect the source repository before proceeding.

LICENSE

Catalog license label: MIT. Check the source repository's current license and terms before using, modifying or distributing this software.

Capability inspector

Capability definitions are not reviewed. Unreviewed imports are not exposed as trusted interfaces.

Tools (0)

No reviewed records to display. This does not establish that upstream lacks this capability.

Resources (0)

No reviewed records to display. This does not establish that upstream lacks this capability.

Prompts (0)

No reviewed records to display. This does not establish that upstream lacks this capability.

NEWSLETTER - COMING LATER

Newsletter subscriptions are not open yet

Email delivery is not connected. This page does not collect email addresses or create subscriptions.

Browse the registry for current listings instead.

Community Reviews

Coming later

Reviews for DeFi Copilot MCP server for Stellar DeFi intelligence are not available yet

Review publishing and storage are not connected. This page does not collect or publish ratings or comments, including after sign-in.

FREQUENTLY ASKED QUESTIONS

Does the MCP server require API keys or subscriptions?

No API keys or subscriptions are required; agents pay per request using x402.

Are private keys stored by the server?

Wallets are stored locally on the user's machine and private keys never leave the user's device.

Does the wallet auto-fund on mainnet?

No, on mainnet the wallet is created but not auto-funded; users must deposit XLM manually.

Upstream README

View this exact version on GitHub

README.md · e97879d7db5e · Fetched 2026-11-13 12:32:06 UTC

Original upstream text, without AI rewriting. Scripts, forms and unsafe links are filtered for safety.

Showing the last retrieved documentation snapshot; check the source for current changes.

DeFi Copilot

npm version npm downloads License: MIT Node.js Stellar

Pay-per-decision DeFi intelligence for AI agents on Stellar. Built with x402 protocol — agents buy decisions, not subscriptions.

Overview

DeFi Copilot is a Stellar-native DeFi intelligence layer that allows AI agents to autonomously query DeFi data, execute swaps, and interact with DeFi protocols — paying per request using the x402 protocol. No API keys. No subscriptions. No human approval required.

Two ways to use:

  • MCP Server — install in Claude Desktop or any MCP-compatible AI, agents query and pay automatically
  • REST API — standard HTTP with x402 payment protocol, works with any HTTP client

Live backend: https://api.fxjrin.com


How It Works

User / AI Agent
      |
      | (natural language or direct API call)
      v
MCP Server (defi-copilot-mcp)
      |
      | GET /defi/yield/best
      v
Backend API (port 3000)
      |
      | 402 Payment Required
      v
Agent builds + signs Stellar USDC tx
      |
      | x-payment header
      v
Facilitator verifies + settles (port 4022)
      |
      | on-chain settlement on Stellar
      v
Return DeFi intelligence

Project Structure

defi-copilot/
  src/
    server.ts                  # Express server
    routes/
      yield.ts                 # GET /defi/yield/best
      swap.ts                  # GET /defi/swap/best
    services/
      scorer.ts                # Market data + Blend on-chain APY + DEX quotes
    utils/
      x402-middleware.ts       # x402 payment verification
      network.ts               # Network config (testnet/mainnet)
      http.ts                  # IPv4-forced HTTP client (undici)
      init.ts                  # Server wallet setup script
    facilitator/
      index.ts                 # Local x402 facilitator (port 4022)
    agent/
      client.ts                # Agent payment client with auto-create wallet
      demo.ts                  # Demo script
  mcp-server/
    src/
      index.ts                 # MCP tools + auto-create wallet
      network.ts               # Network config for MCP
      http.ts                  # IPv4-forced HTTP client (undici)

Prerequisites

  • Node.js v18+
  • npm v9+
  • Git

Installation

1. Clone the repository

git clone https://github.com/fxjrin/defi-copilot.git
cd defi-copilot

2. Install backend dependencies

npm install

3. Install MCP server dependencies

cd mcp-server
npm install
cd ..

Configuration

Backend .env

The .env file is generated automatically by npm run init. If you prefer to set it up manually, create .env in the defi-copilot/ root:

# Stellar network: testnet or mainnet
STELLAR_NETWORK=testnet

# Server wallet — receives x402 payments
# Generated automatically by: npm run init
SERVER_SECRET_KEY=
SERVER_PUBLIC_KEY=

PORT=3000

Quick Start

Step 1 — Initialize server wallet

Run the setup script to automatically generate and fund a server wallet:

npm run init

This will:

  1. Generate a new Stellar keypair for the server
  2. Fund with XLM via Friendbot (testnet only)
  3. Set up USDC trustline
  4. Save credentials to .env

Expected output:

DeFi Copilot — Initial Setup
Network: testnet
Generating server wallet...
  Public key : GXXXX...
  Secret key : SXXX*...XXXX (saved to .env)
  Credentials saved to .env
  Funding via Friendbot...
  XLM funded successfully
  Waiting for account activation...
Setting up USDC trustline...
  USDC trustline created
Final balances:
  USDC: 0.0000
  XLM: 10000.0000
Setup complete!
Run: npm start

Step 2 — Start the server

npm start

This starts both the API server (port 3000) and the x402 facilitator (port 4022) simultaneously.

Expected output:

[api]          🚀 DeFi Copilot API running on port 3000
[api]             Network : testnet
[api]             Wallet  : GXXXX...
[facilitator]  ⚡ Local x402 Facilitator running on port 4022

Step 3 — Run the demo

Make sure npm start is running in another terminal, then:

npm run demo

The demo agent will auto-create its own wallet, fund it with USDC, and make payments automatically.

Expected output:

DeFi Copilot Agent Demo
Initializing agent wallet...
  No wallet found — creating new agent wallet on Stellar testnet...
  Funding with XLM via Friendbot...
  XLM funded successfully
  Setting up USDC trustline...
  Swapping XLM to USDC...
  USDC funded successfully
  Agent wallet ready: GXXXX...

DEMO 1: Where should I put my USDC?
  Agent requesting: http://localhost:3000/defi/yield/best
  Payment required: 0.0010 USDC
  Payment accepted!
  Strategy   : Deposit to Fixed V2 on Blend Finance
  APY        : 9.47% (live on-chain)
  Risk       : low
  Confidence : 95%

DEMO 2: Best route to swap 500 XLM to USDC?
  Agent requesting: http://localhost:3000/defi/swap/best
  Payment accepted!
  Route          : SDEX Orderbook
  Expected output: 75.88 USDC
  Slippage       : 0.005%
  Confidence     : 99%

API Reference

GET /health

Free. Returns server status.

{
  "status": "ok",
  "network": "testnet",
  "server_wallet": "GXXXX..."
}

GET /defi/yield/best

Cost: 0.001 USDC via x402

Query params:

  • asset — USDC or XLM (default: USDC)
  • amount — number (default: 1000)

Response:

{
  "strategy": "Deposit to Fixed V2 on Blend Finance",
  "protocol": "Blend Finance",
  "apy": "9.47%",
  "risk": "low",
  "reasoning": "Live Blend Finance on-chain APY. Pool comparison: Fixed V2: USDC 9.47% | YieldBlox V2: USDC 0.07%",
  "confidence": 0.95,
  "marketData": {
    "xlmPrice": "0.1518 USDC",
    "spread": "0.3945%",
    "volume24h": "4531.6K XLM",
    "source": "Blend Finance (on-chain Soroban) + Stellar mainnet DEX"
  },
  "alternatives": [...]
}

GET /defi/swap/best

Cost: 0.001 USDC via x402

Query params:

  • from — source asset (default: XLM)
  • to — target asset (default: USDC)
  • amount — number (default: 100)

Response:

{
  "from": "XLM",
  "to": "USDC",
  "amount": 500,
  "route": ["SDEX Orderbook"],
  "expectedOutput": "75.88 USDC",
  "slippage": "0.005%",
  "priceImpact": "low",
  "marketPrice": "1 XLM = 0.1518 USDC",
  "confidence": 0.99,
  "reasoning": "DEX comparison: SDEX Orderbook: 75.88 USDC | Stellar DEX: 75.80 USDC | Stellar AMM: 75.70 USDC"
}

x402 Payment Flow

1. Client → GET /defi/yield/best
2. Server ← 402 Payment Required
   {
     "x402Version": 1,
     "accepts": [{
       "scheme": "exact",
       "network": "stellar-testnet",
       "maxAmountRequired": "10000",
       "asset": "CBIELTK6...",
       "payTo": "GXXXX..."
     }]
   }
3. Client builds + signs Stellar USDC payment tx
4. Client → GET /defi/yield/best
           x-payment: <base64-encoded-payload>
5. Facilitator verifies transaction
6. Facilitator settles on Stellar
7. Server → 200 OK with DeFi intelligence

MCP Server

The MCP server allows AI agents (Claude, Cursor, etc.) to use DeFi Copilot tools directly in conversation, with automatic payment handling.

Install via Claude Code

claude mcp add defi-copilot -- npx -y defi-copilot-mcp

Install via Claude Desktop config

Add to your claude_desktop_config.json:

macOS: ~/Library/Application Support/Claude/claude_desktop_config.json

Windows: %APPDATA%\Claude\claude_desktop_config.json

Linux: ~/.config/Claude/claude_desktop_config.json

{
  "mcpServers": {
    "defi-copilot": {
      "command": "npx",
      "args": ["-y", "defi-copilot-mcp"],
      "env": {
        "STELLAR_NETWORK": "testnet"
      }
    }
  }
}

Note: DEFI_COPILOT_API defaults to https://api.fxjrin.com — no need to set it unless you run your own backend.

Available Tools

ToolCostDescription
get_best_yield0.001 USDCBest yield strategy — live from Blend Finance on-chain (Soroban)
get_best_swap0.001 USDCOptimal swap route — compares SDEX Orderbook, Stellar DEX, AMM
execute_swapFREEExecute real swap on Stellar DEX
deposit_blendFREEDeposit USDC to Blend Finance to earn yield (mainnet)
withdraw_blendFREEWithdraw USDC + interest from Blend Finance (mainnet)
get_blend_positionFREECheck your Blend Finance deposit + interest earned (mainnet)
transferFREESend XLM or USDC to any Stellar address
get_market_dataFREELive XLM price, volume, spread from Stellar mainnet DEX
get_agent_walletFREECheck or create agent wallet
fund_walletFREEShow wallet address + QR code URL for funding
set_networkFREESwitch between testnet and mainnet
get_transaction_historyFREEView recent wallet transaction history
get_api_infoFREEAPI info and pricing

Agent Wallet Behavior

On first use, the MCP server automatically:

  1. Generates a new Stellar keypair
  2. Funds with XLM via Friendbot (testnet only)
  3. Sets up USDC trustline
  4. Swaps 50 XLM to USDC for payment capability
  5. Saves wallet to ~/.defi-copilot/wallet-testnet.json

Each user's wallet is stored locally on their own machine. Private keys never leave the user's device.

On mainnet, the wallet is created but not auto-funded — users must deposit XLM manually. This is intentional: mainnet uses real funds.

Network Switching

Switch networks within a conversation:

User: "Switch to mainnet"
Claude: calls set_network(network="mainnet")

User: "Deposit 10 USDC to Blend Finance"
Claude: calls deposit_blend(amount=10, confirmed=true)

Or set via environment variable (persists across sessions):

"env": {
  "STELLAR_NETWORK": "mainnet"
}

Data Sources

DataSourceNetwork
Yield APYBlend Finance smart contracts (Soroban)Mainnet (on-chain)
Swap quotesSDEX Orderbook + Stellar DEX pathfinder + AMM poolMainnet (real quotes)
XLM priceStellar Horizon trade aggregationsMainnet (real prices)
Orderbook spreadStellar Horizon order bookMainnet
24h volumeStellar Horizon trade aggregationsMainnet
Paymentsx402 protocolTestnet or Mainnet

All price and yield data comes directly from Stellar mainnet for accuracy, regardless of which network is used for payments.


Environment Variables

Backend (defi-copilot/.env)

VariableRequiredDescription
STELLAR_NETWORKNotestnet or mainnet (default: testnet)
SERVER_SECRET_KEYYesSecret key for server wallet (receives payments)
SERVER_PUBLIC_KEYYesPublic key for server wallet
PORTNoServer port (default: 3000)

MCP Server (via config or shell env)

VariableRequiredDescription
STELLAR_NETWORKNotestnet or mainnet (default: testnet)
DEFI_COPILOT_APINoBackend API URL (default: https://api.fxjrin.com)

npm Scripts

Backend (defi-copilot/)

npm run init        # Generate and fund server wallet
npm start           # Start API + facilitator together
npm run dev         # Start API only (port 3000)
npm run facilitator # Start facilitator only (port 4022)
npm run demo        # Run agent payment demo
npm run build       # Compile TypeScript

MCP Server (defi-copilot/mcp-server/)

npm run build       # Compile TypeScript
npm run dev         # Run without compiling (tsx)

Deployment

Backend on VPS

git clone https://github.com/fxjrin/defi-copilot.git
cd defi-copilot
npm install

# Initialize server wallet
npm run init

# Install pm2 for process management
npm install -g pm2

# Start both api and facilitator
pm2 start npm --name defi-copilot -- start
pm2 save
pm2 startup

After deploying, nginx reverse proxy + SSL via certbot is recommended:

apt install -y nginx certbot python3-certbot-nginx
# configure nginx to proxy port 3000
certbot --nginx -d your-domain.com

License

MIT

Install configuration

Are you the maintainer?

Claim this server with your GitHub account to request manual ownership verification.

README Embed Badge
Markdown

Link to the catalog listing for DeFi Copilot MCP server for Stellar DeFi intelligence from your README. This badge does not certify ownership, compatibility or security.

[![MCP catalog listing](https://img.shields.io/badge/MCP-awesome--mcp-orange?style=flat-square)](https://awesome-mcp.com/servers/defi-copilot)

REPOSITORY STATS

GitHub StarsUnavailable
ForksUnavailable

Public repository statistics could not be verified. Check the configured source address; unavailable counts are not zero.

Downloads and pulls

Separate sources, scopes and periods. Never combined or treated as installations, active users or security reviews.

No reviewed package or image identity; download statistics are not listed yet.

Related finance crypto MCP Servers

Alternative and complementary servers in the same category

View all in finance crypto →
USA Spending MCP Server
usaspending-mcp-server•thsmale

A stateless streamable HTTP MCP server for interacting with the official source of government spending data.

Repository stats unavailable
Finance & Analytics
Fortnox MCP server — More AI
more-ai-chatgpt-claude-mcp-fortnox•amor3

A hosted, remote MCP server for Fortnox that lets AI assistants answer questions from a company's bookkeeping and propose changes for approval before writing them.

0
Finance & Analytics

OptimistFi is a read-only remote MCP server that provides perpetual futures market data, perps prop firm rules and pricing, and US equity investment research.

Repository stats unavailable
Finance & Analytics