Defi Copilot

by fxjrin

285 downloads
Not rated
GitHub Website

About

Pay-per-decision DeFi intelligence for AI agents on Stellar. Built with x402 protocol.

Details

Author
fxjrin
Downloads
285
Categories
Other, AI

- Pay-per-request using the x402 protocol
- Live on-chain yield data from Blend Finance (Soroban)
- Optimal swap route comparison across SDEX, Stellar DEX, and AMM
- Automatic Stellar wallet creation and funding on testnet
- Free tools for swap execution, deposits, withdrawals, and transfers
- Wallet stored locally; private keys never leave your device

Setting up with Highlight

This MCP is not yet compatible with Highlight’s one-click setup. However, you can still use it with Highlight by following these steps:

  1. Download and install Highlight from highlightai.com/download
  2. Navigate to the plugins tab and select "Add Custom Plugin"
  3. Configure the plugin with the settings below
    Plugin Name Defi Copilot
    Command (node, npx, python, etc.)

    Please refer to the README for specific instructions on how to obtain API keys or other required environment variables.

  4. Enable "Start Automatically" if you want the plugin to start when Highlight launches

From the repository

Install the MCP server via npx -y defi-copilot-mcp and add it to Claude Desktop or any MCP-compatible client. Use the REST API at https://api.fxjrin.com with any HTTP client. Set the STELLAR_NETWORK environment variable to testnet or mainnet; the DEFI_COPILOT_API defaults to the live backend unless you run your own.

Claude Desktop / Cursor

Paste into your MCP client config file to install this server.

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

McpServers

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

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:

```env

No reviews yet — be the first

Sign in to leave a review

Use Google, GitHub, or an email account so ratings stay tied to real people.

Email sign in

No reviews posted yet.