xian-mcp-server
OfficialSummary: This local MCP/HTTP Xian server lets you query chain/indexed data, inspect contracts and state, simulate calls, verify signatures, and plan/monitor DEX activity.
Check address balances and list all token balances with pagination.
Discover token contracts and metadata by symbol or contract.
Read BDS/indexed status, blocks, transactions, events, state history, per-tx/block state writes, and developer rewards.
Inspect shielded wallet output tags and wallet history.
Read contract source and state variables.
Simulate transactions to estimate chi without executing.
Verify message signatures.
Query DEX prices/pairs and get exact-in or exact-out quotes.
Create single-use DEX plans for swaps, adding liquidity, and removing liquidity with slippage/deadline settings.
Wait for live finalized DEX events or list indexed DEX/LP events with cursor pagination.
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., "@xian-mcp-server What is the current block height on Xian?"
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.
xian-mcp-server
xian-mcp-server is a Model Context Protocol (MCP) server that exposes the
Xian blockchain to AI assistants and HTTP clients. It wraps xian-tech-py
to offer wallet management, transactions, smart-contract reads and writes,
indexed BDS reads, shielded wallet sync, token discovery, DEX trading, and
cryptographic operations through a single tool catalog.
The server speaks two transports:
Mode | Transport | Use case |
MCP (stdio) | JSON-RPC over | Claude Desktop, LM Studio, MCP clients |
HTTP (REST) | JSON over HTTP | Web apps, AI tool-calling loops, scripts |
⚠️ LOCAL USE ONLY. The server handles private keys. Do not expose it to the internet or use it with production wallets.
See CLAUDE.md for the full AI-facing tool reference and chain-specific concepts (chi, state-key format, address vs. public key, DEX workflow, error patterns).
Token and DEX tools accept a decimal string or an integer for an amount.
Use "1.000000000000000000000000000001" to retain all 30 fractional places.
For generic transaction and simulation arguments use
{"amount":{"__fixed__":"1.25"}}. An ordinary string in a generic argument
stays a string. Returned decimal values use plain strings and integers outside
the JSON safe integer range use the __big_int__ wrapper. DEX plans expose
the exact typed calls passed to simulation and signing.
Request Shape
flowchart LR
Assistant["AI assistant or script"] --> Transport["MCP stdio or HTTP REST"]
Transport --> Catalog["Shared tool catalog"]
Catalog --> SDK["xian-tech-py"]
SDK --> Node["Xian node RPC"]
SDK --> Live["CometBFT live events"]
SDK --> BDS["BDS indexed APIs"]
Catalog --> Wallets["Local wallet operations"]
Catalog --> Crypto["Local crypto helpers"]
Catalog --> DEX["DEX helper tools"]Related MCP server: gulltoppr
Quick Start
Build the Docker image (recommended):
git clone https://github.com/xian-technology/xian-mcp-server.git
cd xian-mcp-server
docker build --target pypi -t xian-mcp-server .This standalone build uses the dependency revisions in uv.lock. To build against
sibling SDK checkouts instead, use docker compose build or:
docker buildx build --target local --load -t xian-mcp-server \
--build-context xian_py=../xian-py \
--build-context xian_accounts=../xian-contracting/packages/xian-accounts \
--build-context xian_runtime_types=../xian-contracting/packages/xian-runtime-types \
.Smoke-test the MCP handshake:
docker run --rm xian-mcp-server python scripts/smoke_stdio.py
# or, without Docker:
uv run python scripts/smoke_stdio.pyThe smoke test completes the handshake, verifies the simulation tool is available, and prints the number of advertised tools.
Use with Claude Desktop
Edit your Claude Desktop config (~/Library/Application Support/Claude/claude_desktop_config.json
on macOS, %APPDATA%\Claude\claude_desktop_config.json on Windows,
~/.config/Claude/claude_desktop_config.json on Linux):
{
"mcpServers": {
"xian": {
"command": "docker",
"args": ["run", "-i", "--rm", "xian-mcp-server"]
}
}
}Quit Claude Desktop fully and restart it; the Xian tools will be available.
Use with LM Studio
In LM Studio's Program sidebar, choose Install → Edit mcp.json and add:
{
"xian": {
"command": "docker",
"args": ["run", "-i", "--rm", "xian-mcp-server"]
}
}LM Studio reloads MCP servers automatically when the file is saved.
Run the HTTP Server
uv run xian-mcp-http # bare-metal
export XIAN_MCP_HTTP_TOKEN="$(openssl rand -hex 32)"
# Optional: publish Docker Compose HTTP on IPv6 loopback instead of IPv4.
# export HTTP_PUBLISH_HOST="::1"
docker compose up xian-mcp-http
docker run -p 127.0.0.1:8100:8100 \
-e HTTP_HOST=0.0.0.0 \
-e XIAN_MCP_HTTP_TOKEN="${XIAN_MCP_HTTP_TOKEN}" \
xian-mcp-server xian-mcp-httpEndpoints:
Method | Path | Description |
|
| List all tools with their JSON-Schema params |
|
| Call a tool by name with a JSON body |
|
| Health check |
curl http://localhost:8100/tools
curl -X POST http://localhost:8100/tools/get_balance \
-H "Content-Type: application/json" \
-d '{"address": "your_address_here"}'HTTP binds to 127.0.0.1 by default in bare-metal mode. Docker examples bind
the host port to 127.0.0.1 by default while the process listens on 0.0.0.0
inside the container. With Compose, set HTTP_PUBLISH_HOST=::1 to publish the
host port on IPv6 loopback, then call http://[::1]:8100/tools.
Unsafe wallet/signing tools are hidden from GET /tools and rejected by
POST /tools/{name} unless XIAN_MCP_ENABLE_UNSAFE_WALLET_TOOLS=1 is set.
When unsafe tools are enabled, or when HTTP binds to a non-loopback address, set
XIAN_MCP_HTTP_TOKEN and send it as a bearer token. IPv4 loopback,
localhost, and IPv6 loopback binds such as ::1 or [::1] do not require a
token unless unsafe tools are enabled or a token is explicitly configured. IPv6
wildcard :: and other non-loopback IPv6 binds require a token.
DEX discovery, quotes, and plans are read-only and remain available with the
unsafe gate disabled. The three dex_submit_* tools are value-moving tools and
use the same unsafe-wallet gate and HTTP bearer-token requirements as sends and
legacy DEX helpers. Each planner stores an immutable canonical plan in a
process-local registry and returns its complete audit JSON with an opaque
plan_id, SHA-256 digest, issue time, and expiry. After confirmation, pass only
that plan_id and the private key to the matching submitter. Submission claims
the stored plan exactly once before wallet validation or network work, simulates
calls by default, then submits its required approvals and exact router call.
Plans expire after five minutes by default, may be evicted at the registry
bound, and do not survive a server restart; create a fresh plan in those cases.
export XIAN_MCP_ENABLE_UNSAFE_WALLET_TOOLS=1
export XIAN_MCP_HTTP_TOKEN="$(openssl rand -hex 32)"
curl http://localhost:8100/tools \
-H "Authorization: Bearer ${XIAN_MCP_HTTP_TOKEN}"
curl -X POST http://localhost:8100/tools/create_wallet \
-H "Authorization: Bearer ${XIAN_MCP_HTTP_TOKEN}"Browser CORS is disabled by default. To allow a local browser client, list exact
origins with XIAN_MCP_HTTP_CORS_ORIGINS; wildcard CORS is rejected:
export XIAN_MCP_HTTP_CORS_ORIGINS="http://localhost:3000,http://127.0.0.1:3000"The HTTP wrapper (http_server.py) is designed to be reusable with any MCP
server that uses the TOOL_SPECS pattern; see the source for the
create_app(tool_specs=...) helper.
Principles
Local-only by default. The server is built around private-key custody. It must not be exposed to the internet or paired with production wallets.
Two transports, one tool catalog. Stdio MCP and HTTP REST expose the exact same tools and schemas. The transport is a thin shell.
AI-friendly safety conventions. Errors return human-readable strings. Diagnostics omit private keys. Unsafe wallet creation/import tools return secret material by design; protect their results. Confirmation is expected for any value-moving operation; see CLAUDE.md.
xian-tech-pyis the only SDK. All blockchain interactions go throughxian-tech-py's sync / async clients. Live DEX waits use its CometBFT WebSocket watcher, while indexed reads wrap its BDS surface.Read-mostly indexed surface. BDS-backed reads (blocks, txs, events, state history, shielded sync) are read-only and most useful when pointed at a node with BDS-backed indexed APIs enabled.
Tool Surface
Group | Tools (representative) |
Wallets |
|
Balances / txs |
|
Contracts / state |
|
Token discovery |
|
DEX discovery / planning |
|
DEX events |
|
DEX market data |
|
dex_list_events returns newest-first events for browsing. Start replay
with after_id: 0 or an existing cursor to get ascending events. Commit
next_after_id only for a response with complete: true. A partial
response retains the input cursor so a temporary source failure can be
retried. Wide cursors are returned as decimal strings.
| DEX submission | dex_submit_swap, dex_submit_add_liquidity, dex_submit_remove_liquidity; legacy single-pair helpers: buy_on_dex, sell_on_dex |
| Indexed / BDS | get_bds_status, get_developer_rewards, list_blocks, get_block, get_block_by_hash, get_indexed_tx, list_txs_for_block, list_txs_by_sender, list_txs_by_contract, get_events_for_tx, list_events, get_state_history, get_state_for_tx, get_state_for_block |
| Shielded sync | list_shielded_output_tags, list_shielded_wallet_history |
| Crypto | sign_message, verify_signature, encrypt_message, decrypt_message |
Use tools/list (see test_requests.jsonl) to discover the full schema.
buy_on_dex and sell_on_dex call con_dex_helper on the direct pair. Each
quotes the pair first and signs its own price bound: buy_on_dex signs
max_input (quoted input plus the slippage percentage, rounded up) and
sell_on_dex signs min_out (quoted output minus slippage, rounded down).
The contract reverts when execution would cross that bound. The result carries
the quote and bound under trade_bounds. Both need a sell_token allowance to
con_dex_helper (at least max_input for a buy, amount for a sell).
create_hd_wallet(account_index=0) and
create_hd_wallet_from_mnemonic(mnemonic, account_index=0) use the same indexed
Xian mnemonic derivation as the browser/mobile wallets and Python's
Wallet.from_mnemonic. The optional integer index ranges from 0 through
4294967295. Save the phrase and selected index to restore the same address.
Results include numeric account_index, the normalized phrase, and Xian and
Ethereum keys. The Ethereum helper keeps its default account 0, identified by
numeric ethereum_account_index: 0 in the result. These tools remain
behind the unsafe-wallet opt-in, and their results contain secret key material.
Configuration
Variable | Purpose | Default |
| Node RPC URL |
|
| Chain ID |
|
| GraphQL endpoint |
|
| Include SDK |
|
| Enable wallet creation/import, signing, encryption/decryption, sends, and DEX trade helpers |
|
| HTTP bind address |
|
| HTTP bind port |
|
| Docker Compose host interface for publishing HTTP mode |
|
| Bearer token for HTTP tools; required for unsafe tools or non-loopback binds | unset |
| Comma-separated browser origins allowed to call HTTP mode | unset |
| Process-local DEX plan lifetime (bounded to 30-900 seconds) |
|
| Maximum stored DEX plans before oldest-first eviction (bounded to 1-1000) |
|
The defaults target a local current-code stack. Drop overrides into a .env
file (template in .env.example) when using docker-compose.
Key Files
xian_server.py— stdio MCP server entrypoint.dex_plan_registry.py— bounded process-local storage for immutable, expiring, single-use DEX plans.http_server.py— reusable HTTP REST wrapper around the same tool specs.serialization.py— explicit tool-result serialization; types without an encoding raiseTypeErrorand surface as tool errors.mcp.json,custom_catalog.yaml— example client configurations.test_requests.jsonl— sample MCP handshake messages.tests/—unit/(deterministic) andintegration/(live-network) coverage; shared fixtures intests/shared.py.Dockerfile,docker-compose.yml— container build and runtime topology.CLAUDE.md— AI assistant integration guide and detailed tool reference.
Validation
The standard setup uses locked dependencies and works without sibling
checkouts. Mnemonic tools require xian-tech-py 0.5.3 or newer and use its
Wallet.from_mnemonic API for canonical indexed Xian accounts.
uv sync --frozen --extra dev
uv run pytest -q # deterministic unit tests
docker run --rm xian-mcp-server python scripts/smoke_stdio.py # MCP handshake smoke testTo test an unreleased sibling SDK explicitly after the standard setup:
uv pip install \
-e ../xian-contracting/packages/xian-runtime-types \
-e ../xian-contracting/packages/xian-accounts \
-e "../xian-py[eth,hd]"
uv run --no-sync pytest -q
uv run --no-sync python scripts/smoke_stdio.pyUse --no-sync while testing sibling overrides. Run uv sync --frozen --extra dev
to return to the locked published package versions. Docker Compose and the
local Docker target retain their explicit sibling build contexts.
Live-network integration tests are opt-in and submit small transactions against the configured dev node:
export XIAN_NODE_URL=http://127.0.0.1:27657
export XIAN_CHAIN_ID=xian-localnet-1
export XIAN_MCP_LIVE_PRIVATE_KEY=<funded-dev-private-key>
export XIAN_MCP_LIVE_TOKEN_SYMBOL=XDT
export XIAN_MCP_LIVE_TOKEN_CONTRACT=con_dex_demo_token
export XIAN_MCP_LIVE_DEX_TOKEN=con_dex_demo_token
export XIAN_MCP_LIVE_DEX_BASE=currency
# Optional: also add and remove a small liquidity position.
export XIAN_MCP_LIVE_DEX_LIQUIDITY=1
uv run pytest -q tests/integration/test_live_tool_surface.pyCI runs unit tests and the MCP handshake smoke test on every push and PR.
Live integration tests run on a daily schedule and via manual
workflow_dispatch.
Related Docs
CLAUDE.md — AI-assistant integration guide, full tool reference, security guidelines, common workflows
test_requests.jsonl — sample MCP handshake messages smoke input
xian-tech-py— the underlying Python SDK
Operational logs
Both entrypoints write bounded, single-line UTC diagnostics to stderr using
timestamp | LEVEL | mcp/component | message | key=value records. Stdio stdout
is reserved for MCP JSON-RPC. Failed tools carry a generated request ID, tool
name, safe reason, exception type and stack locations; tool arguments, exception
messages, locals, signing material and credential-bearing endpoints are omitted.
Routine reads and fallback diagnostics are DEBUG; HTTP access logging is disabled.
The server creates no log files. Docker or the host supervisor owns retention of stderr: workspace Docker defaults are 50 MiB segments, five segments per container, with no age guarantee. Host capture expires files after seven days and caps its aggregate at 250 MiB, discarding older entries sooner when necessary.
Available Tools
35 toolsdex_get_pairC
Get a canonical DEX pair by id or token contracts
Inputs: pair_id, token_a, token_b.
dex_list_eventsA
List indexed canonical DEX or bound LP-token events with a restart-safe cursor
Inputs: event, limit, after_id, contract.
dex_list_pairsB
List canonical Xian DEX pairs and reserves
Inputs: limit, token, offset.
dex_plan_add_liquidityC
Issue a single-use addLiquidity plan with exact calls, digest, and expiry
Inputs: account (required), token_a (required), token_b (required), recipient (required), +4 more.
dex_plan_remove_liquidityC
Issue a single-use removeLiquidity plan with exact calls, digest, and expiry
Inputs: account (required), token_a (required), token_b (required), liquidity (required), +3 more.
dex_plan_swapC
Issue a single-use DEX swap plan with fresh quote, exact calls, digest, and expiry
Inputs: amount (required), account (required), token_in (required), recipient (required), +7 more.
dex_quote_exact_inB
Quote the best route and output for an exact input amount
Inputs: token_in (required), amount_in (required), token_out (required), path, +2 more.
dex_quote_exact_outC
Quote the least input required for a desired output amount
Inputs: token_in (required), token_out (required), amount_out (required), path, +2 more.
dex_wait_live_eventA
Wait for low-latency finalized DEX events over CometBFT WebSocket without BDS; non-durable, so use dex_list_events for replay
Inputs: event (required), contract (required), caller, signer, +3 more.
get_balanceB
Check the balance of a XIAN address for a specific token
Inputs: address (required), token_contract.
get_bds_statusA
Get indexed/BDS availability and synchronization status for the connected node
Inputs: no named parameters.
get_blockB
Get an indexed block by height
Inputs: height (required).
get_block_by_hashB
Get an indexed block by block hash
Inputs: block_hash (required).
get_contract_sourceC
Get the source code of a smart contract
Inputs: contract_name (required).
get_developer_rewardsA
Get indexed developer reward totals for a recipient key
Inputs: recipient_key (required).
get_dex_priceA
Get the current price of a token on the DEX
Inputs: token_contract (required), base_contract.
get_events_for_txB
List indexed events emitted by a transaction
Inputs: tx_hash (required).
get_indexed_txB
Get an indexed transaction by transaction hash
Inputs: tx_hash (required).
get_stateC
Read a state variable from a smart contract
Inputs: state_key (required).
get_state_for_blockA
List indexed state writes produced by a block height or block hash
Inputs: block_ref (required).
get_state_for_txB
List indexed state writes produced by a transaction
Inputs: tx_hash (required).
get_state_historyC
List indexed history entries for a state key
Inputs: key (required), limit, offset.
get_token_balancesA
List all token balances for a XIAN address with pagination support
Inputs: address (required), limit, offset, include_zero.
get_token_contract_by_symbolB
Find the contract address for a token by its symbol
Inputs: token_symbol (required).
get_token_data_by_contractC
Get metadata for a token by its contract address
Inputs: token_contract (required).
get_transactionA
Get details of a transaction by its hash
Inputs: tx_hash (required).
list_blocksC
List indexed blocks with pagination
Inputs: limit, offset.
list_eventsB
List indexed events for a contract and event name
Inputs: event (required), contract (required), limit, offset, +1 more.
list_shielded_output_tagsC
List indexed shielded output tags for a wallet sync tag
Inputs: tag_value (required), kind, limit, offset, +1 more.
list_shielded_wallet_historyC
List indexed shielded wallet history for a wallet sync tag
Inputs: tag_value (required), kind, limit, after_note_index.
list_txs_by_contractA
List indexed transactions that called a contract with pagination
Inputs: contract (required), limit, offset.
list_txs_by_senderB
List indexed transactions submitted by a sender with pagination
Inputs: sender (required), limit, offset.
list_txs_for_blockB
List indexed transactions for a block height or block hash
Inputs: block_ref (required).
simulate_transactionA
Simulate a transaction to estimate chi without executing it
Inputs: address (required), contract (required), function (required), kwargs.
verify_signatureB
Verify a message signature
Inputs: address (required), message (required), signature (required).
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 35 tools
Most tools have clear distinct purposes, but a few like get_transaction and get_indexed_tx overlap in retrieving transaction details by hash, and get_events_for_tx vs list_events could cause confusion. Overall, the descriptions help disambiguate.
All tools follow a consistent verb_noun pattern in snake_case. DEX-specific tools are prefixed with 'dex_', while others start with verbs like get, list, simulate, verify. No mixed conventions.
At 35 tools, the set is quite large but each tool serves a distinct purpose in the blockchain/DEX domain. It is above the typical 3-15 range, but not extremely bloated; some redundancy exists (e.g., get_transaction and get_indexed_tx).
The server covers a broad range of blockchain queries, DEX operations, contract interactions, and shielded wallet history. Missing direct transaction submission, but simulation and plans are provided. Minor gaps in lifecycle coverage.
Maintenance
Related MCP Connectors
Trade 16 crypto exchanges + MetaTrader 5 from your AI assistant via one MCP connection.
API discovery and x402 paid execution via MCP. Search by natural-language, call with USDC payment on Arbitrum, Base, BNB, Solana, SEI
Zero-setup MCP gateway securely connecting AI to your tools with authentication and workflows
16 Bitcoin, business, data, text, and developer tools for AI agents over one MCP endpoint.
Related MCP Servers
- AlicenseNot gradedqualityNot gradedmaintenanceEnables seamless interaction with the Hyperion blockchain, including wallet management, token transactions, ERC20 token deployment, and smart contract operations through standardized MCP endpoints.-
- FlicenseNot gradedqualityDmaintenanceEnables AI agents to resolve smart contract ABIs, read, encode, simulate, and prepare transactions across multiple blockchains via a REST API or MCP server, with no signing required.-
- AlicenseNot gradedqualityDmaintenanceEnables AI-powered chat and DeFi operations (swap, transfer) via MCP-compliant tools, integrating with LLMs for onchain actions.8 npmMIT
- AlicenseNot gradedqualityCmaintenanceMCP server that lets any AI agent operate a wallet directly on-chain: create wallets, send, swap, bridge, and deploy contracts across EVM and Bitcoin networks.1MIT