README
¶
mcp-sh-godot
A sandboxed bash shell over the live Godot editor, or a running game, served over MCP. Built
on mcp-sh. The binary carries its own addon, a native
mcp-sh host on 127.0.0.1:9510 in the editor (9511 in a game). The agent runs
gdsh commands with pipes, loops and jq.
mcp-sh-godot run 'tree root | tree nodes --recursive | grep -c Camera'
Install
curl -fsSL https://raw.githubusercontent.com/brohd11/mcp-sh-godot/main/install.sh | sh
mcp-sh-godot setup # ~/.mcp-sh/godot/ + prints the claude/codex mcp add commands
On Windows: irm https://raw.githubusercontent.com/brohd11/mcp-sh-godot/main/install.ps1 | iex.
Then, in each Godot project:
mcp-sh-godot addon install # writes res://addons/mcp_sh_godot/, versioned with this binary
mcp-sh-godot addon status # addon vs binary version, gdsh, editor_console
mcp-sh-godot commands # check what the shell can reach
Enable mcp-sh-godot in Project Settings > Plugins. It listens while the editor is open.
Run mcp-sh-godot addon install again after mcp-sh-godot update, so the addon matches the
binary. addon remove takes it out.
Which commands it offers:
- With Editor Console enabled, its
commands are offered. They run in the console's context (
.gdrc, the undo stack), taking turns with what you type into it. - Without it, gdsh's own commands are offered, plus gdsh_lib's
treeandutilswhen installed. gdsh is found by itsGDShclass wherever gdaddon put it (gdaddon install brohd11/godot-gdsh). - Either way, commands from
bridge.jsonare added.
Commands get their arguments exactly as bash passed them: no gdsh quoting, variables or
aliases apply. cd and pwd are gdsh's (mcp-sh hands bash's to them), as are cn and
pwn for the working node. Both carry over between calls, separate from the console prompt.
In a running game
The bridge is a node, so a game or app adds it the way the plugin does. Then register the
mcp-sh-godot-game entry that setup (and --help) prints for each agent; it sets
MCP_SH_GODOT_PORT=9511.
const McpShBridge = preload("res://addons/mcp_sh_godot/bridge.gd")
func _ready():
var bridge = McpShBridge.new()
bridge.host = my_console.create_host() # optional: any GDSh.Host; plain gdsh when null
add_child(bridge)
- It listens on
9511unlessportis set, and saysgodot runtimeinlist_commands. - Release builds don't listen unless
serve_in_releaseis set: commands can run any code. - Without a host it serves gdsh's builtins and gdsh_lib, which work on the live tree. Use
GDSh.Host.new({"command_dirs": ["res://game/commands"]})for the game's own commands.
Bridge config
The addon reads ~/.mcp-sh/godot/bridge.json, then res://.mcp-sh/godot/bridge.json.
Later files win, and commandDirs/exclude add up. Use Project > Tools > Restart mcp-sh-godot
Bridge after editing them.
{
"port": 0,
"token": "",
"autostart": true,
"editorConsole": true,
"gdshLib": true,
"commandDirs": ["res://tools/agent"],
"commands": {"bake": "res://tools/bake_command.gd"},
"exclude": ["settings"],
"include": ["echo"]
}
commandDirsare gdsh command folders.commandsmaps a name to one command script. Relative paths are relative to the config file, and~/is the home folder.port0 is 9510 in the editor.excludehides commands. The defaults hide gdsh's session builtins, the text tools the shell already has (grep,head,tail) andos/term.includebrings a default back.- With a token, set the same one for the shell:
MCP_SH_GODOT_TOKEN. A different port needsMCP_SH_GODOT_PORT. The editor also reads both variables as defaults, if it was started with them.
Shell overrides go in ~/.mcp-sh/godot/config.json (or ./.mcp-sh/godot.json for one
project). See the mcp-sh README for the config keys.
Development
make # host build -> build/<os>-<arch>/mcp-sh-godot
make test
make package # release archives for every platform
The addon's source is addon/mcp_sh_godot/, embedded into the binary. To work on it, symlink
that folder into a project's addons/.
The makefile body, installers, workflows and cliff.toml are rendered from
sh-templates by the workspace's render-go.sh.
Only the config blocks above # ---- end config ---- are edited here. Pushing a v* tag
releases.