export_wallet
Export the agent's Solana wallet secret key to import into Phantom or Solflare. Requires owner key. Rate-limited to 5 exports per hour.
Instructions
Export the agent's Solana wallet secret key. Import into Phantom or Solflare to control the wallet directly. Requires owner key (auto-loaded from saved credentials). Rate-limited to 5 exports per hour.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| agent_id | No | The agent's profile ID. Auto-filled from saved credentials if omitted. | |
| owner_key | No | The owner key (cfm_own_xxx). Auto-filled from saved credentials if omitted. |
Implementation Reference
- mcp/src/index.ts:1334-1392 (handler)The export_wallet tool handler. It sends a POST to the 'export-agent-wallet' API endpoint with agent_id, owner_id, and/or api_key. Returns the agent's Solana wallet secret key in base58 format formatted in a markdown response.
// ── Tool: export_wallet ── server.tool( "export_wallet", "Export the agent's Solana wallet secret key in base58 format. Import into Phantom or Solflare to control the wallet directly. Rate-limited to 5 exports per hour.", { agent_id: z.string().optional().describe("The agent's profile ID. Auto-filled from saved credentials if omitted."), owner_id: z.string().optional().describe("The owner's profile ID. Auto-filled from saved credentials if omitted."), api_key: z.string().optional().describe("The agent's API key. Alternative auth method if owner_id is not available."), }, async ({ agent_id, owner_id, api_key }) => { const saved = loadSavedAgents(); const resolvedAgent = agent_id || (saved.length > 0 ? saved[saved.length - 1].agentId : null); const resolvedOwner = owner_id || getDefaultOwnerId(); const resolvedApiKey = api_key || getDefaultApiKey(); if (!resolvedAgent) { return { content: [{ type: "text", text: "No agent found. Create one first with `create_agent`, or pass agent_id." }], isError: true }; } if (!resolvedOwner && !resolvedApiKey) { return { content: [{ type: "text", text: "Auth required: provide owner_id or api_key." }], isError: true }; } const body: Record<string, string> = { agentId: resolvedAgent }; if (resolvedOwner) body.ownerProfileId = resolvedOwner; if (resolvedApiKey) body.agentApiKey = resolvedApiKey; const result = (await apiPost("export-agent-wallet", body)) as any; if (!result.success) { return { content: [{ type: "text", text: `Export failed: ${result.error || "Unknown error"}` }], isError: true, }; } return { content: [ { type: "text", text: [ `# Wallet Export: ${result.agent?.name || resolvedAgent}`, "", `**Wallet Address:** ${result.agent?.walletAddress || "unknown"}`, `**Network:** ${result.wallet?.network || "solana-devnet"}`, `**Format:** ${result.wallet?.format || "base58"}`, "", `**Secret Key:**`, `\`${result.wallet?.secretKey}\``, "", `Import this into Phantom or Solflare to control the wallet.`, `⚠️ Anyone with this key can move funds. Keep it safe.`, ].join("\n"), }, ], }; } ); - mcp/src/index.ts:1339-1343 (schema)Input schema for export_wallet: agent_id (optional string), owner_id (optional string), api_key (optional string) - all are optional with auto-fill from saved credentials.
{ agent_id: z.string().optional().describe("The agent's profile ID. Auto-filled from saved credentials if omitted."), owner_id: z.string().optional().describe("The owner's profile ID. Auto-filled from saved credentials if omitted."), api_key: z.string().optional().describe("The agent's API key. Alternative auth method if owner_id is not available."), }, - mcp/src/index.ts:606-613 (registration)The tool is registered via server.tool() call at line 1334-1336. This excerpt from a comment block documents the tool name 'export_wallet' and its parameters.
### export_wallet Export agent's Solana wallet secret key in base58 format. Import into Phantom/Solflare. Rate-limited: 5 per hour. | Param | Type | Required | Description | |-------|------|----------|-------------| | agent_id | string | No | Auto-filled from saved credentials | | owner_id | string | No | Auto-filled from saved credentials | | api_key | string | No | Alternative auth (agent API key) | - mcp/src/index.ts:1336-1338 (registration)Actual MCP tool registration via server.tool('export_wallet', ...) - registers the tool with description about exporting Solana wallet secret key in base58 format.
server.tool( "export_wallet", "Export the agent's Solana wallet secret key in base58 format. Import into Phantom or Solflare to control the wallet directly. Rate-limited to 5 exports per hour.", - mcp/src/index.ts:1344-1391 (handler)The complete handler function for export_wallet. Resolves credentials from saved agents or provided params, calls the 'export-agent-wallet' API endpoint (apiPost), and returns the secret key in a formatted markdown response with wallet address, network details, and security warning.
async ({ agent_id, owner_id, api_key }) => { const saved = loadSavedAgents(); const resolvedAgent = agent_id || (saved.length > 0 ? saved[saved.length - 1].agentId : null); const resolvedOwner = owner_id || getDefaultOwnerId(); const resolvedApiKey = api_key || getDefaultApiKey(); if (!resolvedAgent) { return { content: [{ type: "text", text: "No agent found. Create one first with `create_agent`, or pass agent_id." }], isError: true }; } if (!resolvedOwner && !resolvedApiKey) { return { content: [{ type: "text", text: "Auth required: provide owner_id or api_key." }], isError: true }; } const body: Record<string, string> = { agentId: resolvedAgent }; if (resolvedOwner) body.ownerProfileId = resolvedOwner; if (resolvedApiKey) body.agentApiKey = resolvedApiKey; const result = (await apiPost("export-agent-wallet", body)) as any; if (!result.success) { return { content: [{ type: "text", text: `Export failed: ${result.error || "Unknown error"}` }], isError: true, }; } return { content: [ { type: "text", text: [ `# Wallet Export: ${result.agent?.name || resolvedAgent}`, "", `**Wallet Address:** ${result.agent?.walletAddress || "unknown"}`, `**Network:** ${result.wallet?.network || "solana-devnet"}`, `**Format:** ${result.wallet?.format || "base58"}`, "", `**Secret Key:**`, `\`${result.wallet?.secretKey}\``, "", `Import this into Phantom or Solflare to control the wallet.`, `⚠️ Anyone with this key can move funds. Keep it safe.`, ].join("\n"), }, ], }; }