Skip to main content
Glama

Run a console command

console_exec
Destructive

Runs console command lines in menu, client, or server realms, returns the printed output, and reports read-back convar values or unknown-command errors.

Instructions

Runs a console command line from a realm (menu: RunConsoleCommand; server: game.ConsoleCommand; client: RunConsoleCommand, with automatic fallback to the engine if the command is blocked from Lua). Like the engine console, ';' and line breaks outside quotes separate commands: 'a 1; b 2' runs a then b (statements lists them). Waits a few frames then returns the console lines printed meanwhile (gmod-mcp's own log lines left out; the console is shared, so filter with regex). An unknown command or convar is an error (unknown_command), not a silent no-op. For every convar it set or named, convars gives the value read back (value, number, and a warning for FCVAR_ARCHIVE convars, which land in the user's config and are shared by every instance). killserver on a game that hosts a map first leaves it like disconnect (left_game_first: true): run in game it can crash the engine. Example: {"cmd": "sv_gravity 600"}. convar_set refuses archived convars unless persist: 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": {
      "cmd": "<cmd>"
    },
    "name": "console_exec"
  }
}

Input Schema

NameRequiredDescriptionDefault
cmdYesCommand line, e.g. 'echo hello' or 'sv_gravity 600'.
realmNoExecution realm (default: menu in client mode, server on srcds).
regexNoKeep only the output lines matching this (ECMAScript, case-insensitive).
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 before reading the output (default 5).
connect_timeout_sNoFor `connect`: how long to wait for the outcome, reported in connect_result (default 20).

Output Schema

NameRequiredDescriptionDefault
cmdYes
viaYes
nextNo
noteNo
realmYes
outputYes
convarsNo
warningNo
next_callNo
statementsNo
answered_byNo
next_cursorYes
output_noteNo
blocked_in_luaNo
connect_resultNo
truncated_noteNo
left_game_firstNo
version_warningNo

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.3.7

TDQS

A4.6/5.0
Behavior5/5

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

Goes well beyond the destructiveHint=true annotation: it discloses the frame wait before reading, that only console lines from the meanwhile window are returned, that gmod-mcp's own log lines are excluded, that unknown commands produce an error rather than a no-op, that convars are read back with FCVAR_ARCHIVE warnings, and that `killserver` first leaves the game like `disconnect`. This is exactly the added context the destructive annotation cannot carry.

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

Conciseness4/5

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

Front-loaded with the core action and semantics, and nearly every sentence carries operational information. It is dense and slightly overloaded — the trailing convar_set/persist sentence and the convar readback discussion sit a step away from the primary call path.

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 6-parameter destructive tool with an output schema, the description covers execution semantics, filtering, error behavior, side effects on user config, and the one dangerous command case. An agent has everything needed to call it correctly and safely.

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 100%, so baseline is 3, and the description adds real meaning on top: `regex` filters a shared console stream, `wait_frames` corresponds to the 'few frames' delay, and `realm` behavior is spelled out with fallback semantics. The `statements` and `convars` outputs are described, though `instance` and `connect_timeout_s` are left entirely to 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?

States a specific verb and resource ('Runs a console command line from a realm') and immediately pins down the underlying implementation per realm (menu: RunConsoleCommand; server: game.ConsoleCommand; client: RunConsoleCommand with engine fallback). An agent can distinguish this from lua_exec or convar_set without opening 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 Guidelines4/5

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

Gives concrete operating context: command separators, regex filtering of shared output, and the explicit caveat that `killserver` in-game can crash the engine, plus the `convar_set`/`persist` distinction for archived convars. It stops short of a full when-to-use-this-instead-of-lua_exec routing statement, so it is clear but not exhaustive.

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