This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
This is the Metaplex CLI (mplx), a command-line interface for interacting with the Metaplex ecosystem on Solana. It provides tools for managing digital assets, collections, tokens, and more using the Metaplex Core protocol.
# Build the project
npm run build
# Clean build artifacts
npm run clean
# Clean and rebuild
npm run build:clean
# Development mode (uses ts-node)
./bin/dev.js
# Run built CLI
./bin/run.js
# or
npm run mplx# Run linting
npm run lint
# Fix linting issues
npm run lint:fix
# Type checking and build verification
npm run verify# Run all tests
npm test
# Start local validator for testing
npm run validator
# Stop local validator
npm run validator:stopThe CLI follows the OCLIF framework with a hierarchical command structure:
mplx <program> <object> <command> [flags]- Three main command groups:
core,config,toolbox
Base Classes:
BaseCommand(src/BaseCommand.ts): Base class for non-transactional commands with global flagsTransactionCommand(src/TransactionCommand.ts): Extended base class for blockchain transaction commands with commitment levels
Context System:
Context(src/lib/Context.ts): Central configuration management for RPC, wallets, signers, and Umi instance- Configuration stored in
~/.config/mplx/config.json - Supports multiple RPCs and wallets with switching capabilities
Key Libraries:
- Uses Metaplex Umi as the core blockchain interaction layer
- Integrates mpl-core, mpl-token-metadata, and mpl-toolbox programs
- File-based and Ledger wallet support through custom signer implementations
Core Commands (src/commands/core/):
- Asset management (create, burn, fetch, update)
- Collection management (create, fetch)
- Plugin system (add, generate)
Config Commands (src/commands/config/):
- RPC endpoint management (add, list, set, remove)
- Wallet management (add, list, set, remove, new)
- Explorer preferences
Toolbox Commands (src/commands/toolbox/):
- SOL operations (balance, transfer, airdrop)
- Token operations (create, transfer, update)
- Utility functions (rent calculations)
- Pluggable storage providers (Irys, Arweave Turbo)
- Automatic file type detection and MIME type handling
- Support for batch operations with directory structures
- Mocha-based test suite
- Helper functions for creating test assets and collections
- Integration with Amman for local validator testing
- Test utilities in
test/corehelpers.tsfor extracting IDs from CLI output
- Extend appropriate base class (BaseCommand or TransactionCommand)
- Follow existing patterns for flag definitions and help text
- Use the context system for blockchain interactions
- Include proper error handling and user feedback
- Access Umi instance through
this.context.umi - Use context signers for transactions:
this.context.signer,this.context.payer - Leverage existing transaction utilities in
src/lib/umi/
- Use utilities in
src/lib/file.tsfor file handling - Leverage storage providers in
src/lib/uploader/for uploads - Follow existing patterns for metadata and plugin file structures
- Extend ConfigJson type for new configuration options
- Update CONFIG_KEYS array when adding new config fields
- Use consolidateConfigs function for merging configuration sources
- Uses pnpm as package manager
- Node.js >= 20.0.0 required
- ESM modules with TypeScript compilation target es2022