🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

stellar-mcp-x402

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

stellar-mcp-x402

MCP server giving AI agents access to Stellar blockchain data — accounts, DEX, transactions, assets — with x402 micropayments settled on Stellar

latest
npmnpm
Version
0.2.0
Version published
Weekly downloads
12
-52%
Maintainers
1
Weekly downloads
 
Created
Source

StellarMCP

Data Merchant for the Agent Economy

MCP server giving AI agents access to Stellar blockchain data — accounts, DEX orderbooks, transactions, trade history, asset metadata, and network status — with every tool call monetized via x402 micropayments settled on Stellar.

Built for the Stellar Hacks: Agents hackathon.

Features

  • 16 MCP tools querying the Stellar Horizon REST API
  • PriceService with VWAP, OHLC history, and oracle abstraction layer
  • x402 micropayments on Stellar — agents pay per call in USDC
  • Dual transport — stdio for MCP clients, HTTP REST for x402-gated access
  • Earn/spend demo — agent earns USDC selling data, spends USDC on external services
  • OpenClaw registered — permissionless agent discovery via GET /skill.md
  • Zero dependencies on @stellar/stellar-sdk — raw fetch to Horizon

Quick Start

MCP Client (stdio — free, local)

npx stellar-mcp-x402

Or add to your MCP client config:

{
  "mcpServers": {
    "stellarmcp": {
      "command": "npx",
      "args": ["stellar-mcp-x402"],
      "env": {
        "STELLAR_NETWORK": "testnet"
      }
    }
  }
}

HTTP Server (x402-monetized)

git clone https://github.com/siriuslattice/stellarmcp.git
cd stellarmcp
pnpm install
cp .env.example .env
# Edit .env with your Stellar testnet wallet and OZ facilitator key
TRANSPORT=http pnpm start

Then query:

# Free endpoint
curl http://localhost:4021/tools/getNetworkStatus

# Paid endpoint (requires x402 payment header)
curl http://localhost:4021/tools/getAccount?accountId=GAAZI4TCR3TY5OJHCTJC2A4QSY6CJWJH5IAJTGKIN2ER7LBNVKOCCWN7

# View pricing
curl http://localhost:4021/pricing

Tools

Horizon Data Tools

ToolDescriptionPrice
getAccountAccount balances, thresholds, signers$0.001
getTransactionsRecent transactions for an account$0.001
getPaymentsRecent payments for an account$0.001
getOrderbookDEX orderbook with spread and midprice$0.002
getTradeAggregationsOHLC candle data for a trading pair$0.002
getAssetInfoAsset metadata, supply, flags$0.001
getNetworkStatusNetwork health and protocol versionFree
getLedgerLedger details by sequence number$0.001
getEffectsAccount effects (balance changes, trades, etc.)$0.001
getOffersOpen DEX offers for an account$0.001
getOperationsAll operations for an account$0.001
getLiquidityPoolsStellar AMM liquidity pools$0.002
getClaimableBalancesClaimable balances by claimant or asset$0.001

Price Tools

ToolDescriptionPrice
getPriceCurrent price for any Stellar asset pair$0.002
getPriceHistoryOHLC price history with VWAP$0.002
getVWAPVolume-weighted average price$0.002

The price tools are powered by PriceService, which aggregates data from the Stellar SDEX via trade aggregations. The oracle abstraction layer supports multiple price sources (SDEX, Reflector) with source attribution.

Asset Format

TypeFormatExample
NativeXLMXLM
ClassicCODE:ISSUERUSDC:GA5ZSEJYB37JRC5AVCIA5MOP4RHTM335X2KGX3IHOJAPP5RE34K4KZVN

Agent Demo

The earn/spend loop demonstrates the full agent economy:

# Terminal 1: Start the x402 HTTP server (earn side)
TRANSPORT=http pnpm start

# Terminal 2: Start a mock external x402 service (spend side)
pnpm demo:service

# Terminal 3: Run the agent demo
pnpm demo

The agent:

  • Earns USDC by receiving x402 payments from clients querying Stellar data
  • Spends USDC by paying external x402 services to enrich its outputs

Development

pnpm install
pnpm typecheck    # Type check (zero errors required)
pnpm test         # Run unit tests
pnpm build        # Build for production
pnpm inspect      # Open MCP Inspector at localhost:6274

Architecture

                                                   +--> PriceService ──> OracleProvider(s)
                                                   |
stdio transport ──> McpServer ──> 16 tools ──> HorizonClient ──> Stellar Horizon REST API
                                                   |
HTTP transport  ──> Express ──> x402 middleware ────+
                       |
                       +-- /tools/* (paid endpoints)
                       +-- /tools/getNetworkStatus (free)
                       +-- /health (free)
                       +-- /pricing (free)
                       +-- /skill.md (OpenClaw discovery)

The PriceService sits on top of HorizonClient and provides normalized price data (current price, OHLC history, VWAP) through an oracle abstraction layer. The SDEX oracle queries Horizon trade aggregations; future oracles (Reflector, Chainlink) plug in via the same OracleProvider interface.

Tech Stack

  • TypeScript with strict mode
  • Node.js 22+
  • MCP SDK (@modelcontextprotocol/sdk)
  • x402 (@x402/express, @x402/stellar, @x402/core)
  • Express 4 with CORS and rate limiting
  • Vitest for testing
  • tsup for bundling

Environment Variables

See .env.example for all options.

VariableRequiredDefaultDescription
STELLAR_NETWORKNotestnettestnet or pubnet
HORIZON_URLNohttps://horizon-testnet.stellar.orgHorizon API URL
TRANSPORTNostdiostdio or http
STELLAR_PAYEE_ADDRESSHTTP modeYour Stellar address for receiving payments
OZ_FACILITATOR_URLHTTP modeOpenZeppelin x402 facilitator URL
OZ_API_KEYHTTP modeOpenZeppelin facilitator API key
PORTNo4021HTTP server port
LOG_LEVELNoinfodebug, info, warn, error
SOROBAN_RPC_URLNoSoroban RPC URL (for future SEP-41 token support)

License

MIT

Keywords

stellar

FAQs

Package last updated on 10 Apr 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts