Skip to main content
Glama

Press a key or type text in the game UI

ui_key

Presses named keys or types text into the focused game UI field, including dialogs, Derma text entries, and HTML inputs, after clicking the target.

Instructions

Presses a key and/or types text into the focused part of the game UI (a text entry of a dialog, a Derma TextEntry, an HTML input): key is a named key (enter, escape, tab, backspace, space, up, down, left, right, home, end, pageup, pagedown, insert, delete, f1..f12, a letter, a digit or space: those type the character, as WM_CHAR like text, they are not pressed as keys), text is typed character by character as WM_CHAR (up to 256 characters; no control characters: use key). The engine narrows every typed character through the machine's ANSI code page with best-fit (live, CP1252: accents of western Europe arrive, l-stroke becomes l, Greek a, Cyrillic and CJK ?): a text with such a character is refused with text_not_representable (before anything is typed; details: code_page, characters) unless allow_lossy: true. For those, set the text from Lua with lua_exec in the realm that owns the panel (menu for the main menu's dialogs, client for Derma in game): entry:SetText("...") on a DTextEntry (DTextEntry:SetValue does nothing while the entry has the keyboard focus, which a ui_click gives it; entry:OnValueChange(text) afterwards if the page listens to it). With both, the text is typed first, then the key is pressed (text "hello" + key enter). Click the field first with ui_click. Result: {sent: [messages], key?, text_units?, lossy_characters? and ansi_code_page? (allow_lossy), frames_waited, window, screen, cursor_via, screenshot?}. 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: {"text": "my name", "key": "enter"}.

Tool call template

This tool declares no required parameters. Add optional parameters from the input schema as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {},
    "name": "ui_key"
  }
}

Input Schema

NameRequiredDescriptionDefault
keyNoNamed key to press (enter, escape, tab, backspace, up, f1...).
textNoText to type (UTF-8, 256 characters at most). Only characters of the machine's ANSI code page arrive unchanged (accents of western Europe on CP1252); see text_not_representable.
instanceNoOptional. Instance identifier (see instances_list). If present and different from the local instance, the call is relayed by the coordinator to that instance.
allow_lossyNoType the text even if the engine will alter some characters (l-stroke becomes l, Greek a, Cyrillic and CJK ?). Default false: the call is refused with text_not_representable.
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_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
keyNo
nextNo
noteNo
sentYes
screenNo
windowNo
warningNo
next_callNo
cursor_viaNo
screenshotNo
text_unitsNo
answered_byNo
frames_waitedYes
ansi_code_pageNo
truncated_noteNo
screenshot_noteNo
version_warningNo
lossy_charactersNo
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 supply a title and two hints, so the description carries the behavioral burden and does so thoroughly: input is posted via PostMessage, the real cursor does not move and no window takes focus, it is Windows-client-only and unsupported on srcds, and the wait_frames timing model (20 fps light client) is explained. It also enumerates each refusal code with the condition that triggers it.

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 is front-loaded, but the body is a single dense paragraph with stacked parentheticals that is hard to scan. Some content does not earn its place here, notably the out_of_bounds code annotated as 'ui_click only' and a restatement of the result shape despite an output schema existing.

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 a 7-parameter tool with no required fields and subtle platform/encoding constraints, the description covers targets, ordering, encodings, failure modes, and the exact workaround path. Nothing an agent needs in order to invoke it correctly or interpret a refusal 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%, yet the description adds real meaning: letters, digits and space in `key` are typed as WM_CHAR rather than pressed as keys, `text` is typed character by character up to 256 chars with no control characters, and text is typed before the key. It also explains allow_lossy's effect and the code-page refusal payload (code_page, characters), though wait_frames and screenshot_after are only lightly touched beyond the 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 opens with a specific verb and resource: pressing a key and/or typing text into the focused part of the game UI, and immediately enumerates the target widgets (dialog text entry, Derma TextEntry, HTML input). It distinguishes itself from siblings by name, telling the agent to focus fields with ui_click and to use lua_exec for text the engine cannot represent.

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 prerequisites (click the field first with ui_click, open a menu if cursor_hidden), the alternative path for non-representable text (lua_exec with DTextEntry:SetText, plus the caveat that SetValue does nothing while focused), and the ordering rule when both parameters are supplied. Both when-to-use and when-to-use-something-else are explicit.

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