xian-mcp-server

Endogen/xian-mcp-server

3.2

If you are the rightful owner of xian-mcp-server and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to dayong@mcphub.com.

A Model Context Protocol (MCP) server for interacting with the XIAN blockchain network, designed for local use to manage wallets, send transactions, and deploy smart contracts.

Tools
13
Resources
0
Prompts
0

Xian MCP Server

A Model Context Protocol (MCP) server for interacting with the XIAN blockchain network. This server enables AI assistants to manage wallets, send transactions, query smart contracts, and interact with the XIAN blockchain and DEX.

⚠️ IMPORTANT: This server handles private keys and is intended for LOCAL USE ONLY. Never expose this server to the internet or use it with production wallets.

Features

  • ✅ Create new wallets (standard and HD wallets)
  • ✅ Import wallets from private keys or mnemonics
  • ✅ Check balances (XIAN and custom tokens)
  • ✅ Send transactions and tokens
  • ✅ Query and interact with smart contracts
  • ✅ Sign, verify, encrypt, and decrypt messages
  • ✅ Simulate transactions for gas estimation
  • ✅ Query token information by symbol or contract
  • ✅ Trade on the XIAN DEX (buy/sell tokens)
  • ✅ Get real-time DEX price data

Prerequisites

  • Docker Desktop installed and running
  • For Claude Desktop: Claude Desktop app (macOS, Windows, or Linux)
  • For LM Studio: LM Studio version 0.3.17 or later

Quick Start

1. Clone the Repository

git clone https://github.com/endogen/xian-mcp-server.git
cd xian-mcp-server

2. Build the Docker Container

Option A: Using Docker Compose (Recommended)
docker-compose build
Option B: Using Docker directly
docker build -t xian-mcp-server .

3. Testing

The repo includes a test file with the proper MCP handshake that can be used to test

Direct test
python xian_server.py < test_requests.jsonl
Docker test
docker run --rm -i xian-mcp-server < test_requests.jsonl

This test validates that:

  • ✅ The MCP server starts correctly and accepts stdio communication
  • ✅ The MCP protocol handshake completes successfully (initialize → initialized → tools/list)
  • ✅ All Python dependencies are properly installed
  • ✅ The server can serialize and respond with valid JSON-RPC 2.0 messages
  • ✅ All Xian blockchain tools are registered and available

You should see two JSON responses:

  1. Initialize response (id:1)
  2. Tools list response (id:2)
Implementation Tests

To test the actual Xian blockchain functionality (wallets, transactions, cryptography), run the comprehensive test suite:

# Install test dependencies
pip install pytest pytest-asyncio

