Skip to main content
Glama

confirm_hand

Approve and execute a pending Hands action using its single-use approval token. Only call after user authorizes the action, as side effects can be destructive.

Instructions

Approve and EXECUTE a previously-issued Hands invocation by its single-use approval token. The token is returned by any confirm-required Hands tool; tokens expire after 60 seconds and CANNOT be reused. Side effect equals whatever the underlying Hand does — this can be highly destructive (running arbitrary shell commands, modifying files, etc.), so only call when the user has authorised the pending action. The token IS the auth (no external auth, no rate limits). Invalid, expired, or already-consumed tokens return an inert text response, NOT an error.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
tokenYesThe approval token from the pending response

Implementation Reference

  • The actual MCP tool handler for 'confirm_hand'. It consumes a token from the ConfirmStore, executes the stored pending hand, and returns the result.
    server.tool(
      "confirm_hand",
      "Approve and EXECUTE a previously-issued Hands invocation by its single-use approval token. The token is returned by any confirm-required Hands tool; tokens expire after 60 seconds and CANNOT be reused. Side effect equals whatever the underlying Hand does — this can be highly destructive (running arbitrary shell commands, modifying files, etc.), so only call when the user has authorised the pending action. The token IS the auth (no external auth, no rate limits). Invalid, expired, or already-consumed tokens return an inert text response, NOT an error.",
      { token: z.string().describe("The approval token from the pending response") },
      async ({ token }) => {
        const pending = handsRegistry.getConfirmStore().consume(token);
        if (!pending) {
          return { content: [{ type: "text", text: "Token invalid, expired, or already consumed." }] };
        }
        try {
          const result = await pending.execute();
          return { content: [{ type: "text", text: formatExecResult(pending.toolName, result) }] };
        } catch (e: any) {
          return { content: [{ type: "text", text: `Execution failed after approval: ${e?.message ?? e}` }] };
        }
      }
    );
  • Tool registered via server.tool() with name 'confirm_hand', description, Zod schema {token: string}, and handler function.
    server.tool(
      "confirm_hand",
      "Approve and EXECUTE a previously-issued Hands invocation by its single-use approval token. The token is returned by any confirm-required Hands tool; tokens expire after 60 seconds and CANNOT be reused. Side effect equals whatever the underlying Hand does — this can be highly destructive (running arbitrary shell commands, modifying files, etc.), so only call when the user has authorised the pending action. The token IS the auth (no external auth, no rate limits). Invalid, expired, or already-consumed tokens return an inert text response, NOT an error.",
      { token: z.string().describe("The approval token from the pending response") },
      async ({ token }) => {
        const pending = handsRegistry.getConfirmStore().consume(token);
        if (!pending) {
          return { content: [{ type: "text", text: "Token invalid, expired, or already consumed." }] };
        }
        try {
          const result = await pending.execute();
          return { content: [{ type: "text", text: formatExecResult(pending.toolName, result) }] };
        } catch (e: any) {
          return { content: [{ type: "text", text: `Execution failed after approval: ${e?.message ?? e}` }] };
        }
      }
    );
  • The input schema for confirm_hand: a single required 'token' string parameter.
    "confirm_hand",
    "Approve and EXECUTE a previously-issued Hands invocation by its single-use approval token. The token is returned by any confirm-required Hands tool; tokens expire after 60 seconds and CANNOT be reused. Side effect equals whatever the underlying Hand does — this can be highly destructive (running arbitrary shell commands, modifying files, etc.), so only call when the user has authorised the pending action. The token IS the auth (no external auth, no rate limits). Invalid, expired, or already-consumed tokens return an inert text response, NOT an error.",
    { token: z.string().describe("The approval token from the pending response") },
    async ({ token }) => {
  • ConfirmStore class: manages single-use approval tokens with TTL (60s). stash() creates a token with CSPRNG, consume() returns the pending execution if valid, clearProject() and clearAll() for cleanup.
    import { randomBytes } from "node:crypto";
    import type { ExecResult } from "./types.js";
    
    interface PendingEntry {
      toolName: string;
      projectName: string;
      resolvedArgv: string[];
      workingDir: string;
      env: Record<string, string>;
      expiresAt: number;
      execute: () => Promise<ExecResult>;
    }
    
    export interface StashInput {
      toolName: string;
      projectName: string;
      resolvedArgv: string[];
      workingDir: string;
      env: Record<string, string>;
      execute: () => Promise<ExecResult>;
    }
    
    export class ConfirmStore {
      private map = new Map<string, PendingEntry>();
      private ttlMs: number;
    
      constructor(opts: { ttlMs?: number } = {}) {
        this.ttlMs = opts.ttlMs ?? 60_000;
      }
    
      stash(input: StashInput): string {
        const token = randomBytes(32).toString("hex");
        this.map.set(token, { ...input, expiresAt: Date.now() + this.ttlMs });
        return token;
      }
    
      consume(token: string): { execute: () => Promise<ExecResult>; toolName: string } | null {
        const entry = this.map.get(token);
        if (!entry) return null;
        this.map.delete(token);
        if (entry.expiresAt < Date.now()) return null;
        return { execute: entry.execute, toolName: entry.toolName };
      }
    
      clearProject(projectName: string): void {
        for (const [token, entry] of this.map) {
          if (entry.projectName === projectName) this.map.delete(token);
        }
      }
    
      clearAll(): void {
        this.map.clear();
      }
    }
  • formatPendingConfirm() generates the instruction message telling the agent to call confirm_hand({ token: '...' }) to approve a hand execution.
    export function formatPendingConfirm(p: PendingFormatInput): string {
      return [
        `This tool requires human approval before running.`,
        ``,
        `  Tool:    ${p.toolName}`,
        `  Project: ${p.projectName}`,
        `  Command (resolved):`,
        ...p.resolvedArgv.map((a, i) => `    [${i}] ${a}`),
        `  Working dir: ${p.workingDir}`,
        ``,
        `To approve, call: confirm_hand({ token: "${p.token}" })`,
        `This token expires in 60 seconds.`,
      ].join("\n");
    }
Behavior5/5

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

With no annotations, description fully discloses side effects (underlying Hand action, potentially destructive), auth mechanism (token itself), no external auth, no rate limits, token expiry, and error behavior. Highly transparent.

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?

Four sentences packed with essential info: action, token source and constraints, side effects and warning, error handling. No fluff, each sentence earns its place.

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

Completeness5/5

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

Despite no output schema, description covers input, behavior, side effects, error handling, and security model. Complete for a destructive execution tool.

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

Parameters5/5

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

The single parameter 'token' is well-described in schema; description adds critical context: single-use, 60-second expiry, sourced from confirm-required Hands tool. Adds meaningful value beyond schema.

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

Purpose5/5

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

The description clearly states the tool approves and executes a previously-issued Hands invocation using a single-use approval token. It differentiates from sibling tools like list_hands by focusing on execution of pending actions.

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

Usage Guidelines5/5

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

Explicitly explains when to use (only after receiving token from confirm-required Hands tool, only when user authorized), token expiry and non-reusability, and that invalid tokens return inert text response. No alternative needed due to uniqueness.

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/safiyu/ctxnest'

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