Set a convar
convar_setSet Garry's Mod convars in menu, client, or server realms, verify the value by reading it back, and retry via engine console when Lua cannot apply it.
Instructions
Sets a convar from a realm (RunConsoleCommand; server realm: game.ConsoleCommand), waits 3 frames and reads it back. When the value did not take from Lua (some convars, e.g. volume_sfx, ignore Lua) it retries through the engine console (client mode). Convars with FCVAR_ARCHIVE are saved into the user's cfg/config.cfg when the game quits and are shared by every game of this folder: they are refused unless persist: true (your MCP client may then ask the user). Result: the convar as convar_get reads it, plus previous and via (lua or engine). Errors: not_found, protected (FCVAR_PROTECTED), archived, set_refused (cheat without sv_cheats, wrong realm, blocked command). Example: {"name": "sv_gravity", "value": 300, "realm": "server"}.
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": {
"name": "<name>",
"value": "<value>"
},
"name": "convar_set"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | ||
| realm | No | Execution realm (default: menu in client mode, server on srcds). | |
| value | Yes | New value. | |
| persist | No | Allow changing an FCVAR_ARCHIVE convar (persisted in config.cfg). Default false. | |
| instance | No | Optional. Instance identifier (see instances_list). If present and different from the local instance, the call is relayed by the coordinator to that instance. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| max | No | ||
| min | No | ||
| via | No | ||
| help | No | ||
| name | Yes | ||
| next | No | ||
| note | No | ||
| flags | Yes | ||
| value | No | ||
| number | No | ||
| default | No | ||
| warning | No | ||
| previous | No | ||
| next_call | No | ||
| protected | No | ||
| flag_names | Yes | ||
| answered_by | No | ||
| truncated_note | No | ||
| version_warning | No |