Repository navigation
Conversation
MCP-117: `screenshot` takes two optional booleans, both off unless asked. ocr: true runs Apple Vision (`VNRecognizeTextRequest`, accurate) on the clean cropped frame — before any overlay — and answers `ocr`, one item per line in reading order with `text`, `box` in the window's display pixels (the space of `ui_tree`'s box, a ref crop's offset added back and clamped to `size`) and `at`, the box's centre in 0..1 of the window rounded to three decimals, straight into `tap`. Vision normalizes its boxes bottom-left; the conversion to the top-left space is pinned by tests with words drawn at known top and bottom rows. The key is present only when asked (empty when nothing was read), and recognized text lives in the tool result only: no log line carries it (MCP-14). grid: true draws a subtle labelled 0.1…0.9 grid of both axes on the PNG the `image` block carries, in the same 0..1 space `tap` takes; a ref crop draws only the steps it covers, still labelled with their whole-window value. It is drawn after OCR, so a line never reaches a word, and the PNG's pixel size is unchanged. Schemas: the screenshot inputSchema declares both flags with descriptions; the outputSchema names `ocr` (`additionalProperties: false`, every field described) so answers validate (MCP-5), and the tool description matches docs/design/mcp.md word for word (MCP-7). Docs: docs/specs/mcp.md gains MCP-117 with its proofs; docs/design/mcp.md's tools row and screenshot answer shape document both; docs/MAP.md lists the new file. No wire or Android change, no new dependency. Tests: MCPCoreTests (arguments, schema strictness, sample answer, description parity), ScreenshotSourceTests (ocr present only when asked), MCPScreenshotOCRTests (synthetic card at known rows, crop offset, reading order, grid pixels and PNG size, grid after OCR, crop fractions), and the mcp e2e suite's flag/schema checks. Fixes #393 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Fixes #393 (MCP-117)
Outcome
screenshotgains two optional booleans, both off unless asked, with no wire or Android change and no new dependency:ocr: trueruns Apple's on-device Vision (VNRecognizeTextRequest,.accurate) on the clean decoded frame after anyrefcrop and before any grid overlay. The answer carriesocr, one item per line in reading order, each{text, box, at}:boxin the window's display pixels (the space ofui_tree'sbox, a ref crop's offset added back and clamped tosize) andatthe box's centre in0..1of the window, rounded to 3 decimals — directly usable intap. Vision's bottom-left normalized boxes are converted to the top-left display space, pinned by a synthetic card with words at known top and bottom rows. The key is present only when asked ([]when nothing was read). Recognized text lives in the tool result only; no log line carries it (MCP-14).grid: truedraws a subtle, labelled 0.1…0.9 grid of both axes onto the PNG in theimagecontent block, in the same0..1spacetaptakes; a ref crop draws only the steps it covers, still labelled with their whole-window value. It runs after OCR, so a line never reaches a word, and the PNG's pixel size is unchanged.Schemas and docs move in the same commit: input/output schemas (strict
additionalProperties: false, everyocrfield described), the tool description matchesdocs/design/mcp.mdword for word (MCP-7),docs/specs/mcp.mdgains MCP-117 with proofs, anddocs/MAP.mdlists the new file.Checks
New tests are tagged
[MCP-117]:MCPCoreTests.testScreenshotTakesOcrAndGrid_MCP117,testScreenshotOutputSchemaDeclaresOcr_MCP117;ScreenshotSourceTests.testOcrIsAnsweredOnlyWhenAsked_MCP117;MCPScreenshotOCRTests(box/atconversion top vs bottom, ref-crop offset and clamp, reading order, a synthetic card's known rows, crop-fraction grid mapping, grid pixels/PNG size, grid drawn after OCR); plussuite_screen.py's flag/schema checks.The unfiltered
swift testpre-existing teardown stall (#161) is why the filter above is used; no test processes were left running.