Skip to main content
Glama

Click in the game UI

ui_click

Clicks or scrolls the game window using screenshot or client-area coordinates to operate VGUI2 dialogs, Derma panels, and HTML menus that have no console command.

Instructions

Clicks (or scrolls the wheel) at a point of the game window: use it for what has no console command, the buttons of VGUI2 dialogs ("Disconnected by the server" > Close), Derma panels and the menu's HTML. Take the coordinates from a screenshot (coords "screenshot", the default: pixels of that image, origin top-left; if the image you read has another size than the game window's, e.g. a screenshot with w/h, pass screenshot_size [w, h] and the point is scaled) or give coords "window" (pixels of the window's client area, title bar excluded). DPI scaling is handled: the result says the window size, DPI and the scale applied. Posts WM_MOUSEMOVE, then the button down and up (double: down, up, double-click, up) one frame apart, or WM_MOUSEMOVE and one WM_MOUSEWHEEL (wheel: notches, positive = up). Result: {sent: [messages], at: {x, y} (client pixels), coords, button | wheel, scale?, frames_waited, window: {client_w, client_h, dpi, dpi_awareness, class}, screen: {w, h}, cursor_via (game_ui | vgui), screenshot?, screenshot_error?} plus the image with screenshot_after (the engine's jpeg capture when there is no client realm). The cursor is visible when the game menu (main menu, ESC menu, a dialog on it) is up, gui.IsGameUIVisible(), or a Derma popup, the context or spawn menu has it, vgui.CursorVisible() in the client realm. Windows game client only (unsupported on srcds). Refusals, each its own error code: unsupported; not_a_test_client (the game was not started by instances_launch: pass allow_user_game: true to post into the user's own game); client_locked (connected to a server that is not on this machine); loading (a map is loading: events_wait map_loaded); window_unavailable (window minimized or not found); cursor_hidden (the mouse is captured by the game view: no menu, dialog or popup is open; open one first, e.g. console_exec gameui_activate); out_of_bounds (ui_click only: the point is outside the image or window). The input is posted to the game's own window (PostMessage): the user's real cursor does not move and no window takes the focus. Example: {"x": 640, "y": 400, "screenshot_after": true}.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "x": "<x>",
      "y": "<y>"
    },
    "name": "ui_click"
  }
}

Input Schema

NameRequiredDescriptionDefault
xYesPixel column (see coords).
yYesPixel row (see coords).
wheelNoScroll this many notches instead of clicking (positive = up, negative = down; not 0).
buttonNoDefault left. Not with wheel.
coordsNoSpace of x and y: "screenshot" (default) or "window" (client-area pixels).
doubleNoDouble click (down, up, double-click, up). Not with wheel.
instanceNoOptional. Instance identifier (see instances_list). If present and different from the local instance, the call is relayed by the coordinator to that instance.
wait_framesNoFrames to wait after the last message so the UI reacts (default 5; a light test client runs at 20 fps).
allow_user_gameNoPost into a game that instances_launch did not start (the user's own). Default false.
screenshot_sizeNo[w, h] of the image x and y were read on, when it is not the game window's size (a screenshot with w/h).
screenshot_afterNoAlso return a screenshot after the wait (same image as `screenshot`: the render capture with a map loaded, the engine's own jpeg command at the main menu, in a dialog or on a loading screen).

Output Schema

NameRequiredDescriptionDefault
atYes
nextNo
noteNo
sentYes
scaleNo
wheelNo
buttonNo
coordsNo
screenNo
windowNo
warningNo
next_callNo
cursor_viaNo
screenshotNo
answered_byNo
frames_waitedYes
truncated_noteNo
screenshot_noteNo
version_warningNo
screenshot_errorNo

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.3.7

TDQS

A4.7/5.0
Behavior5/5

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

Annotations only declare destructiveHint=false and openWorldHint=false; the description goes far beyond by explaining that input is posted via PostMessage to the game's own window, the user's real cursor does not move and no window takes focus. It also documents DPI handling, frame timing (messages one frame apart, 20 fps test client), the visible-cursor preconditions, and a full error-code taxonomy with causes.

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

Conciseness3/5

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

The purpose and coordinate rules are front-loaded, but the body is one dense run-on paragraph with deeply nested parentheticals that is hard to scan. The long "Result: {sent, at, scale?, frames_waited, window, screen...}" passage largely duplicates the supplied output schema, spending words on information already available structurally.

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?

For an 11-parameter, platform-constrained UI-automation tool, the definition covers preconditions, coordinate spaces, message mechanics, failure modes and remedies, and the platform limitation (Windows client only). Since an output schema exists, it correctly does not need to justify return values, and nothing an agent needs before calling is missing.

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

Parameters4/5

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

Schema coverage is already 100%, so the baseline is 3, but the description adds real cross-parameter meaning: how screenshot_size rescales a point read off a differently sized image, the down/up/double-click and wheel message sequences, and that wait_frames governs how long the UI gets to react. It stops short of restating every field (e.g. instance relay is only in the schema), so it is additive rather than exhaustive.

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?

"Clicks (or scrolls the wheel) at a point of the game window" gives a specific verb, resource and coordinate target, and the description immediately carves out its niche against console-driven tools ("use it for what has no console command") naming VGUI2 dialogs, Derma panels and HTML menus as concrete targets. An agent can distinguish this from console_exec or ui_key without reading any schema.

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?

It states the selection rule explicitly (use for UI that has no console command, pointing at console_exec gameui_activate as the remedy when the cursor is captured) and enumerates each refusal condition with the action that resolves it (events_wait map_loaded for loading, open a menu for cursor_hidden). The when-not case (srcds unsupported, non-test-client without allow_user_game) is spelled out rather than inferred.

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