process_command
Execute natural language commands for Base network operations, enabling wallet management, balance checks, and transaction execution through LLM-powered automation.
Instructions
Process a natural language command for Base network operations
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| command | Yes | Natural language command (e.g., "Send 0.1 ETH to 0x123...") |
Input Schema (JSON Schema)
{
"properties": {
"command": {
"description": "Natural language command (e.g., \"Send 0.1 ETH to 0x123...\")",
"type": "string"
}
},
"required": [
"command"
],
"type": "object"
}
Implementation Reference
- src/mcp/tools.ts:11-48 (handler)The core handler function that implements the logic for the 'process_command' tool. It uses NLP to parse the command and dispatches to blockchain-specific handlers.export async function processNaturalLanguageCommand(command: string): Promise<any> { try { // Parse the command const parsedCommand = parseCommand(command); console.log(`Parsed command: ${JSON.stringify(parsedCommand)}`); // Generate human-readable description const description = generateCommandDescription(parsedCommand); console.log(`Command description: ${description}`); // Process based on intent switch (parsedCommand.intent) { case CommandIntent.SEND_TRANSACTION: return await handleSendTransaction(parsedCommand.parameters as SendTransactionArgs); case CommandIntent.CHECK_BALANCE: return await handleCheckBalance(parsedCommand.parameters as CheckBalanceArgs); case CommandIntent.CREATE_WALLET: return await handleCreateWallet(parsedCommand.parameters as CreateWalletArgs); case CommandIntent.UNKNOWN: default: return { success: false, message: `I couldn't understand that command. Try something like "Send 0.1 ETH to 0x123..." or "Create a new wallet".`, originalCommand: command }; } } catch (error) { console.error('Error processing command:', error); return { success: false, message: `Error processing command: ${error instanceof Error ? error.message : 'Unknown error'}`, originalCommand: command }; } }
- src/mcp/server.ts:201-212 (schema)Tool definition including schema for 'process_command' in the MCP ListToolsRequestSchema response.name: 'process_command', description: 'Process a natural language command for Base network operations', inputSchema: { type: 'object', properties: { command: { type: 'string', description: 'Natural language command (e.g., "Send 0.1 ETH to 0x123...")', }, }, required: ['command'], },
- src/mcp/server.ts:257-277 (handler)Handler case in MCP CallToolRequestSchema that validates input and invokes the core processNaturalLanguageCommand function.case 'process_command': { if (typeof args.command !== 'string' || !args.command) { throw new McpError( ErrorCode.InvalidParams, 'Command is required and must be a string' ); } const result = await toolHandlers.processNaturalLanguageCommand( args.command ); return { content: [ { type: 'text', text: JSON.stringify(result, null, 2), }, ], }; }
- src/mcp/tools.ts:152-158 (registration)Registration of the processNaturalLanguageCommand function within the toolHandlers object imported and used by the MCP server.export const toolHandlers = { processNaturalLanguageCommand, handleSendTransaction, handleCheckBalance, handleCreateWallet, handleListWallets };