# Run the tests
python test_xian_server.py
Before running the tests:
  1. Open test_xian_server.py and configure the test values at the top of the file
  2. Update the values with real testnet data (addresses, private keys, etc.)
  3. The tests use testnet by default (https://testnet.xian.org)
What the tests cover:
  • ✅ Wallet creation and import
  • ✅ Balance and state queries
  • ✅ Transaction simulation and retrieval
  • ✅ Cryptographic operations - signing, encryption
  • ✅ Error handling for invalid inputs
Expected output:
  • Tests will show ✅ for passed tests
  • Tests requiring configuration will be skipped with helpful messages
  • Failed tests will show detailed error information

Run these tests before building the Docker container to ensure all functionality works correctly with your network configuration.

Installation Guide

For Claude Desktop

Step 1: Configure Claude Desktop

Locate your Claude Desktop configuration file:

  • macOS: ~/Library/Application\ Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json
  • Linux: ~/.config/Claude/claude_desktop_config.json
Step 2: Add the XIAN Server

Edit the configuration file and add the XIAN server:

{
  "mcpServers": {
    "xian": {
      "command": "docker",
      "args": [
        "run",
        "-i",
        "--rm",
        "xian-mcp-server"
      ]
    }
  }
}

If you already have other MCP servers configured, add the "xian" entry alongside them.

Step 3: Restart Claude Desktop
  1. Completely quit Claude Desktop (check system tray/menu bar)
  2. Start Claude Desktop again
  3. The XIAN tools should now be available

For LM Studio

Step 1: Open MCP Configuration
  1. Launch LM Studio
  2. Click the Program tab (>_) in the right sidebar
  3. Click Install > Edit mcp.json
Step 2: Add the XIAN Server

Add this configuration to your mcp.json:

{
  "xian": {
    "command": "docker",
    "args": [
      "run",
      "-i",
      "--rm",
      "xian-mcp-server"
    ]
  }
}

The default location for this file is:

  • macOS/Linux: ~/.lmstudio/mcp.json
  • Windows: %USERPROFILE%\.lmstudio\mcp.json
Step 3: Save and Use

Save the file - LM Studio automatically reloads MCP servers when you save changes.

Advanced: Docker MCP Toolkit (Claude Desktop)

If you're using Docker MCP Toolkit, you can add XIAN to your custom catalog:

  1. Copy the example catalog:
cp custom_catalog.yaml ~/.docker/mcp/catalogs/custom.yaml
  1. Update your Claude Desktop config to use both catalogs:
{
  "mcpServers": {
    "mcp-toolkit-gateway": {
      "command": "docker",
      "args": [
        "run", "-i", "--rm",
        "-v", "/var/run/docker.sock:/var/run/docker.sock",
        "-v", "~/.docker/mcp:/mcp",
        "docker/mcp-gateway",
        "--catalog=/mcp/catalogs/docker-mcp.yaml",
        "--catalog=/mcp/catalogs/custom.yaml",
        "--config=/mcp/config.yaml",
        "--registry=/mcp/registry.yaml",
        "--tools-config=/mcp/tools.yaml",
        "--transport=stdio"
      ]
    }
  }
}

MCP Details

  • Transport: stdio (mcp.server), serving list_tools and call_tool with TextContent JSON responses.
  • Tools include wallet/HD wallet, balances/transactions, contract state/source, token queries, DEX helpers, and crypto (sign/verify/encrypt/decrypt). Use tools/list (see test_requests.jsonl) to discover the full schema.
  1. Add to registry:
echo 'registry:\n  xian:\n    ref: ""' >> ~/.docker/mcp/registry.yaml

Configuration

Environment Variables

The server supports these environment variables:

  • XIAN_NODE_URL: XIAN node URL (default: https://node.xian.org)
  • XIAN_CHAIN_ID: XIAN chain ID (default: xian-1)
  • XIAN_GRAPHQL: GraphQL endpoint URL (default: https://node.xian.org/graphql)
Using Docker Compose with custom values

Create a .env file in the project directory (or copy and rename .env.example):

XIAN_NODE_URL=https://node.xian.org
XIAN_CHAIN_ID=xian-1
XIAN_GRAPHQL=https://node.xian.org/graphql

Then run:

docker-compose up
Using Docker directly

To use custom values with Docker:

{
  "xian": {
    "command": "docker",
    "args": [
      "run", "-i", "--rm",
      "--env", "XIAN_NODE_URL=https://your-node.example.com",
      "--env", "XIAN_CHAIN_ID=testnet-1",
      "--env", "XIAN_GRAPHQL=https://your-node.example.com/graphql",
      "xian-mcp-server"
    ]
  }
}

Usage Examples

Once installed, you can interact with the XIAN blockchain through your AI assistant:

Basic Wallet Operations

  • "Create a new XIAN wallet"
  • "Create an HD wallet with recovery phrase"
  • "Import wallet from private key [key]"
  • "Restore HD wallet from mnemonic: [12/24 word phrase]"

Balance and Transactions

  • "Check balance for address 8bf21c7dc3a4ff32996bf56a665e1efe3c9261cc95bbf82552c328585c863829"
  • "Send 10 XIAN to [address] using private key [key]"
  • "Send 100 custom_token to [address] using private key [key]"
  • "Get transaction details for hash [tx_hash]"
  • "Simulate sending 100 tokens to estimate gas costs"

Smart Contracts

  • "Get the source code of contract 'currency'"
  • "Check the state of variable 'balances:address123' in contract 'currency'"
  • "Read contract state: con_token.metadata:token_symbol"
  • "Simulate calling function 'transfer' on contract 'currency'"

Token Information

  • "Find the contract address for token symbol USDT"
  • "Get token metadata for contract con_my_token"
  • "What's the current DEX price of con_my_token in XIAN?"

DEX Trading

  • "Buy 100 con_my_token with currency (XIAN) using private key [key]"
  • "Sell 50 con_my_token for currency with 2% slippage"
  • "Get the current price of con_my_token against XIAN"

Cryptographic Operations

  • "Sign the message 'Hello XIAN' with private key [key]"
  • "Verify signature [sig] for message 'Hello XIAN' from address [addr]"
  • "Encrypt a message from [sender_key] to [recipient_public_key]"
  • "Decrypt message [encrypted] from [sender_public_key] using [receiver_private_key]"

Available Tools

Wallet Management

ToolDescriptionParametersRequires Private Key
create_walletGenerate new random walletNoneNo
create_wallet_from_private_keyImport wallet from private keyprivate_keyYes (to import)
create_hd_walletCreate new HD wallet with mnemonicNoneNo
create_hd_wallet_from_mnemonicRestore HD wallet from mnemonicmnemonicNo

Balance and Transactions

ToolDescriptionParametersRequires Private Key
get_balanceCheck address balanceaddress, token_contractNo
send_transactionSend generic transactionprivate_key, contract, function, kwargsYes
send_tokensSend tokens to addressprivate_key, to_address, token_contract, amountYes
get_transactionGet transaction detailstx_hashNo
simulate_transactionEstimate gas costsaddress, contract, function, kwargsNo

Smart Contracts

ToolDescriptionParametersRequires Private Key
get_stateRead contract state variablestate_keyNo
get_contractGet contract source codecontract_nameNo

Token Information

ToolDescriptionParametersRequires Private Key
get_token_contract_by_symbolFind contract by token symboltoken_symbolNo
get_token_data_by_contractGet token metadatatoken_contractNo

DEX Operations

ToolDescriptionParametersRequires Private Key
buy_on_dexBuy tokens on DEXprivate_key, buy_token, sell_token, amount, slippage, deadline_minYes
sell_on_dexSell tokens on DEXprivate_key, sell_token, buy_token, amount, slippage, deadline_minYes
get_dex_priceGet token price on DEXtoken_contract, base_contractNo

Cryptographic Operations

ToolDescriptionParametersRequires Private Key
sign_messageSign a messageprivate_key, messageYes
verify_signatureVerify message signatureaddress, message, signatureNo
encrypt_messageEncrypt message between partiessender_private_key, receiver_public_key, messageYes
decrypt_messageDecrypt received messagereceiver_private_key, sender_public_key, encrypted_messageYes

Troubleshooting

Container won't build

  • Ensure Docker Desktop is running
  • Check that you have sufficient disk space
  • Try docker system prune to clean up old images

Tools don't appear in Claude/LM Studio

  • Verify the container built successfully: docker images | grep xian
  • Check the config file syntax (must be valid JSON)
  • Ensure you completely restarted the application
  • Test the container directly: docker run --rm xian-mcp-server

Connection errors

  • Verify the XIAN node URL is accessible
  • Check your internet connection
  • Try the default node: https://node.xian.org

Permission denied errors

  • On Linux/macOS: Ensure Docker has necessary permissions
  • On Windows: Run Docker Desktop as administrator if needed

Development

Running without Docker

For development, you can run the server directly:

# Install dependencies
pip install -r requirements.txt

# Run the server
python xian_server.py

Resources

Security Notice

This server handles sensitive cryptographic material. Always:

  • Use only for local development and testing
  • Never expose to the internet
  • Keep private keys secure
  • Use testnet for experimentation
  • Verify all transactions before execution