Skip to main content
Glama

confirm_command

Confirm execution of potentially dangerous commands in WSL environments to prevent accidental or harmful operations by requiring explicit user approval.

Instructions

Confirm dangerous command execution

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
confirmation_idYesConfirmation ID
confirmYesProceed with execution

Implementation Reference

  • The main handler function for the confirm_command tool. It retrieves the pending confirmation by ID, deletes it from the map, cancels if not confirmed, or executes the command using CommandExecutor and formats the output. Handles InvalidConfirmationError and other errors.
    async ({ confirmation_id, confirm }) => { try { const pending = this.pending_confirmations.get(confirmation_id); if (!pending) { throw new InvalidConfirmationError(confirmation_id); } this.pending_confirmations.delete(confirmation_id); if (!confirm) { return { content: [ { type: 'text' as const, text: 'Command execution cancelled.', }, ], }; } const result = await this.command_executor.execute_command( pending.command, pending.working_dir, pending.timeout, ); return { content: [ { type: 'text' as const, text: this.format_output(result), }, ], }; } catch (error) { return { content: [ { type: 'text' as const, text: `Error confirming command: ${ error instanceof Error ? error.message : String(error) }`, }, ], isError: true, }; } },
  • Valibot schema defining the input parameters: confirmation_id (string) and confirm (boolean).
    schema: v.object({ confirmation_id: v.pipe( v.string(), v.description('Confirmation ID'), ), confirm: v.pipe( v.boolean(), v.description('Proceed with execution'), ), }),
  • src/index.ts:397-467 (registration)
    The registration of the confirm_command tool using this.server.tool, including name, description, schema, annotations, and handler.
    // confirm_command tool this.server.tool( { name: 'confirm_command', description: 'Confirm dangerous command execution', schema: v.object({ confirmation_id: v.pipe( v.string(), v.description('Confirmation ID'), ), confirm: v.pipe( v.boolean(), v.description('Proceed with execution'), ), }), annotations: { readOnlyHint: false, destructiveHint: true, }, }, async ({ confirmation_id, confirm }) => { try { const pending = this.pending_confirmations.get(confirmation_id); if (!pending) { throw new InvalidConfirmationError(confirmation_id); } this.pending_confirmations.delete(confirmation_id); if (!confirm) { return { content: [ { type: 'text' as const, text: 'Command execution cancelled.', }, ], }; } const result = await this.command_executor.execute_command( pending.command, pending.working_dir, pending.timeout, ); return { content: [ { type: 'text' as const, text: this.format_output(result), }, ], }; } catch (error) { return { content: [ { type: 'text' as const, text: `Error confirming command: ${ error instanceof Error ? error.message : String(error) }`, }, ], isError: true, }; } }, );
  • Class property storing pending confirmations, used by the confirm_command handler.
    private pending_confirmations: Map<string, PendingConfirmation>;

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/spences10/mcp-wsl-exec'

If you have feedback or need assistance with the MCP directory API, please join our Discord server