connect_wallet
Securely link your Solana wallet to the Crossmint HR Airdrop MCP server to enable token distribution. Provide your private key for wallet authentication.
Instructions
Connect a Solana wallet to the airdrop server
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| privateKey | Yes | The private key of the Solana wallet (base58 encoded) | |
| rpcUrl | No | The Solana RPC URL to use (optional) |
Input Schema (JSON Schema)
{
"properties": {
"privateKey": {
"description": "The private key of the Solana wallet (base58 encoded)",
"type": "string"
},
"rpcUrl": {
"description": "The Solana RPC URL to use (optional)",
"type": "string"
}
},
"required": [
"privateKey"
],
"type": "object"
}
Implementation Reference
- src/server.ts:454-503 (handler)The main handler function for the 'connect_wallet' tool. It validates input using Zod, creates a Solana connection, derives the keypair from base64 private key, fetches the SOL balance, updates the server state, and returns the connection details.private async handleConnectWallet(args: any) { try { // Validate input const schema = z.object({ privateKey: z.string(), rpcUrl: z.string().optional(), }); const { privateKey, rpcUrl } = schema.parse(args); // Connect to Solana const connection = new Connection( rpcUrl || 'https://api.mainnet-beta.solana.com', 'confirmed' ); let keypair: Keypair; try { keypair = Keypair.fromSecretKey(Buffer.from(privateKey, 'base64')); } catch (e: any) { throw new McpError(ErrorCode.InvalidParams, 'Invalid private key format. Please provide a base64 encoded private key.'); } const publicKey = keypair.publicKey.toString(); // Get SOL balance const balance = await connection.getBalance(keypair.publicKey); const solBalance = balance / LAMPORTS_PER_SOL; // Update state this.state.connectedWallet = { publicKey, solBalance, }; return { content: [ { type: 'text', text: `Wallet connected successfully. Public Key: ${publicKey}\nSOL Balance: ${solBalance} SOL`, }, ], }; } catch (error) { throw new McpError( ErrorCode.InternalError, `Failed to connect wallet: ${error instanceof Error ? error.message : String(error)}` ); } }
- src/server.ts:115-131 (schema)The tool registration in ListToolsRequestHandler, including name, description, and input schema definition (JSON Schema). Note: description mentions base58 but code expects base64.{ name: 'connect_wallet', description: 'Connect a Solana wallet to the airdrop server', inputSchema: { type: 'object', properties: { privateKey: { type: 'string', description: 'The private key of the Solana wallet (base58 encoded)', }, rpcUrl: { type: 'string', description: 'The Solana RPC URL to use (optional)', }, }, required: ['privateKey'], },
- src/server.ts:314-316 (registration)The dispatch/registration in the CallToolRequestHandler switch statement that routes 'connect_wallet' calls to the handler function.case 'connect_wallet': return await this.handleConnectWallet(args); case 'connect_crossmint_wallet':
- src/server.ts:457-460 (schema)Zod runtime validation schema inside the handler for input parameters.const schema = z.object({ privateKey: z.string(), rpcUrl: z.string().optional(), });