Skip to main content
Glama

Confirm dangerous command execution

confirm_command
Destructive

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>;
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations already declare destructiveHint=true and readOnlyHint=false, so the agent knows this is a destructive write operation. The description adds the 'dangerous' qualifier which reinforces the destructive nature, but doesn't provide additional behavioral context like what happens after confirmation, whether confirmation is reversible, or what specific dangers are involved. The description aligns with but doesn't significantly expand beyond the annotations.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is extremely concise at just three words, with zero wasted language. It's front-loaded with the core concept and doesn't contain any unnecessary elaboration. For a simple confirmation tool, this brevity is appropriate.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a destructive tool with no output schema, the description is inadequate. It doesn't explain what happens after confirmation, what gets executed, how to obtain the confirmation_id, or what the dangerous command actually is. Given the destructive nature and workflow context implied by the tool name, more guidance about the confirmation process and its consequences is needed.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents both parameters (confirmation_id and confirm) with their types and basic descriptions. The description doesn't add any meaning about what a confirmation_id represents, how it's obtained, or the implications of setting confirm to true versus false. Baseline 3 is appropriate when the schema provides complete parameter documentation.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose2/5

Does the description clearly state what the tool does and how it differs from similar tools?

Tautological: description restates name/title.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is provided about when to use this tool versus alternatives. The description doesn't mention prerequisites, when this confirmation step is required, or how it relates to sibling tools like 'execute_command'. There's no indication of workflow context or sequencing with other tools.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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