run_custom_tool
Run a custom tool from your project configuration by specifying its name and arguments. Use it to execute predefined scripts or commands with dynamic parameters via {{key}} placeholders.
Instructions
Execute a custom tool defined in project configuration
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| toolName | Yes | Name of the custom tool to run | |
| args | No | Arguments to pass to the custom tool (replaces {{key}} placeholders) |
Implementation Reference
- The handler function that executes custom tools. It looks up the tool by name from project config customTools, substitutes {{key}} placeholders with provided args, then runs the command via runCommand with skipAllowedCheck=true.
async runCustomTool(toolName: string, args?: Record<string, any>): Promise<ToolResult> { try { const config = await this.configService.loadProjectConfig(); const customTool = config.customTools?.find(tool => tool.name === toolName); if (!customTool) { return { isError: true, content: [{ type: 'text', text: `Custom tool '${toolName}' not found in project configuration` }] }; } // Replace placeholders in command if args provided let command = customTool.command; if (args) { for (const [key, value] of Object.entries(args)) { command = command.replace(new RegExp(`\\{\\{${key}\\}\\}`, 'g'), String(value)); } } return this.runCommand(command, { skipAllowedCheck: true, // Custom tools are pre-approved commitResult: true, commitMessage: `Executed custom tool: ${toolName}` }); } catch (error) { return { isError: true, content: [{ type: 'text', text: `Failed to execute custom tool: ${error}` }] }; } } - src/index.ts:349-350 (registration)Registration of 'run_custom_tool' in the main tool execution switch statement, dispatching to SecureCommandService.runCustomTool.
case 'run_custom_tool': return await this.secureCommandService.runCustomTool(args.toolName, args.args); - src/toolDefinitions.ts:998-1008 (schema)The schema definition for the run_custom_tool tool, specifying toolName (required string) and args (optional object for placeholder substitution).
name: 'run_custom_tool', description: 'Execute a custom tool defined in project configuration', inputSchema: { type: 'object', properties: { toolName: { type: 'string', description: 'Name of the custom tool to run' }, args: { type: 'object', description: 'Arguments to pass to the custom tool (replaces {{key}} placeholders)' } }, required: ['toolName'] } }, - The ProjectConfig interface defining the customTools array structure (name, command, description, args) that stores custom tool definitions.
customTools?: Array<{ name: string; command: string; description: string; args?: Record<string, any>; }>; - src/types.ts:57-66 (helper)The ToolResult interface used as the return type for all tool handlers including runCustomTool.
export interface ToolResult { content: Array<{ type: 'text' | 'image'; text?: string; data?: string; mimeType?: string; _meta?: Record<string, any>; }>; isError?: boolean; _meta?: Record<string, any>;