An MCP (Model Context Protocol) server that lets AI agents trade perpetual futures on Injective.
Exposes Injective perpetual futures trading as MCP tools for Claude Desktop / Claude Code:
| Tool | Description |
|---|---|
wallet_generate |
Generate a new encrypted wallet |
wallet_import |
Import a wallet from a private key |
wallet_list |
List all local wallets |
wallet_remove |
Remove a wallet from the keystore |
market_list |
List all active perpetual markets |
market_price |
Get oracle price for a market |
account_balances |
Get bank + subaccount balances (all token types) |
account_positions |
Get open positions with P&L |
token_metadata |
Look up token symbol, decimals, type for any denom |
trade_open |
Open a perpetual position (market order) |
trade_close |
Close an open position (market order) |
Claude (MCP client)
│ tool calls
▼
MCP Server (src/mcp/server.ts)
│
▼
Core Library
├── config/ Network configuration (testnet/mainnet)
├── keystore/ AES-256-GCM encrypted key storage
├── wallets/ Wallet generation and management
├── markets/ Market data with caching
├── accounts/ Balances and positions
└── trading/ Open/close perpetual positions
│
▼
Injective Chain (via @injectivelabs/sdk-ts)
npm install
npm run buildAdd to your Claude Desktop MCP config (~/Library/Application Support/Claude/claude_desktop_config.json):
{
"mcpServers": {
"injective": {
"command": "node",
"args": ["/path/to/mcp-server/dist/mcp/server.js"],
"env": {
"INJECTIVE_NETWORK": "testnet"
}
}
}
}Set INJECTIVE_NETWORK to "mainnet" for production.
Add to your project's MCP config or ~/.claude/mcp.json:
{
"mcpServers": {
"injective": {
"command": "node",
"args": ["/path/to/mcp-server/dist/mcp/server.js"],
"env": { "INJECTIVE_NETWORK": "testnet" }
}
}
}Once connected, Claude can:
- Generate a wallet —
wallet_generate(save the mnemonic!) - Fund it — send USDT to the address via the testnet faucet
- Check balances —
account_balances - List markets —
market_list - Open a position —
trade_openwith symbol, side, amount, leverage - Monitor —
account_positionsto see P&L - Close —
trade_close
- Private keys are encrypted at rest with AES-256-GCM + scrypt
- Claude never sees private keys — only addresses and tx hashes
- Wallet passwords flow through MCP tool parameters (may appear in logs — see
SECURITY.md) - Keystore location:
~/.injective-agent/keys/
See SECURITY.md for the full security model.
npm test # unit tests (no network)
npm run test:integration # integration tests against testnet
npm run typecheck # type check only| Package | Purpose |
|---|---|
@injectivelabs/sdk-ts |
Chain interaction, signing, message building |
@injectivelabs/networks |
Endpoint resolution |
@injectivelabs/utils |
BigNumber utilities |
decimal.js |
Arbitrary-precision financial math |
@modelcontextprotocol/sdk |
MCP server framework |
Balances and token metadata support all Injective denom formats, including MTS (MultiVM Token Standard) tokens:
| Type | Denom format | Example |
|---|---|---|
| Native | inj |
INJ |
| Peggy (bridged ERC20) | peggy0x... |
USDT |
| IBC | ibc/... |
ATOM via IBC |
| Factory | factory/inj.../name |
TokenFactory tokens |
| MTS (ERC20) | erc20:0x... |
EVM-deployed tokens |
Token metadata (symbol, decimals) is resolved automatically:
- Hardcoded — well-known denoms (INJ, USDT) for instant resolution
- On-chain —
ChainGrpcBankApi.fetchDenomMetadata()for registered tokens - Pattern-based — fallback display names for unregistered denoms
Results are cached in-memory for the lifetime of the server process.
| Network | Value |
|---|---|
| Testnet | INJECTIVE_NETWORK=testnet |
| Mainnet | INJECTIVE_NETWORK=mainnet |