@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): McpServerUse 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): voidWhen config is omitted, resolveConfig() is called automatically to read values from environment variables.
resolveConfig
Builds an McpConfig from environment variables.
function resolveConfig(): McpConfigMcpConfig
interface McpConfig {
apiKey: string
walletId: string
chainId: number
keyshareDir: string
keysharePassword?: string
walletBackupPassword?: string
debug?: boolean
}| Field | Env Variable | Required | Description |
|---|---|---|---|
apiKey | EMBARK_API_KEY | Yes | API key for authentication |
walletId | EMBARK_WALLET_ID | Yes | Target smart wallet identifier |
chainId | EMBARK_CHAIN_ID | Yes | Default chain ID (e.g. 1 for Ethereum) |
keyshareDir | EMBARK_KEYSHARE_DIR | Yes | Path to the directory storing MPC keyshares |
keysharePassword | EMBARK_KEYSHARE_PASSWORD | No | Password to decrypt local keyshare files |
walletBackupPassword | EMBARK_WALLET_BACKUP_PASSWORD | No | Password for vault backup/restore |
debug | EMBARK_DEBUG | No | Enable 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.
| Tool | Description | Key Parameters |
|---|---|---|
get_wallet_info | Returns the smart account address, deployed status, and current chain | none |
get_balance | Fetches native or ERC-20 token balance | tokenAddress? |
transfer | Sends native currency or ERC-20 tokens | to, amount, tokenAddress? |
read_contract | Calls a read-only contract function | contractAddress, abi, functionName, args? |
get_transaction_status | Returns the status of a user operation by hash | hash |
list_supported_chains | Lists all chains the SDK supports | none |
switch_chain | Changes the active chain for subsequent operations | chainId |
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