Add MCP server for scripted in-game testing #764
Closed
nicholasgower wants to merge 4 commits from
feature/mcp-ingame-testing into main
pull from: feature/mcp-ingame-testing
merge into: MagicBeanDev:main
MagicBeanDev:main
MagicBeanDev:github/pr/2893
MagicBeanDev:github/pr/2890
MagicBeanDev:github/pr/2887
MagicBeanDev:github/pr/2878
MagicBeanDev:github/pr/2875
MagicBeanDev:github/pr/2874
MagicBeanDev:github/pr/2873
MagicBeanDev:github/pr/2871
MagicBeanDev:github/pr/2756
MagicBeanDev:github/pr/2897
MagicBeanDev:github/pr/2896
MagicBeanDev:github/pr/2718
MagicBeanDev:github/pr/2842
MagicBeanDev:github/pr/2691
MagicBeanDev:github/pr/2895
MagicBeanDev:github/pr/2743
MagicBeanDev:github/pr/2765
MagicBeanDev:github/pr/2708
MagicBeanDev:github/pr/2732
MagicBeanDev:github/pr/2755
MagicBeanDev:github/pr/2817
MagicBeanDev:github/pr/2876
MagicBeanDev:release-please--branches--main
MagicBeanDev:release-please--branches--main--release-notes
MagicBeanDev:github/pr/2778
MagicBeanDev:github/pr/2888
MagicBeanDev:github/pr/2866
MagicBeanDev:github/pr/2877
MagicBeanDev:github/pr/2800
MagicBeanDev:github/pr/2829
MagicBeanDev:github/pr/2850
MagicBeanDev:github/pr/2889
MagicBeanDev:github/pr/2882
MagicBeanDev:github/pr/2860
MagicBeanDev:github/pr/2849
MagicBeanDev:github/pr/2886
MagicBeanDev:github/pr/2794
MagicBeanDev:github/pr/2840
MagicBeanDev:github/pr/2830
MagicBeanDev:github/pr/2834
MagicBeanDev:github/pr/2719
MagicBeanDev:github/pr/2742
MagicBeanDev:github/pr/2741
MagicBeanDev:github/pr/2820
MagicBeanDev:github/pr/2771
MagicBeanDev:github/pr/2859
MagicBeanDev:github/pr/2858
MagicBeanDev:github/pr/2823
MagicBeanDev:github/pr/2757
MagicBeanDev:github/pr/2769
MagicBeanDev:github/pr/2844
MagicBeanDev:github/pr/2843
MagicBeanDev:github/pr/2673
MagicBeanDev:github/pr/2855
MagicBeanDev:github/pr/2739
MagicBeanDev:github/pr/2807
MagicBeanDev:github/pr/2851
MagicBeanDev:github/pr/2789
MagicBeanDev:github/pr/2814
MagicBeanDev:github/pr/2818
MagicBeanDev:github/pr/2774
MagicBeanDev:github/pr/2772
MagicBeanDev:github/pr/2750
MagicBeanDev:github/pr/2786
MagicBeanDev:github/pr/2785
MagicBeanDev:github/pr/2782
MagicBeanDev:github/pr/2779
MagicBeanDev:github/pr/2775
MagicBeanDev:github/pr/2706
MagicBeanDev:github/pr/2766
MagicBeanDev:github/pr/2747
MagicBeanDev:github/pr/2759
MagicBeanDev:github/pr/2745
MagicBeanDev:github/pr/2740
MagicBeanDev:github/pr/2733
MagicBeanDev:github/pr/2725
MagicBeanDev:github/pr/2727
MagicBeanDev:github/pr/2728
MagicBeanDev:github/pr/2729
MagicBeanDev:github/pr/2721
MagicBeanDev:github/pr/2722
MagicBeanDev:github/pr/2715
MagicBeanDev:github/pr/2714
MagicBeanDev:github/pr/2707
MagicBeanDev:github/pr/2703
MagicBeanDev:github/pr/2705
MagicBeanDev:github/pr/2697
MagicBeanDev:github/pr/2679
MagicBeanDev:github/pr/2676
MagicBeanDev:github/pr/2669
MagicBeanDev:docs/what-hookshot-connects-to
MagicBeanDev:fix/hdr-encode-test
MagicBeanDev:fix/main-tests
MagicBeanDev:fix/play-cache-files
MagicBeanDev:perf/game-barrier-order
MagicBeanDev:feat/heap-lazy
MagicBeanDev:feat/texture-detail
MagicBeanDev:perf/astc-opaque-bc1
MagicBeanDev:fix/fs-dir-lock
MagicBeanDev:fix/framegen-native-kept
MagicBeanDev:fix/update-no-downgrade
MagicBeanDev:port/k10-gcn-f16-mirrors
MagicBeanDev:fix/framegen-mult-cap
MagicBeanDev:chore/release-as-2.1.1
MagicBeanDev:perf/pcache-load-switch
MagicBeanDev:fix/prepare-progress-log
MagicBeanDev:fix/update-closes-stale-game
MagicBeanDev:fix/hdr-scaled-sampled
MagicBeanDev:perf/first-start-preset
MagicBeanDev:perf/zero-upload
MagicBeanDev:fix/vcore-escape-2s
MagicBeanDev:test/fake-gh-atomic
MagicBeanDev:perf/batch-idle-flush
MagicBeanDev:test/finish-stub-a
MagicBeanDev:chore/record-2.1.0
MagicBeanDev:fix/main-red-tests
MagicBeanDev:fix/test-display-startup-driver-cache
MagicBeanDev:feat/mesh-shader-mode
MagicBeanDev:fix/menu-probes-at-startup
MagicBeanDev:fix/fps-counter-classic
MagicBeanDev:fix/test-log-batch-flake
MagicBeanDev:fix/narrow-screen-hud
MagicBeanDev:ci/prereleases
MagicBeanDev:release/v2.0.15
MagicBeanDev:hotfix/v2.0.15
MagicBeanDev:fix/present-ahead-replay
MagicBeanDev:release/v2.0.13
MagicBeanDev:fix/bracket-paths-2013
MagicBeanDev:fix/hdr-overlays-2013
MagicBeanDev:fix/fps-counter-scale-2013
MagicBeanDev:fix/stick-seen-at-rest
MagicBeanDev:hotfix/menu-fits-screen
MagicBeanDev:fix/f1-always-opens-menu
MagicBeanDev:fix/ini-keep-lines
MagicBeanDev:claude/cranky-pike-7cf247
MagicBeanDev:perf/texture-answer-flat
MagicBeanDev:fix/stamp-test-modules
MagicBeanDev:fix/appimage-fonts
MagicBeanDev:fix/display-awake
MagicBeanDev:release/v2.0.12
MagicBeanDev:fix/discord-windows
MagicBeanDev:rc/v2.0.12-tests
MagicBeanDev:fix/dlss-keep-feature
MagicBeanDev:rc/v2.0.12
MagicBeanDev:button-icons
No reviewers
Labels
Clear labels
accessibility
Barrier affecting people with disabilities
autorelease: pending
autorelease: tagged
bug
Something isn't working
dependencies
Pull requests that update a dependency file
documentation
Improvements or additions to documentation
duplicate
This issue or pull request already exists
enhancement
New feature or request
github_actions
Pull requests that update GitHub Actions code
good first issue
Good for newcomers
help wanted
Extra attention is needed
invalid
This doesn't seem right
question
Further information is requested
testing wanted
wontfix
This will not be worked on
No labels
accessibility
autorelease: pending
autorelease: tagged
bug
dependencies
documentation
duplicate
enhancement
github_actions
good first issue
help wanted
invalid
question
testing wanted
wontfix
Milestone
Clear milestone
No items
No milestone
Assignees
Clear assignees
No assignees
1 participant
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Hookshot!764
Loading…
Reference in a new issue
No description provided.
Delete branch "feature/mcp-ingame-testing"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What this adds
scripts/hookshot_mcp.py: a stdio MCP server built on the official Python SDK (mcp==2.3.0).launch,stop,status,press,stick,sequence,screenshot,wait,logs.hookshot://log,hookshot://last-screenshot,hookshot://status.HOS_INPUT_SCRIPT_ONLY=1ignores physical pads, keyboard and mouse.LX=,LY=,RX=,RY=.!quitlive command for a clean stop.HOOKSHOT_NO_ENV_FILE=1lets the MCP server own the environment.RX_VK_SHOT_FILEandRX_SCREENSHOT_FILErequest one PNG of the next present from the Vulkan and WebGPU renderers.tests/test_mcp_server.py(protocol over stdio, input encoding, env handling, native seams, fake-game end to end), plus analog and script-only cases intests/test_input_background.py.docs/mcp.mdwith host configuration and tool usage; updated development, design, contributing and Vulkan notes.mcp==2.3.0for the new test.Follow-up checks
scripts/pr_check.py: a read-only pre-PR gate. It rejects game-derived paths, CRLF endings, non-Conventional commit subjects and missing commit trailers, then runs the game-free suite unless--no-testsis given. It never stages, commits, pushes or calls GitHub.tests/test_pr_check.py: throwaway-repository coverage for clean and bad PRs, including a.nup, CRLF content, missing trailers and an untracked game file.tests/test_shot_request.py: extracts the productionread_shot_request()fromvk_replay.cppand compiles a fixture for the missing, empty, trimmed, one-shot and buffer-edge cases behindRX_VK_SHOT_FILE.tests/test_docs.py: resolves relative Markdown links, verifies documentedpython/powershellcommands name tracked files, and compares this page's MCP tool/resource tables with the live server.CONTRIBUTING.mdanddocs/development.mdnow point atscripts/pr_check.py;gpu/vk/VULKAN.mdanddocs/mcp.mdpoint at the new fixtures.Verification
python -I -B tests/test_mcp_server.pypython -I -B tests/run_all.py mcp --strictpython -I -B tests/test_input_background.py --cc gcc(all cases, includinganalogandscript-only)python -I scripts/hookshot_mcp.py --check --game-dir <fake-folder>python -I -B tests/test_pr_check.pypython -I -B tests/test_shot_request.py --cxx g++python -I -B tests/test_docs.pypython -I -B tests/run_all.py pr_check shot_request docs --strictThe Vulkan/WebGPU C++ changes could not be compiled in this environment because there is no game build, Vulkan headers or dump here. The input-parser changes were compiled and exercised through the existing fixture; the extracted shot-request parser was compiled and tested separately.
The full local
tests/run_all.py --strictrun gave 71 passed, 11 failed, 9 skipped; the failures are environment/tool gaps here (missing SPIR-V/Vulkan headers,clang/clang++, and Windows symlink privileges innx2/test_nup_paths.py), not the new tests. All three new checks passed.Known issue in the first commit
The first commit
e9c2b0dpredates the newpr_checkgate. It is not a Conventional Commit and lacks theCo-Authored-Bytrailer, sopython -I -B scripts/pr_check.py --base main --no-testsreports it. The three follow-up commits pass. I did not rewrite the published branch; if a rebase/amend is acceptable, the subject should becomefeat: add the Hookshot MCP server for scripted in-game testingand the body should end with both trailers fromdocs/design.mdsection 8.No game files, builds, saves or generated screenshots are included.
I'm also working on a save file editor for this project, and I've decided I will not continue work on this until after the MCP server is merged. Easily automating user input is impossible without a functional MCP server, and I'd rather not combine PRs prematurely. #784
Nice work on this; the game-side seams in particular (script-only input,
!quit, the one-shot screenshot request) are things I've wanted too.I've been running something similar locally for a while, but as a few small command-line tools instead of an MCP server, so I wanted to share how that's turned out. I think the core of this would be more useful as a CLI, with MCP (if wanted) as a thin layer on top.
What I use, roughly:
oot hookshot [--dir D]starts a build with its own data folder (XDG_DATA_HOME), then gets into the newest save by itself. It appends presses to theHOS_INPUT_LIVEfile, and decides when to press from the log rather than from sleeps: the per-seconda frame: N drawsline is about 2 in the intro, 15–70 in menus, about 5 while loading, and hundreds in play.RX_VK_SHOTS). Results are files, plus one summary line per run in a text file (fps, flash count from the frame log, …), so two builds can be A/B'd by diffing.oot-statusis a small GPU queue/lock. With several builds and test runs going at once, I needed runs to stop stepping on each other:hookshot-buildwraps the build with a shared object cache across checkouts. A second checkout of the same commit builds in about 20 s instead of about 12 min.oot-compareloads the same save in Hookshot and in an emulator and takes side-by-side screenshots. The save files are the same format in both. I wrote it up here: https://gist.github.com/hckrman101/701e15b643b7ce32f778116f3004b1a4Why a CLI rather than only MCP:
launch && wait-for play && shot && stop, loop over builds, or diff two runs' logs, without a protocol in between.statusjust reads it back.What I'd suggest: keep the seams as they are, and make
scripts/hookshot_mcp.py's tools into subcommands of one script. For example,hookshot-test launch|press|stick|sequence|shot|wait|logs|status|stop --run <dir>, wherelaunchwrites the run folder and the rest read it. Thenhookshot_mcp.pycan be ~100 lines that call those same functions. Two things I'd add that have saved me a lot of time:waiton game state (log signals: draw counts, "loading", the first present) instead of seconds.Happy to compare notes or help with any of it.
Closing to keep the queue clear — please rebase on current main and reopen; thanks!
Rebased onto current
main(b2765ba) and opened again as #1025, with the real-game verification and the--game-dirfix from that testing included.