Skip to Content
API Reference@embarkai/mcp

@embarkai/mcp API

API reference for the MCP server package.

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 } from '@embarkai/mcp';

Server Functions

createMcpServer

Creates an MCP server instance without starting a transport.

function createMcpServer(config: McpConfig): McpServer

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

startMcpServer

Creates a server and immediately starts it with the stdio transport.

function startMcpServer(config?: McpConfig): void

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

resolveConfig

Builds an McpConfig from environment variables.

function resolveConfig(): McpConfig

McpConfig

interface McpConfig { apiKey: string walletId: string chainId: number keyshareDir: string keysharePassword?: string walletBackupPassword?: string debug?: boolean }
FieldEnv VariableRequiredDescription
apiKeyEMBARK_API_KEYYesAPI key for authentication
walletIdEMBARK_WALLET_IDYesTarget smart wallet identifier
chainIdEMBARK_CHAIN_IDYesDefault chain ID (e.g. 1 for Ethereum)
keyshareDirEMBARK_KEYSHARE_DIRYesPath to the directory storing MPC keyshares
keysharePasswordEMBARK_KEYSHARE_PASSWORDNoPassword to decrypt local keyshare files
walletBackupPasswordEMBARK_WALLET_BACKUP_PASSWORDNoPassword for vault backup/restore
debugEMBARK_DEBUGNoEnable verbose logging (true / false)

ChainManager

Internal helper used by the MCP server to switch chains at runtime.

class ChainManager { getCurrentChainId(): number switchChain(chainId: number): Promise<void> getSupportedChains(): number[] }

Built-in Tools

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

ToolDescriptionKey Parameters
get_wallet_infoReturns the smart account address, deployed status, and current chainnone
get_balanceFetches native or ERC-20 token balancetokenAddress?
transferSends native currency or ERC-20 tokensto, amount, tokenAddress?
read_contractCalls a read-only contract functioncontractAddress, abi, functionName, args?
get_transaction_statusReturns the status of a user operation by hashhash
list_supported_chainsLists all chains the SDK supportsnone
switch_chainChanges the active chain for subsequent operationschainId

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": "1", "EMBARK_KEYSHARE_DIR": "./keyshares" } } } }

Example: Programmatic Usage

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