Skip to main content
Glama

get_user_decision

Request user decisions remotely during AFK mode by sending prompts for confirmations, choices, text input, or code diff approvals to mobile devices.

Instructions

Sends a decision request to the mobile client and blocks until the user responds or timeout expires. Only call when AFK mode is active. Use type 'confirm' for yes/no, 'choice' for selecting from options, 'text' for free-text input, 'diff' for approving code changes.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
sessionIdYesThe session ID
promptYesThe question for the user
typeYesThe type of decision
optionsNoFor "choice" type: list of options
diffNoFor "diff" type: file diff information
defaultValueNoDefault value used if timeout fires
timeoutSecondsNoTimeout in seconds (default: 300)

Implementation Reference

  • Main handler function for get_user_decision tool. Creates a decision request, sends it to the mobile client via WebSocket, and blocks until the user responds or timeout expires. Returns { decision: string | null, timedOut: boolean }.
    async (args) => {
      const id = crypto.randomUUID();
      const timestamp = new Date().toISOString();
      const timeoutMs = (args.timeoutSeconds ?? 300) * 1000;
    
      const result = await new Promise<{
        decision: string | null;
        timedOut: boolean;
      }>((resolve) => {
        const timer = setTimeout(() => {
          const session = getSession();
          session.pendingDecisions.delete(id);
          clearCurrentDecision(id);
          resolve({ decision: args.defaultValue ?? null, timedOut: true });
        }, timeoutMs);
    
        addPendingDecision({ id, resolve, timer });
    
        const request: DecisionRequestMessage = {
          type: "decision_request",
          id,
          timestamp,
          prompt: args.prompt,
          decisionType: args.type,
          options: args.options ?? null,
          diff: args.diff ?? null,
          defaultValue: args.defaultValue ?? null,
          timeoutSeconds: args.timeoutSeconds ?? 300,
        };
    
        sendDecisionRequest(request);
    
        // Push notification for decision requests
        sendPushNotification("🔔 Decision Needed", args.prompt);
      });
    
      return {
        content: [
          {
            type: "text" as const,
            text: JSON.stringify(result),
          },
        ],
      };
    },
  • Zod schema definition for get_user_decision input parameters. Defines sessionId, prompt, type (confirm/choice/text/diff), options, diff, defaultValue, and timeoutSeconds with validation rules.
    {
      sessionId: z.string().describe("The session ID"),
      prompt: z.string().describe("The question for the user"),
      type: z.enum(["confirm", "choice", "text", "diff"]).describe("The type of decision"),
      options: z
        .array(z.string())
        .nullable()
        .optional()
        .describe('For "choice" type: list of options'),
      diff: z
        .object({
          filePath: z.string(),
          before: z.string(),
          after: z.string(),
        })
        .nullable()
        .optional()
        .describe('For "diff" type: file diff information'),
      defaultValue: z
        .string()
        .nullable()
        .optional()
        .describe("Default value used if timeout fires"),
      timeoutSeconds: z
        .number()
        .optional()
        .default(300)
        .describe("Timeout in seconds (default: 300)"),
    },
  • Tool registration with MCP server using server.tool() method. Registers the tool name 'get_user_decision' with its description and handler.
    server.tool(
      "get_user_decision",
  • TypeScript interface GetUserDecisionInput defining the type-safe input structure for the tool, including sessionId, prompt, type, options, diff, defaultValue, and timeoutSeconds.
    export interface GetUserDecisionInput {
      sessionId: string;
      prompt: string;
      type: DecisionType;
      options?: string[] | null;
      diff?: DiffInfo | null;
      defaultValue?: string | null;
      timeoutSeconds?: number;
    }
  • Helper function addPendingDecision that stores the pending decision request in the session's pendingDecisions Map, allowing the WebSocket handler to resolve it when the user responds.
    export function addPendingDecision(pending: PendingDecision): void {
      getSession().pendingDecisions.set(pending.id, pending);
    }
Behavior4/5

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

With no annotations, the description carries full burden and does well by disclosing key behaviors: it blocks until response/timeout, has timeout handling, and requires AFK mode. It doesn't mention error cases or response format, but covers essential operational context.

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?

Two sentences, zero waste. First sentence states core functionality, second provides critical usage rules and type guidance. Every phrase earns its place with essential information.

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

Completeness4/5

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

For a complex 7-parameter tool with no annotations or output schema, the description provides strong context on when/how to use it and behavioral constraints. It could mention response format or error handling, but covers the most critical aspects given the complexity.

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 all parameters thoroughly. The description adds minimal value by mentioning type usage examples, but doesn't provide additional semantics beyond what's in the schema descriptions.

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's purpose with specific verbs ('sends', 'blocks') and resources ('decision request to mobile client'), and distinguishes it from siblings by specifying it's for user decisions during AFK mode, unlike status-checking or notification tools.

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 states when to use ('Only call when AFK mode is active') and provides clear alternatives for different decision types ('Use type 'confirm' for yes/no, 'choice' for selecting from options, etc.'), helping the agent choose appropriately.

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/paulbennet/afk-mode-mcp'

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