Skip to Content
API Reference@embarkai/mcp

@embarkai/mcp API

API reference for the MCP server package (@embarkai/mcp 0.2.4).

The @embarkai/mcp package exposes an MCP-compatible server that lets AI agents manage embarkAI smart wallets over the Model Context Protocol.

import { createMcpServer, startMcpServer, resolveConfig, ChainManager } from '@embarkai/mcp' import type { McpConfig } from '@embarkai/mcp'

Server Functions

createMcpServer

Creates an MCP server instance without starting a transport. It builds a ChainManager (loading or creating the wallet keyshare) and registers all tools.

function createMcpServer(config: McpConfig): Promise<McpServer>

Use this when you need to attach a custom transport (e.g. SSE, WebSocket).

startMcpServer

Creates a server and immediately connects it to the stdio transport.

function startMcpServer(config?: McpConfig): Promise<void>

When config is omitted, resolveConfig() is called automatically to read values from environment variables.

resolveConfig

Builds an McpConfig from environment variables. Throws if EMBARK_API_KEY or EMBARK_WALLET_ID is missing, or if EMBARK_CHAIN_ID is not a number.

function resolveConfig(): McpConfig

McpConfig

interface McpConfig { apiKey: string walletId: string chainId: number keyshareDir: string keysharePassword?: string walletBackupPassword?: string debug: boolean }
FieldEnv VariableDefaultDescription
apiKeyEMBARK_API_KEY— (required)Project API key from the Dashboard
walletIdEMBARK_WALLET_ID— (required)Identifier of the server wallet the agent controls
chainIdEMBARK_CHAIN_ID2030232745 (Lumia Beam)Chain the server starts on; can be changed at runtime with switch_chain
keyshareDirEMBARK_KEYSHARE_DIR./data/keysharesDirectory for encrypted keyshare files
keysharePasswordEMBARK_KEYSHARE_PASSWORD—Enables the encrypted file storage (FileKeyshareStorage). Without it the keyshare lives in memory and is lost when the process exits
walletBackupPasswordEMBARK_WALLET_BACKUP_PASSWORD—Password for ShareVault backup and restore
debugEMBARK_DEBUGfalse ("true" enables)Verbose logging in the underlying ServerWalletManager

ChainManager

Holds one ServerWalletManager per chain and the active chain the tools operate on. Exported for programmatic use; the server creates it for you.

class ChainManager { activeChainId: number static create(config: McpConfig): Promise<ChainManager> getManager(chainId?: number): ServerWalletManager getOrCreateWallet(walletId: string, chainId?: number): Promise<ServerWallet> getReadClient(chainId?: number): PublicReadClient getActiveChainConfig(): ChainConfig switchChain(chainId: number): { previousChainId: number; activeChain: ChainConfig } getAllChainConfigs(): ChainConfig[] }

create() picks FileKeyshareStorage when keysharePassword is set and MemoryKeyshareStorage otherwise. Every method defaults chainId to activeChainId.


Built-in Tools

The MCP server registers seven tools that AI agents can invoke.

ToolDescriptionParameters
get_wallet_infoReturns walletId, smartAccountAddress, ownerAddress and the active chain (id, name, nativeCurrency, blockExplorerUrl)none
get_balanceNative or ERC-20 balance for an addressaddress? (defaults to the wallet’s smart account), tokenAddress?
transferSends native currency or ERC-20 tokens from the walletto, amount (human-readable, e.g. "1.5"), tokenAddress?
read_contractCalls a read-only contract functionaddress, abi (array of ABI items), functionName, args?
get_transaction_statusReturns the receipt of a UserOperationuserOpHash
list_supported_chainsLists all chains the server can operate onnone
switch_chainChanges the active chain for subsequent operationschainId

See Tools Reference for request and response examples.

Example: Using with Claude Desktop

{ "mcpServers": { "embarkai": { "command": "npx", "args": ["-y", "@embarkai/mcp"], "env": { "EMBARK_API_KEY": "your-api-key", "EMBARK_WALLET_ID": "your-wallet-id", "EMBARK_CHAIN_ID": "2030232745", "EMBARK_KEYSHARE_DIR": "./keyshares", "EMBARK_KEYSHARE_PASSWORD": "a-strong-password" } } } }

Example: Programmatic Usage

import { createMcpServer } from '@embarkai/mcp' const server = await createMcpServer({ apiKey: process.env.EMBARK_API_KEY!, walletId: process.env.EMBARK_WALLET_ID!, chainId: 2030232745, keyshareDir: './keyshares', keysharePassword: process.env.EMBARK_KEYSHARE_PASSWORD, debug: true, })
Last updated on