Launcher MCP: every CLI command is a tool of the same name, plus settings and agent-config

The MCP tools are generated from the CLI's clap definition (cli_tools.rs):
mods_search is horizon-launcher mods search, with the same arguments, and
a call runs that command with --json. So the mod browser, modpacks, hosted
servers, settings, game arguments, data collection, desktop entry and the
benchmark are all reachable, and new CLI commands become tools by
themselves. Destructive ones need confirm: true and carry destructiveHint.
The session keeps play, server (with server_command/log/stop),
account_list and account_sign_in in-process, renamed after the CLI
(launch_client is play; play takes join for an invite code).

New CLI commands: settings [KEY VALUE] (selected version, folders,
install-new-versions, opening animation) and agent-config, the MCP config
for Claude Code, Codex, Cursor and any client. play takes --world and
--creative. Under No AI, mcp and agent-config are hidden and refused.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Ludovic Marie
2026-10-23 02:01:57 +02:00
parent b117930ae4
commit ef792ec3b9
9 changed files with 737 additions and 261 deletions
+29 -10
View File
@@ -3,9 +3,10 @@
A scratch launcher home gets one "installed" version made of this checkout's builds
(horizon-client and horizon-ctl) and the prepared resources in .local/horizon-client. An MCP
client then talks to `horizon-launcher mcp` alone: the game tools are listed, a call before the
game runs says to launch it, launch_client starts it under control, and game_wait_ready,
game_state, game_ui and game_screenshot play it until game_quit. Then No AI is turned on with
client then talks to `horizon-launcher mcp` alone: every CLI command is listed as a tool of the same
name (versions, settings, mods_search...), a destructive one needs confirm, the game tools are
listed, a call before the game runs says to start it, play starts it under control, and
game_wait_ready, game_state, game_ui and game_screenshot play it until game_quit. Then No AI is turned on with
`horizon-launcher no-ai on`: `horizon-launcher mcp` refuses to start, and a session already running
refuses its next call.
@@ -70,14 +71,27 @@ def scenario(m, out):
'clientInfo': {'name': 'launcher_mcp_e2e', 'version': '1'}})
assert init['serverInfo']['name'] == 'horizon-launcher', init
tools = {t['name'] for t in m.rpc('tools/list', {})['tools']}
for name in ['launch_client', 'game_state', 'game_ui', 'game_click', 'game_screenshot']:
for name in ['play', 'server', 'versions', 'settings', 'mods_search', 'modpack_list', 'servers_list',
'data_status', 'account_list', 'game_args', 'game_state', 'game_ui', 'game_click',
'game_screenshot']:
assert name in tools, f'{name} missing from {sorted(tools)}'
assert 'game_launch' not in tools, 'launch_client covers horizon-ctl launch'
for name in ['game_launch', 'mcp', 'no_ai', 'agent_config']:
assert name not in tools, f'{name} is a tool'
# Generated from the CLI: the same command, its JSON output.
result, texts, _ = m.call('versions', installed=True)
assert json.loads(texts[-1])['installed'] == [TAG], texts
result, texts, _ = m.call('settings', key='opening-animation', value='off')
assert json.loads(texts[-1])['opening_animation'] is False, texts
result, texts, _ = m.call('game_args')
assert 'game_args' in json.loads(texts[-1]), texts
result, texts, _ = m.call('remove', tag=TAG)
assert result['isError'] and 'confirm' in texts[-1], texts
result, texts, _ = m.call('game_state')
assert result['isError'] and 'launch_client' in texts[-1], texts
assert result['isError'] and 'with play' in texts[-1], texts
result, texts, _ = m.call('launch_client', world='Agent', creative=True,
result, texts, _ = m.call('play', world='Agent', creative=True,
offscreen=sys.platform == 'darwin')
assert not result['isError'], texts
result, texts, _ = m.call('game_wait_ready', seconds=300)
@@ -105,6 +119,9 @@ def no_ai_scenario(launcher, env, home):
run = lambda *a: subprocess.run([str(launcher), *a], env=env, input='', capture_output=True, text=True,
timeout=60)
assert json.loads(run('no-ai', '--json').stdout) == {'no_ai': False}
config = json.loads(run('agent-config', '--json').stdout)
assert config['server']['args'] == ['mcp'] and len(config['clients']) == 4, config
assert 'agent-config' in run('--help').stdout
m = Mcp(launcher, env)
m.rpc('initialize', {'protocolVersion': '2025-06-18', 'capabilities': {},
'clientInfo': {'name': 'launcher_mcp_e2e', 'version': '1'}})
@@ -117,9 +134,11 @@ def no_ai_scenario(launcher, env, home):
except Failed as e:
assert REFUSAL in str(e), e
m.close()
r = run('mcp')
print(f'[launcher-mcp] mcp under No AI -> exit {r.returncode}: {r.stderr.strip()}')
assert r.returncode == 1 and r.stderr.strip() == f'error: {REFUSAL}', r
for command in ('mcp', 'agent-config'):
r = run(command)
print(f'[launcher-mcp] {command} under No AI -> exit {r.returncode}: {r.stderr.strip()}')
assert r.returncode == 1 and r.stderr.strip() == f'error: {REFUSAL}', r
assert 'agent-config' not in run('--help').stdout and ' mcp ' not in run('--help').stdout
# What the launcher needs keeps working.
assert run('versions', '--installed', '--json').returncode == 0
assert run('no-ai', 'off').returncode == 0