stellar-mcp
Provides tools for interacting with the Stellar network and Soroban smart contracts, including network status, account and transaction lookup, contract event queries, contract spec/ABI introspection, storage and TTL diagnostics, transaction simulation, XDR decoding and security inspection, and safe transaction building/submission.
Click on "Deploy 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., "@stellar-mcp why did my soroban contract call fail with Error(Contract, #4)?"
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.
stellar-mcp
A lightweight, zero-CLI-dependency Model Context Protocol (MCP) server that gives AI coding assistants (Claude Code, Cursor, Windsurf, Claude Desktop) native, real-time access to the Stellar network and Soroban smart contracts—focused on debugging, diagnostics, and safe-by-default workflows.
Table of Contents
Related MCP server: stellar-copilot-mcp
Why stellar-mcp?
Working on Soroban often means context-switching between your IDE, stellar CLI, block explorers, and raw XDR decoders. stellar-mcp eliminates that friction:
Zero External CLI Dependency: No
stellarCLI binary required. Contract WASMcontractspecv0custom sections, XDR structures, and RPC/Horizon queries are parsed natively in Node.js via@stellar/stellar-sdkandWebAssembly.Module.Deep Soroban Diagnostics: Translates opaque host errors (
Error(Contract, #4),Error(Storage, MissingValue),Error(Auth, InvalidAction),Error(Budget, ExceededLimit)) into root-cause explanations and fixes, and resolves custom#[contracterror]variant names directly from deployed WASM specs.Storage & TTL Health: Inspects contract instance and keyed storage byte sizes, computes remaining TTL in ledgers and days (~17,280 ledgers/day), and flags oversized or expiring/archived entries.
Safe-by-Default Guardrails: Mainnet is strictly read-only and simulate-only by default (
ALLOW_MAINNET_WRITES=false).build_transactionoutputs unsigned XDR with an automaticXdrInspectorsecurity audit.Clean Context Hygiene: Converts
BigIntvalues safely, truncates oversized JSON responses at 32,000 characters, and writes all logs strictly tostderrso MCPstdoutJSON-RPC frames are never corrupted.
Architecture
+-------------------------------------------------------------------+
| AI Coding Assistant (Claude Code / Cursor / Windsurf / Desktop) |
+---------------------------------+---------------------------------+
| MCP over stdio (JSON-RPC)
v
+-------------------------------------------------------------------+
| stellar-mcp (src/index.ts) |
| +-- Tools (src/registry.ts) -> 12 validated Zod tools |
| +-- Resources (src/resources.ts) -> network, contract, acct |
| +-- Prompts (src/prompts.ts) -> debug, audit, review |
+---------------------------------+---------------------------------+
|
v
+-------------------------------------------------------------------+
| Pure-SDK Services (src/services/) |
| +-- networks.ts -> Presets, cached clients, write guard |
| +-- contract-spec.ts -> WASM contractspecv0 + SAC + 5m cache |
| +-- xdr-decoder.ts -> ScVal, LedgerKey, Envelope, HostErrors |
| +-- inspector.ts -> XdrInspector security/risk analyzer |
+---------------------------------+---------------------------------+
| HTTPS / HTTP (local)
+-----------------------+-----------------------+
v v
+-------------------+ +-------------------+
| Soroban RPC | | Horizon API |
+-------------------+ +-------------------+Installation & IDE Setup
Prerequisites
Node.js
>= 20.0.0
Option A: Run from Source (Recommended while developing)
git clone git@github-ijele-don:ijele-don/stellar-mcp.git
cd stellar-mcp
npm install
npm run buildOption B: Run via npx (Once published)
npx -y stellar-mcpClaude Code
# Using local build
claude mcp add stellar-mcp -- node /absolute/path/to/stellar-mcp/dist/index.js
# Or via npx
claude mcp add stellar-mcp -- npx -y stellar-mcpCursor (~/.cursor/mcp.json) / Windsurf (~/.codeium/windsurf/mcp_config.json) / Claude Desktop
{
"mcpServers": {
"stellar-mcp": {
"command": "node",
"args": ["/absolute/path/to/stellar-mcp/dist/index.js"],
"env": {
"STELLAR_NETWORK": "testnet",
"ALLOW_MAINNET_WRITES": "false",
"LOG_LEVEL": "info"
}
}
}
}Configuration & Networks
Copy .env.example to .env if running locally, or pass environment variables in your MCP client config.
Environment Variables
Variable | Default | Description |
|
| Default network: |
| preset | Custom Horizon URL (required for |
| preset | Custom Soroban RPC URL |
| preset | Custom network passphrase |
|
| Must be |
| unset | Optional |
|
|
|
Network Presets
Network | Horizon URL | Soroban RPC URL | Passphrase |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Every tool also accepts an optional network parameter to override the configured default per call.
Tools Reference (12)
Network & Ledger Inspection
Tool | Required Inputs | Optional Inputs | Returns |
| — |
| RPC health, latest ledger sequence, protocol version, endpoints, and |
|
|
| XLM & issued asset balances, sequence number, thresholds, and signers |
|
|
| Status, ledger, decoded envelope, return value, and diagnostic events (RPC + Horizon fallback) |
|
|
| Recent contract events with decoded |
Soroban Diagnostics & Introspection
Tool | Required Inputs | Optional Inputs | Returns |
|
|
| Decoded |
|
|
|
|
|
|
| Error |
|
|
| Per-entry byte size, |
XDR Decoding & Security
Tool | Required Inputs | Optional Inputs | Returns |
|
|
| Decoded transaction summary + |
|
|
| Decoded JSON for |
Safe Transaction Workflows
Tool | Required Inputs | Optional Inputs | Returns |
|
|
| Unsigned |
|
|
| Submission status, |
MCP Resources & Prompts
Resources & Resource Templates
URI / Template | Description |
| Live RPC health, latest ledger, protocol version, and mainnet write-policy state |
| Decoded ABI/spec ( |
| Account balances, sequence, thresholds, and signers |
Prompts
Prompt | Arguments | Purpose |
|
| Guides the assistant through |
|
| Audits contract spec, entry byte sizes, TTL health, and storage architecture |
|
| Runs |
Security & Safety Model
Read-Only Mainnet Default:
assertWriteAllowedin src/services/networks.ts throws aSafetyPolicyErroron anysubmit_transactiontargetingmainnetunlessALLOW_MAINNET_WRITES=trueis explicitly set.Unsigned Transaction Building:
build_transactionnever requires a private key—it produces unsigned XDR for simulation or external wallet signing (e.g., Freighter or hardware wallets).Automatic XDR Risk Auditing:
XdrInspector(src/services/inspector.ts) checks every built or inspected transaction:HIGH:ACCOUNT_MERGE,SIGNER_CHANGE(setOptions.signer),CLAWBACKMEDIUM:EXCESSIVE_FEE(>100xBASE_FEEper op),THRESHOLD_CHANGE,REVOKE_SPONSORSHIPLOW:INVOKE_HOST_FUNCTION(advises simulation first),CHANGE_TRUST
Secret Redaction:
pinologger redactsSTELLAR_SECRET_KEY,secret,secretKey, andprivateKey, and writes strictly tostderr.
Real-World IDE Workflows
Debug a failed contract call:
"Transaction
a1b2...failed on testnet withError(Contract, #4)on contractC.... Diagnose why it failed and check recent contract events."Audit storage & rent before mainnet deploy:
"Audit contract
C...on testnet: fetch its spec, check instance storage size, and tell me how many days of TTL remain."Verify an unsigned XDR before signing:
"Inspect this base64 XDR for risky operations and simulate it on testnet to check the auth tree and resource fee."
Project Structure
stellar-mcp/
├── .github/workflows/ci.yml # GitHub Actions CI (Node 20 & 22)
├── src/
│ ├── index.ts # MCP stdio server entry point
│ ├── config.ts # Zod-validated env configuration
│ ├── errors.ts # Typed StellarMcpError hierarchy
│ ├── logger.ts # stderr-only pino logger with redaction
│ ├── registry.ts # Single source of truth for all 12 tools
│ ├── resources.ts # MCP resources & URI templates
│ ├── prompts.ts # Guided MCP debugging/audit prompts
│ ├── services/
│ │ ├── networks.ts # Network presets, cached clients, write guard
│ │ ├── contract-spec.ts # Native WASM contractspecv0 + SAC parser
│ │ ├── xdr-decoder.ts # ScVal, LedgerKey, Envelope & error decoder
│ │ └── inspector.ts # XdrInspector transaction risk analyzer
│ ├── tools/ # 12 modular MCP tool implementations
│ └── utils/
│ └── json.ts # BigInt-safe JSON & 32k context truncation
├── tests/ # Unit tests + gated live Testnet suite
├── .env.example
├── LICENSE
├── package.json
├── tsconfig.json
└── vitest.config.tsDevelopment, Testing & CI
# Typecheck, build, and run offline unit tests
npm run typecheck
npm run build
npm test
# Run live Stellar Testnet integration tests (requires network access)
npm run test:testnetUnit tests (
npm test): Offline, fast, and run automatically in CI on Node 20 and 22.Live Testnet suite (
npm run test:testnet): Verifiesget_network_status,fetch_contract_spec,analyze_contract_storage, and live WASMcontractspecv0parsing againsthttps://soroban-testnet.stellar.org.
Roadmap
build_restore_transactionhelper whensimulate_transactionreturnsrestore_neededStreamable HTTP transport alongside
stdiofor remote MCP clientsLocal Rust/TypeScript ABI drift checker comparing workspace contracts against deployed Testnet/Mainnet specs
Publish to npm for zero-setup
npx -y stellar-mcpusage
License & Attribution
MIT License — see LICENSE.
Maintained by @ijele-don. Originally inspired by pulsar (MIT, Copyright (c) 2026 pulsar community), rebuilt from the ground up with a zero-CLI-dependency core, Soroban diagnostics, MCP resources/prompts, and mainnet safety defaults.
Available Tools
12 toolsanalyze_contract_storageB
Inspect a Soroban contract instance storage (and optional extra LedgerKey XDRs), compute remaining TTL in ledgers/days, and flag oversized or expiring/archived entries.
Inputs: contract_id (required), network, additional_keys, size_threshold_bytes.
build_transactionB
Build an unsigned Stellar/Soroban TransactionEnvelope XDR (payment, change_trust, or invoke_contract) with automatic sequence lookup and safety inspection.
Inputs: operations (required), source_account (required), memo, network, +2 more.
decode_xdrB
Decode base64-encoded Stellar XDR (TransactionEnvelope, ScVal, LedgerKey, LedgerEntryData, DiagnosticEvent, or SorobanTransactionData) into readable JSON.
Inputs: xdr (required), type (required), network.
diagnose_soroban_errorA
Decode a Soroban host error string (e.g. "HostError: Error(Contract, #4)" or "Error(Storage, MissingValue)") into root cause, explanation, and suggested fix. Optionally resolves custom contract error names.
Inputs: error_message (required), network, contract_id.
fetch_contract_specA
Fetch and decode the ABI/spec (functions, structs, enums, unions, #[contracterror] codes) directly from a deployed Soroban contract WASM.
Inputs: contract_id (required), network.
get_accountB
Fetch Stellar account balances (XLM & issued assets), sequence number, thresholds, and signers.
Inputs: account_id (required), network, asset_code, asset_issuer.
get_contract_eventsB
Query recent Soroban contract events for a contract ID and decode their topics and values.
Inputs: contract_id (required), limit, network, start_ledger.
get_network_statusA
Check Soroban RPC health, latest ledger sequence, protocol version, endpoints, and mainnet write-policy status.
Inputs: network.
get_transactionA
Fetch a transaction by 64-char hex hash via Soroban RPC (with Horizon fallback) and decode its envelope, return value, and events.
Inputs: tx_hash (required), network.
inspect_xdrA
Decode a TransactionEnvelope XDR and run a security/safety audit (detecting account merges, signer/threshold changes, clawbacks, excessive fees, and Soroban host invocations).
Inputs: xdr (required), network.
simulate_transactionA
Simulate a base64 TransactionEnvelope XDR on Soroban RPC. Returns decoded return value, CPU/memory cost, min resource fee, decoded ledger footprint, events, restore preamble, or structured error diagnosis.
Inputs: xdr (required), network, contract_id.
submit_transactionA
Submit a transaction XDR to Soroban RPC (with Horizon fallback). Mainnet writes are BLOCKED by default unless ALLOW_MAINNET_WRITES=true.
Inputs: xdr (required), sign, network, wait_for_result, +1 more.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 12 tools
Most tools have clearly distinct purposes tied to a specific resource or pipeline stage (simulate, build, submit, diagnose). The main overlap is between decode_xdr and inspect_xdr, both of which decode a TransactionEnvelope, but descriptions clarify that inspect_xdr adds a security audit while decode_xdr handles broader XDR types.
Names consistently follow snake_case verb_noun form (get_account, simulate_transaction, build_transaction, submit_transaction). Minor deviation: retrieval verbs alternate between get_ (get_account, get_transaction, get_contract_events) and fetch_ (fetch_contract_spec), plus a couple of verb_xdr forms, but overall it is predictable.
Twelve tools is well within the ideal range and each maps to a distinct stage of the Soroban workflow (inspect, decode, simulate, build, submit, diagnose). No filler or redundant tools are present.
The surface covers the core lifecycle well: network status, account/transaction lookup, contract spec, simulation, error diagnosis, XDR decode/audit, storage, events, and build/submit. Gaps remain around contract deployment (upload WASM, create contract) and richer transaction building (only payment, change_trust, invoke_contract), which agents may need to work around.
Maintenance
Related MCP Connectors
Wallet trust scores for AI agents. Stellar, XRPL, EVM 81+ chains. OFAC sanctions. x402 payments. Multi-chain wallet trust scoring for AI agents. Score Stellar, XRPL, and EVM wallets across 81+ chains with real-time OFAC/UN/EU sanctions screening. Pay per query via x402 USDC micropayments on Stellar or Base — no accounts, no API keys required.
XRPL token rug-checks, issuer reputation & AMM data for AI agents. Pay-per-call USDC via x402.
Provide AI agents and automation tools with contextual access to blockchain data including balance…
Read-only smart-contract security intelligence for autonomous agents.
Related MCP Servers
- AlicenseAqualityCmaintenanceAn MCP server that provides Stellar blockchain tools for account queries, Soroban contract simulation, and boilerplate generation within compatible AI IDEs.3MIT
- AlicenseAqualityDmaintenanceMCP server for Stellar that enables AI assistants to explain account holdings, diagnose transaction failures, and describe Soroban contracts in plain language, with optional payment proposal flow.3Apache 2.0
- AlicenseAqualityDmaintenanceEnables AI agents to build, test, deploy, invoke, and inspect Soroban smart contracts on the Stellar network through structured MCP tools and resources.68 npmMIT
- AlicenseAqualityBmaintenanceEnables AI assistants to query read-only Stellar analytics over MCP: network status and fees, asset data with look-alike warnings, SDEX order books, account balances with spendable XLM, and DeFi TVL. It requires no API keys and refuses secret keys, answering from public APIs like Horizon, StellarExpert and DefiLlama.652 npmMIT