Skip to main content
For the complete documentation index, see llms.txt

Develop with the wallet CLI and MCP

How scripts, CI, and AI agents hold and move funds on Midnight without a browser extension, using the wallet CLI and its MCP server. For choosing a wallet first, see the overview; for browser DApp integration, see the integration guide.

Develop and test without a wallet

The Self-custody × CLI cell in practice. The wallet CLI exposes the same ConnectedAPI over a local WebSocket, so DApp code paths run with zero changes, then users connect with any browser wallet. The CLI is self-custody (keys in ~/.midnight, BIP-39/44, Lace-compatible) and network-agnostic (one seed serves undeployed, preprod, preview).

GroupCommands
Walletwallet generate/list/use/info/remove, info, address, genesis-address
Transactionsbalance, transfer, airdrop, inspect-cost
DUSTdust register, dust status
Local networklocalnet up/status/stop/down/clean
Config / connectorconfig get/set/unset, cache clear, serve

midnight localnet up orchestrates the full stack in Docker, node (9944), indexer (8088), proof server (6300), so you can deploy and transact with no faucet:

midnight localnet up # node + indexer + proof server (Docker)
midnight wallet generate alice # self-custody key in ~/.midnight
midnight config set network undeployed
midnight airdrop 1000 # fund the active wallet (undeployed-only)
midnight airdrop 1000 mn_addr_undeployed1... # ...or fund ANY address directly (v0.4.1, no seed import)
midnight dust register # REQUIRED before transfers (else error 138)
midnight balance
midnight transfer mn_addr_undeployed1... 100 # positional: <recipient> <amount>

midnight serve --network preview # headless DApp Connector on ws://localhost:9932
midnight serve --network preview --approve-all # dev only: auto-approve every request
#1 beginner gotcha

dust register before transferring, or it fails with BalanceCheckOverspend (138). DUST regenerates about 5 min locally (see Fees and DUST, Troubleshooting).

// A DApp connects to the CLI connector exactly like a browser wallet:
import { createWalletClient } from "midnight-wallet-connector";
const wallet = await createWalletClient({ url: "ws://localhost:9932", networkId: "Preview" });
const balances = await wallet.getUnshieldedBalances(); // same ConnectedAPI surface

Build and test against midnight serve (fast, scriptable, no pop-ups), then deploy and let users connect with Lace/1AM, zero code changes.

Freshness (v0.4.1)

midnight airdrop can now fund any address directly (paste the recipient's address, no seed import needed), so you no longer need to import a seed to fund browser wallets on a local network. The indexer connection also moved to the v4 API, fixing connection errors on the test networks. (repo)

(CLI README, connector, local playground)

AI and agent tooling (the MCP column)

The MCP column, agents calling tools, in two flavors.

Wallet-control MCP. The midnight-wallet-cli ships an MCP server (midnight-wallet-mcp) with 31 tools that mirror the CLI commands, so an AI agent can operate a self-custody wallet, the Self-custody × MCP cell:

GroupMCP tools
Wallet and infomidnight_wallet_generate, _list, _use, _info, _remove, midnight_info, midnight_address, midnight_genesis_address
Transactionsmidnight_balance, _transfer, _airdrop, midnight_inspect_cost
DUSTmidnight_dust_register, _status
Local networkmidnight_localnet_up, _stop, _down, _status, _clean
Configmidnight_config_get, _set, _unset, midnight_cache_clear

The newest tools are the consequential ones: an agent can now drive the full contract lifecycle (deploy, call, read state), not just move tokens, and a two-step confirmation tool shows the human what the agent is about to spend before anything executes. Point any MCP client at the binary, such as Claude Code (.mcp.json), Claude Desktop, Cursor, VS Code (Copilot), or Windsurf:

{ "mcpServers": { "midnight-wallet": { "command": "midnight-wallet-mcp" } } }

This is the highest-risk cell: scope the agent's tools, cap spend, allowlist destinations, and keep a human in the loop (see Security checklist). Walkthrough: "Multi-Language Dev Session #22: midnight-wallet-cli" (YouTube, CLI README).

Dev-assistant MCP. Tooling that helps you build: write Compact, wire the connector, verify claims. See the talk "Midnight for Developers: Midnight MCP, The AI Tool That Finally Understands Compact" (YouTube). Two marketplaces:

  • Midnight Expert has 13 plugins (87 skills, 17 agents) across the dev lifecycle. Most relevant here: midnight-tooling (CLI, devnet, proof server), midnight-dapp-dev (frontend plus connector), midnight-wallet (wallet SDK), midnight-verify (check SDK/connector claims), midnight-status-codes. Install via /plugin then add https://midnightntwrk.expert. (midnightntwrk.expert)
  • Edda Labs ships the midnight plugin: /midnight-docs, /midnight-docs-repos, /midnight-examples, /midnight-contracts, /midnight-starter (the same eddalabs/midnight-starter-template used in the React pattern). Install: /plugin marketplace add eddalabs/edda-marketplace then /plugin install midnight.