Repository navigation
feat(mcp): game-view screenshots with aligned overlays (#465) - #713
Merged
Merged
Conversation
…ew size game_screenshot read Config.Viewport directly, so a game supplying its viewport through ViewportFunc got an unscaled frame and overlays without the letterbox transform, and the PR declared its own SetViewport and Viewport field on top of the ones main already has. It now uses activeViewport and activeViewSize, the mapping game_input_pointer uses: the default size is the view (ViewSizeFunc, the window, then the virtual size), and Viewport.Layout runs on the view in points and is scaled to the image, so a CaptureFrame image in device pixels gets the scale the game used rather than the one Layout picks for the pixel size. Inferred sizes are now bounded like explicit ones and non-finite sizes are refused, a named scene with no scene.Scene is an error instead of a blank image, paths must end in .png, grid_step is accepted at the top level too, and OverlaysDrawn uses omitempty for every flag. The software rasterizer flattens quadratic and cubic curves, reads image source rectangles in the image's points when ImageSource.Size is set, no longer copies Data on every cache lookup, and reports what it leaves out (skipped_ops by kind, skipped_images for URI, asset: and Offscreen sources).
Adds a 2x CaptureFrame under an integer-scaled ViewportFunc, an image with Size, URI images and unsupported ops reported as skipped, a named scene without a scene.Scene, inferred sizes over the caps or not finite, a pixel-count cap within the per-side cap, a symlink leaving ScreenshotDir, non-.png paths and top-level grid_step. Existing cases now set ViewSizeFunc or read the test window, since the default size follows the view.
…e primary mode An MCP client receives an app tool's result as JSON text, so png_base64 is text to the agent; the docs now steer agents to path inside ScreenshotDir, and describe the view size and pixel ratio, scene rendering, skipped_ops and skipped_images, and which sprites get bounds.
houko
force-pushed
the
feat/mcp-screenshots-overlays-465
branch
from
November 24, 2026 19:52
0a9f065 to
c6b7af7
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements the
game_screenshotMCP tool inpackages/game/mcpso coding agents can capture the running game view as a PNG with optional pixel-aligned diagnostic overlays:packages/game/mcp/screenshot.go): supportsConfig.CaptureFrame(compositing overlays onto a cloned*image.RGBA),Config.DrawFrame, or direct rendering ofConfig.Scenes/Config.Scene/Config.SceneFuncunder the sameViewport/ViewportFuncand view size thatgame_input_pointeruses, via a self-contained deterministic software rasterizer.bounds: 1-pixel bounding rectangles aligned with every visible sprite acrosstilemap.Camera(pan, zoom, shake, parallax, repeat),SpaceScreenHUD layers, andscreen.Viewportscaling/letterbox clipping.collision_shapes/physics: 2D collision shapes fromConfig.Physics/Config.PhysicsFunc(box bodies, circle bodies with+Xorientation tick, triggers, solid and one-way tiles) andConfig.RigidPhysics/Config.RigidPhysicsFunc(rotated rigid bodies), matchingphysics.DefaultDebugStyle()colors.grid(withgrid_step),camera(visible frame + center crosshair), andlabels(compact bitmap font labels).png_base64by default or writes confined insideConfig.ScreenshotDirviaos.OpenRootwhenpathis given; rejects unknown fields, invalid dimensions, unsupported formats, and path traversal.mcp.godiff: additiveConfigfields and appendingb.screenshotTools()inBridge.Tools()so parallel MCP PRs (MCP: control the loop #462–MCP: assets and hot reload #469) rebase cleanly.docs/en/mcp.md,docs/zh/mcp.md, added changelog fragmentchangelog.d/mcp-screenshots-overlays-465.mdand engineering note.agents/notes/implemented/feature/2026-11-24-mcp-screenshots-and-overlays.md.Changes after review (rebased onto main after #462, #463 and the asset tools)
Config.Viewport,ViewportFunc,ViewSizeFuncandBridge.SetViewportinstead of redeclaring them. The default size is the view (ViewSizeFunc, the window, then the virtual size), andViewport.Layoutruns on the view in points and is scaled to the image, so aCaptureFrameimage at a 2x pixel ratio gets the game's scale.scene.Sceneis an error;pathmust end in.png;grid_stepis also accepted at the top level.ImageSource.Sizeis set, and reports what it leaves out inskipped_opsandskipped_images(text, ellipses, gradients, URI /asset:/Offscreenimages).path: an MCP client receives an app tool's result as JSON text, sopng_base64is text to the agent until NSGo lets app tools return image content.Verification
git ls-files -z -- '*.go' | xargs -0 -r gofmt -l(empty)go run ./cmd/gameschema -check(passed)go tool nsgo check -target macos,windows,linux,android,web(passed on all targets)go tool nsgo test ./mcp(44 passed, including pixel-exact alignment under camera pan/zoom/parallax,screen.Viewportletterboxing and a 2xCaptureFrame)go tool nsgo check -target linux,web ./mcpand the fullgo tool nsgo test .after the rebasego tool nsgo test -run TestStabilityTable .(passed)go run ./tools/changelog check(passed)bun run verify-notes(passed)Closes #465