A Model Context Protocol (MCP) server implementation for interacting with the Stellar blockchain network. This server enables AI agents and LLMs to perform Stellar blockchain operations through a standardized interface.
Model Context Protocol (MCP) is an open protocol that standardizes how applications provide context to LLMs (Large Language Models). Think of MCP like a USB-C port for AI applications - it provides a standardized way to connect AI models to different data sources and tools.
This MCP server implementation provides AI agents with direct access to Stellar blockchain functionality, enabling them to:
- Create and manage Stellar accounts
- Fund accounts with testnet lumens
- Fetch account information and transaction history
- Sign and submit Soroban smart contract transactions
- Interact with Passkey wallets
- Account Management
- Create new Stellar accounts
- Fund accounts using Friendbot (testnet)
- Fetch account details and balances
- Transaction Operations
- View transaction history
- Sign and submit Soroban transactions
- Support for both regular Stellar wallets and Passkey wallets
- Smart Contract Integration
- Interact with Soroban smart contracts
- Handle contract authorization
- Support for wallet contract interactions
- Node.js (v16 or higher)
- npm or yarn
- A Stellar testnet account (for testing)
You can install and run the server directly from npm:
- Clone the repository:
git clone https://github.com/JoseCToscano/stellar-mcp.git
cd stellar-mcp
- Install dependencies:
npm install
The server requires several environment variables to function properly:
NETWORK_PASSPHRASE
: Identifies the Stellar network (testnet/public)RPC_URL
: Soroban RPC endpoint for blockchain interactions
LAUNCHTUBE_URL
andLAUNCHTUBE_JWT
: Required for passkey wallet integration. Launchtube is used to handle passkey signatures and transaction submissions.MERCURY_URL
,MERCURY_JWT
, andMERCURY_PROJECT_NAME
: Required for passkey wallet management and data storage through Mercury's infrastructure.WALLET_WASM_HASH
: Hash of the wallet contract WASM for verification purposes.
The server supports two special resource files that can be used to provide context to AI agents:
-
AGENT_KEYPAIR_FILE_PATH
: Path to a file storing the AI agent's Stellar keypair. This allows the agent to maintain a consistent identity across sessions. -
USAGE_GUIDE_FILE_PATH
: Path to a markdown file containing usage guidelines and examples. This file is made available as a resource to AI agents to help them understand how to interact with the Stellar blockchain.
Create a .env
file with your configuration:
# Core Variables
NETWORK_PASSPHRASE="Test SDF Network ; September 2015"
RPC_URL="https://soroban-testnet.stellar.org"
# Passkey Integration
LAUNCHTUBE_URL="https://testnet.launchtube.xyz"
LAUNCHTUBE_JWT="your_launchtube_jwt"
MERCURY_URL="https://api.mercurydata.app"
MERCURY_JWT="your_mercury_jwt"
MERCURY_PROJECT_NAME="your_project_name"
WALLET_WASM_HASH="your_wallet_wasm_hash"
# Resource Files
AGENT_KEYPAIR_FILE_PATH="/path/to/agent-keys.txt"
USAGE_GUIDE_FILE_PATH="/path/to/USAGE.md"
npm run build
node build/mcp-server.js
To connect the MCP server to Claude Desktop, add the following configuration to your Claude Desktop config file (usually located at ~/Library/Application Support/Claude/claude_desktop_config.json
):
{
"servers": {
"stellar-mcp": {
"command": "node",
"args": ["/path/to/your/stellar-mcp/build/mcp-server.js"],
"env": {
"LAUNCHTUBE_URL": "https://testnet.launchtube.xyz",
"LAUNCHTUBE_JWT": "your_launchtube_jwt",
"AGENT_KEYPAIR_FILE_PATH": "/path/to/your/stellar-mcp/agent-keys.txt",
"SAC_GUIDE_FILE_PATH": "/path/to/your/stellar-mcp/STELLAR_TOKENS_SAC.md",
"USAGE_GUIDE_FILE_PATH": "/path/to/your/stellar-mcp/USAGE.md",
"WALLET_WASM_HASH": "a8860280cb9f9335b623f81a4e80e89a7920024275b177f2d4bffa6aa5fb5606",
"RPC_URL": "https://soroban-testnet.stellar.org",
"NETWORK_PASSPHRASE": "Test SDF Network ; September 2015",
"MERCURY_JWT": "your_mercury_jwt",
"MERCURY_URL": "https://api.mercurydata.app",
"MERCURY_PROJECT_NAME": "your_mercury_project_name"
}
}
}
}
Make sure to:
- Replace
/path/to/your/
with your actual project path - Obtain the necessary API keys and tokens:
LAUNCHTUBE_JWT
: From LaunchtubeMERCURY_JWT
: From Mercury Data
- Create the required files:
agent-keys.txt
: For storing AI agent's Stellar keypairSTELLAR_TOKENS_SAC.md
: Token directory (provided)USAGE.md
: Usage guidelines
After adding the configuration, restart Claude Desktop for the changes to take effect.
// Example MCP tool call
await server.tool('create-account', {});
// Example MCP tool call
await server.tool('fund-account', {
address: 'GCYK...KLMN',
});
// Example MCP tool call
await server.tool('get-account', {
address: 'GCYK...KLMN',
});
// Example MCP tool call
await server.tool('sign-and-submit-transaction', {
transactionXdr: 'AAAAAgA...',
contractId: 'CC...',
secretKey: 'SDFG...',
});
The sign-and-submit-transaction
tool is specifically designed to handle Soroban smart contract transactions. It provides two key capabilities:
- Accepts pre-assembled transaction XDRs from Soroban contract invocations
- Handles proper transaction signing sequence
- Manages transaction submission and confirmation
- Provides detailed error handling for contract-specific failures
The tool supports two types of transaction signing:
await server.tool('sign-and-submit-transaction', {
transactionXdr: 'AAAAAgA...',
contractId: 'CC...',
secretKey: 'SDFG...', // Standard Stellar secret key or Policy Signer's secret key
});
- The tool automatically interfaces with Launchtube for transaction submission
- Handles policy-based authorization flows
- Provides proper error handling for policy-based rejections
This dual signing capability makes the tool versatile for both traditional Stellar accounts and modern smart wallet implementations.
The main server implementation that exposes Stellar blockchain functionality through MCP tools:
create-account
: Generates new Stellar keypairsfund-account
: Funds testnet accounts using Friendbotget-account
: Retrieves account informationget-transactions
: Fetches transaction historysign-and-submit-transaction
: Signs and submits Soroban transactions
Helper functions for:
- Passkey wallet integration
- Transaction signing logic
- Resource file handling
- Launchtube submission
- SAC (Stellar Asset Contract) client creation
Contributions are welcome! Please feel free to submit a Pull Request.
ISC
For questions and support, please open an issue in the GitHub repository.