@ingcreators/annot-mcp 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/LICENSE +201 -0
- package/README.md +340 -0
- package/bin/annot-mcp.mjs +31 -0
- package/dist/browser/capture.d.ts +40 -0
- package/dist/browser/pool.d.ts +58 -0
- package/dist/browser/resolve-locator.d.ts +43 -0
- package/dist/compare/aggregate.d.ts +6 -0
- package/dist/compare/diff.d.ts +30 -0
- package/dist/dsl/schema.d.ts +466 -0
- package/dist/dsl/svg-primitives.d.ts +34 -0
- package/dist/dsl/to-svg.d.ts +10 -0
- package/dist/dsl/types.d.ts +126 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.js +1355 -0
- package/dist/io/png-dimensions.d.ts +16 -0
- package/dist/io/read-image.d.ts +24 -0
- package/dist/redact/burn.d.ts +14 -0
- package/dist/server.d.ts +34 -0
- package/dist/tools/annotate-screenshot.d.ts +293 -0
- package/dist/tools/annotate-url.d.ts +342 -0
- package/dist/tools/compare-screenshots.d.ts +49 -0
- package/dist/tools/redact-screenshot.d.ts +116 -0
- package/dist/tools/redact-url.d.ts +160 -0
- package/dist/transport.d.ts +8 -0
- package/package.json +65 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
# @ingcreators/annot-mcp
|
|
2
|
+
|
|
3
|
+
## 0.1.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- Initial public release of `@ingcreators/annot-mcp` — Model Context Protocol stdio server exposing the Annot headless annotator as five agent-callable tools: `annot_annotate_screenshot`, `annot_annotate_url` (locator-first), `annot_redact_screenshot`, `annot_redact_url`, `annot_compare_screenshots`. Pairs naturally with `@playwright/mcp` for multi-step browser flows; runs standalone for single-URL annotation + redaction + visual-diff workflows. See `docs/ai-agents.md`.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for describing the origin of the Work and
|
|
141
|
+
reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2026 ingcreators
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,340 @@
|
|
|
1
|
+
# `@ingcreators/annot-mcp`
|
|
2
|
+
|
|
3
|
+
Model Context Protocol server exposing the
|
|
4
|
+
[`@ingcreators/annot-annotator`](../annotator/README.md) headless
|
|
5
|
+
annotator as agent-callable tools. Drop into Claude Desktop /
|
|
6
|
+
Claude Code / Cursor / Continue and an AI agent can compose Annot
|
|
7
|
+
with `@playwright/mcp` + GitHub MCP into autonomous
|
|
8
|
+
browser-driven workflows:
|
|
9
|
+
|
|
10
|
+
- **Bug-report autopilot** — agent navigates to a staging URL,
|
|
11
|
+
identifies a broken element, files a GitHub issue with an
|
|
12
|
+
annotated screenshot in one conversation turn.
|
|
13
|
+
- **Visual-diff PR review** — agent screenshots the same page on
|
|
14
|
+
two branches, posts the diff with changed regions highlighted.
|
|
15
|
+
- **Locator-first annotation** — agent says `{ type: "rect",
|
|
16
|
+
locator: "button:has-text('Submit')", intent: "error" }` in a
|
|
17
|
+
single MCP call; the server handles capture + locator
|
|
18
|
+
resolution + render.
|
|
19
|
+
|
|
20
|
+
> **Status:** under construction. Phases 1–5 + 7 of
|
|
21
|
+
> [`docs/plans/agent-mcp-integration.md`](../../docs/plans/agent-mcp-integration.md)
|
|
22
|
+
> have landed; the package is `private: true` in the workspace
|
|
23
|
+
> until Phase 8 (gated on
|
|
24
|
+
> [`docs/plans/headless-annotator-publish.md`](../../docs/plans/headless-annotator-publish.md))
|
|
25
|
+
> flips it for the first npm publish. Phase 6 (PPTX export) is
|
|
26
|
+
> deferred indefinitely per the plan.
|
|
27
|
+
|
|
28
|
+
## Installation
|
|
29
|
+
|
|
30
|
+
After Phase 8 publish:
|
|
31
|
+
|
|
32
|
+
```sh
|
|
33
|
+
# Once globally (or via npx per-call)
|
|
34
|
+
npm install -g @ingcreators/annot-mcp
|
|
35
|
+
|
|
36
|
+
# Chromium runtime for `_url` tools — one-time, ~150 MB download
|
|
37
|
+
npx playwright install chromium
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Then wire into your MCP client config. For Claude Desktop
|
|
41
|
+
(`~/Library/Application Support/Claude/claude_desktop_config.json`
|
|
42
|
+
on macOS, `%APPDATA%\Claude\claude_desktop_config.json` on
|
|
43
|
+
Windows):
|
|
44
|
+
|
|
45
|
+
```json
|
|
46
|
+
{
|
|
47
|
+
"mcpServers": {
|
|
48
|
+
"annot": {
|
|
49
|
+
"command": "npx",
|
|
50
|
+
"args": ["@ingcreators/annot-mcp"]
|
|
51
|
+
},
|
|
52
|
+
"playwright": {
|
|
53
|
+
"command": "npx",
|
|
54
|
+
"args": ["@playwright/mcp@latest"]
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Restart the client. The five `annot_*` tools appear alongside
|
|
61
|
+
playwright-mcp's `browser_*` tools and any other MCP servers
|
|
62
|
+
you've configured.
|
|
63
|
+
|
|
64
|
+
## The five tools
|
|
65
|
+
|
|
66
|
+
Each tool returns an MCP `image` content block (base64 PNG)
|
|
67
|
+
inline in the agent's conversation, OR — when `output` is set
|
|
68
|
+
to an absolute path — writes the PNG to disk and returns a
|
|
69
|
+
text confirmation.
|
|
70
|
+
|
|
71
|
+
### `annot_annotate_screenshot`
|
|
72
|
+
|
|
73
|
+
Overlay annotations on a pre-captured PNG.
|
|
74
|
+
|
|
75
|
+
**Inputs:**
|
|
76
|
+
- `image` — `data:image/png;base64,...` URL or absolute path.
|
|
77
|
+
- `annotations` — array of `BboxAnnotation` (see DSL below).
|
|
78
|
+
- `output` (optional) — absolute path.
|
|
79
|
+
|
|
80
|
+
### `annot_annotate_url`
|
|
81
|
+
|
|
82
|
+
Open a URL in headless Chromium, capture, overlay annotations
|
|
83
|
+
positioned by Playwright locator strings (or bboxes). The
|
|
84
|
+
headline locator-first tool — one MCP call replaces the
|
|
85
|
+
multi-step `playwright-mcp.browser_navigate` →
|
|
86
|
+
`browser_screenshot` → `browser_locator` × N →
|
|
87
|
+
`annot_annotate_screenshot` flow.
|
|
88
|
+
|
|
89
|
+
**Inputs:**
|
|
90
|
+
- `url` — page URL.
|
|
91
|
+
- `annotations` — array of `LocatorAnnotation` (locator string
|
|
92
|
+
or coordinate).
|
|
93
|
+
- `viewport` (optional) — `{ width, height, deviceScaleFactor }`,
|
|
94
|
+
default 1280×800 at 1×.
|
|
95
|
+
- `fullPage` (optional, default `false`).
|
|
96
|
+
- `waitFor` (optional, default `"load"`) — `"load"` /
|
|
97
|
+
`"domcontentloaded"` / `"networkidle"`.
|
|
98
|
+
- `output` (optional).
|
|
99
|
+
|
|
100
|
+
### `annot_redact_screenshot`
|
|
101
|
+
|
|
102
|
+
Destructively burn redactions (solid / mosaic / blur) into a
|
|
103
|
+
PNG. Original pixels under each region are irrecoverably
|
|
104
|
+
replaced.
|
|
105
|
+
|
|
106
|
+
**Inputs:**
|
|
107
|
+
- `image` — same as `annot_annotate_screenshot`.
|
|
108
|
+
- `regions` — array of `{ bbox, style?, color? }`. `style` is
|
|
109
|
+
`"solid"` (default) / `"mosaic"` / `"blur"`.
|
|
110
|
+
- `output` (optional).
|
|
111
|
+
|
|
112
|
+
### `annot_redact_url`
|
|
113
|
+
|
|
114
|
+
Live-capture variant of redact. Regions accept locator strings
|
|
115
|
+
or bboxes.
|
|
116
|
+
|
|
117
|
+
**Inputs:**
|
|
118
|
+
- `url` / `viewport` / `fullPage` / `waitFor` / `output` — same
|
|
119
|
+
as `annot_annotate_url`.
|
|
120
|
+
- `regions` — array of `{ bbox | locator, style?, color? }`.
|
|
121
|
+
|
|
122
|
+
### `annot_compare_screenshots`
|
|
123
|
+
|
|
124
|
+
Pixel-perfect diff between two PNGs of identical dimensions.
|
|
125
|
+
Returns a PNG of the `after` image with changed regions
|
|
126
|
+
highlighted as `warning`-intent rects.
|
|
127
|
+
|
|
128
|
+
**Inputs:**
|
|
129
|
+
- `before` / `after` — PNG inputs (data URL or absolute path).
|
|
130
|
+
- `threshold` (optional, default `0.1`) — pixelmatch
|
|
131
|
+
sensitivity (0 = strict, 1 = permissive).
|
|
132
|
+
- `includeChangeList` (optional) — when `true`, append a text
|
|
133
|
+
content block listing the changed-region bboxes.
|
|
134
|
+
- `output` (optional).
|
|
135
|
+
|
|
136
|
+
## The annotation DSL
|
|
137
|
+
|
|
138
|
+
Two flavours. `BboxAnnotation` (used by `_screenshot` tools)
|
|
139
|
+
requires explicit positions; `LocatorAnnotation` (used by `_url`
|
|
140
|
+
tools) accepts Playwright locator strings or coordinates.
|
|
141
|
+
|
|
142
|
+
### Intent shorthand
|
|
143
|
+
|
|
144
|
+
Every annotation accepts an `intent: "info" | "warning" | "error"
|
|
145
|
+
| "success" | "neutral"` that resolves to the Annot design
|
|
146
|
+
system's semantic colours:
|
|
147
|
+
|
|
148
|
+
| Intent | Stroke | Text |
|
|
149
|
+
|---|---|---|
|
|
150
|
+
| `info` | `#3b82f6` | `#1e40af` |
|
|
151
|
+
| `warning` | `#f59e0b` | `#92400e` |
|
|
152
|
+
| `error` (default) | `#ef4444` | `#991b1b` |
|
|
153
|
+
| `success` | `#10b981` | `#065f46` |
|
|
154
|
+
| `neutral` | `#6b7280` | `#374151` |
|
|
155
|
+
|
|
156
|
+
Explicit `stroke` / `color` / `fill` override the intent
|
|
157
|
+
defaults.
|
|
158
|
+
|
|
159
|
+
### Annotation types
|
|
160
|
+
|
|
161
|
+
```ts
|
|
162
|
+
// BboxAnnotation (for _screenshot tools).
|
|
163
|
+
type BboxAnnotation =
|
|
164
|
+
| { type: "rect"; bbox: BBox; intent?: Intent; ... }
|
|
165
|
+
| { type: "circle"; center: Point; radius: number; ... }
|
|
166
|
+
| { type: "arrow"; from: Point; to: Point; ... }
|
|
167
|
+
| { type: "text"; at: Point; content: string; fontSize?: number; ... }
|
|
168
|
+
| { type: "callout"; at: Point; targetBbox: BBox; content: string; ... }
|
|
169
|
+
| { type: "raw"; svgFragment: string };
|
|
170
|
+
|
|
171
|
+
// LocatorAnnotation (for _url tools). Same shapes — but you can
|
|
172
|
+
// substitute `locator` (or `fromLocator` / `toLocator` /
|
|
173
|
+
// `atLocator` / `targetLocator`) for any coordinate field.
|
|
174
|
+
type LocatorAnnotation =
|
|
175
|
+
| { type: "rect"; bbox?: BBox; locator?: string; ... }
|
|
176
|
+
| { type: "circle"; center?: Point; radius?: number; locator?: string; ... }
|
|
177
|
+
| { type: "arrow"; from?: Point; fromLocator?: string;
|
|
178
|
+
to?: Point; toLocator?: string; ... }
|
|
179
|
+
| { type: "text"; at?: Point; locator?: string; content: string; ... }
|
|
180
|
+
| { type: "callout"; at?: Point; atLocator?: string;
|
|
181
|
+
targetBbox?: BBox; targetLocator?: string;
|
|
182
|
+
content: string; ... }
|
|
183
|
+
| { type: "raw"; svgFragment: string };
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
### Non-rect locator adaptation
|
|
187
|
+
|
|
188
|
+
When a `locator` resolves to a bounding box on a non-rect shape:
|
|
189
|
+
|
|
190
|
+
- **circle** — center = bbox centroid; radius = `min(w, h) / 2`.
|
|
191
|
+
- **arrow** endpoint — bbox centroid.
|
|
192
|
+
- **text** — `at` = bbox top-left, raised one font line above so
|
|
193
|
+
the caption sits above the element.
|
|
194
|
+
- **callout** — `targetLocator` becomes the highlighted rect;
|
|
195
|
+
`atLocator` becomes the caption anchor (also centroid).
|
|
196
|
+
|
|
197
|
+
## Two end-to-end transcripts
|
|
198
|
+
|
|
199
|
+
### A. Locator-first standalone — bug-report autopilot
|
|
200
|
+
|
|
201
|
+
```
|
|
202
|
+
USER: Go to https://staging.example.com/login, find any disabled
|
|
203
|
+
submit button, and file a GitHub issue against
|
|
204
|
+
ingcreators/example with an annotated screenshot.
|
|
205
|
+
|
|
206
|
+
AGENT → annot.annot_annotate_url({
|
|
207
|
+
url: "https://staging.example.com/login",
|
|
208
|
+
annotations: [
|
|
209
|
+
{ type: "rect",
|
|
210
|
+
locator: "button:has-text('Submit')",
|
|
211
|
+
intent: "error" },
|
|
212
|
+
{ type: "callout",
|
|
213
|
+
atLocator: "form",
|
|
214
|
+
targetLocator: "button:has-text('Submit')",
|
|
215
|
+
content: "Submit button is disabled" }
|
|
216
|
+
]
|
|
217
|
+
})
|
|
218
|
+
← annotated PNG inline
|
|
219
|
+
AGENT → github.create_issue({
|
|
220
|
+
repo: "ingcreators/example",
|
|
221
|
+
title: "Login form: Submit button disabled on staging",
|
|
222
|
+
body: "...", // PNG attached
|
|
223
|
+
})
|
|
224
|
+
← issue URL
|
|
225
|
+
AGENT: Filed https://github.com/ingcreators/example/issues/42.
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
### B. Composing with `@playwright/mcp` — multi-step flow
|
|
229
|
+
|
|
230
|
+
For workflows that need interactivity (sign-in, click, wait)
|
|
231
|
+
before the capture, drive the browser through
|
|
232
|
+
`@playwright/mcp` and feed its screenshot output to
|
|
233
|
+
`annot_annotate_screenshot`:
|
|
234
|
+
|
|
235
|
+
```
|
|
236
|
+
USER: Log in as alice@example.com on staging, navigate to the
|
|
237
|
+
dashboard, annotate the "team analytics" panel for the
|
|
238
|
+
onboarding doc.
|
|
239
|
+
|
|
240
|
+
AGENT → playwright.browser_navigate({ url: ".../login" })
|
|
241
|
+
AGENT → playwright.browser_fill({ selector: "[name=email]",
|
|
242
|
+
text: "alice@example.com" })
|
|
243
|
+
AGENT → playwright.browser_fill({ selector: "[name=password]",
|
|
244
|
+
text: <secret> })
|
|
245
|
+
AGENT → playwright.browser_click({ selector: "button:has-text('Sign in')" })
|
|
246
|
+
AGENT → playwright.browser_wait_for_url({ pattern: "**/dashboard" })
|
|
247
|
+
AGENT → playwright.browser_screenshot({ fullPage: true })
|
|
248
|
+
← bytes
|
|
249
|
+
AGENT → playwright.browser_locator({
|
|
250
|
+
selector: "[data-testid='team-analytics']" })
|
|
251
|
+
← bbox
|
|
252
|
+
AGENT → annot.annot_annotate_screenshot({
|
|
253
|
+
image: <PNG>,
|
|
254
|
+
annotations: [
|
|
255
|
+
{ type: "rect", bbox, intent: "success" },
|
|
256
|
+
{ type: "callout", at: { x: 20, y: bbox.y - 40 },
|
|
257
|
+
targetBbox: bbox,
|
|
258
|
+
content: "Team analytics — review weekly" }
|
|
259
|
+
]
|
|
260
|
+
})
|
|
261
|
+
← annotated PNG
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
The MCP server stays browser-free in this flow — Annot's
|
|
265
|
+
`annot_annotate_url` is the one-shot path, `annot_annotate_screenshot`
|
|
266
|
+
is the composable primitive.
|
|
267
|
+
|
|
268
|
+
## Package boundaries
|
|
269
|
+
|
|
270
|
+
| File / module | Role |
|
|
271
|
+
|---|---|
|
|
272
|
+
| `bin/annot-mcp.mjs` | CLI shim — boots the server over stdio |
|
|
273
|
+
| `src/server.ts` | `createServer()` factory — wires tools + dispatch |
|
|
274
|
+
| `src/transport.ts` | `runStdioServer()` — stdio transport |
|
|
275
|
+
| `src/dsl/types.ts` | `BboxAnnotation` + `LocatorAnnotation` unions |
|
|
276
|
+
| `src/dsl/schema.ts` | JSON Schema literals for MCP `inputSchema` |
|
|
277
|
+
| `src/dsl/to-svg.ts` | DSL → SVG fragment converter |
|
|
278
|
+
| `src/dsl/svg-primitives.ts` | Tier A SVG fragment builders |
|
|
279
|
+
| `src/io/png-dimensions.ts` | PNG IHDR width/height parser |
|
|
280
|
+
| `src/io/read-image.ts` | data URL / filesystem → bytes + dims |
|
|
281
|
+
| `src/browser/pool.ts` | `BrowserPool` — refcounted lifecycle |
|
|
282
|
+
| `src/browser/capture.ts` | `capturePage()` — Chromium navigate + screenshot |
|
|
283
|
+
| `src/browser/resolve-locator.ts` | locator string → bbox + per-shape adaptation |
|
|
284
|
+
| `src/redact/burn.ts` | `burnRedactions()` — canvas-side destructive overlay |
|
|
285
|
+
| `src/compare/diff.ts` | `diffScreenshots()` — pixelmatch wrapper |
|
|
286
|
+
| `src/compare/aggregate.ts` | `aggregateDiffRegions()` — flood-fill bbox extraction |
|
|
287
|
+
| `src/tools/annotate-screenshot.ts` | `annot_annotate_screenshot` |
|
|
288
|
+
| `src/tools/annotate-url.ts` | `annot_annotate_url` |
|
|
289
|
+
| `src/tools/redact-screenshot.ts` | `annot_redact_screenshot` |
|
|
290
|
+
| `src/tools/redact-url.ts` | `annot_redact_url` |
|
|
291
|
+
| `src/tools/compare-screenshots.ts` | `annot_compare_screenshots` |
|
|
292
|
+
|
|
293
|
+
## Runtime dependencies
|
|
294
|
+
|
|
295
|
+
- `@modelcontextprotocol/sdk` — MCP protocol implementation.
|
|
296
|
+
- `@ingcreators/annot-annotator` — Tier A headless rasteriser.
|
|
297
|
+
- `@napi-rs/canvas` — Node canvas for redact + diff (~80 MB
|
|
298
|
+
native binding, prebuilt binaries per OS).
|
|
299
|
+
- `playwright-core` — Chromium driver for `_url` tools. The
|
|
300
|
+
Chromium binary is a separate `npx playwright install chromium`
|
|
301
|
+
step the user runs once.
|
|
302
|
+
- `pixelmatch` — pixel-perfect diff for `annot_compare_screenshots`.
|
|
303
|
+
|
|
304
|
+
## Friendly errors
|
|
305
|
+
|
|
306
|
+
The `_url` tools detect missing Chromium and return a structured
|
|
307
|
+
error pointing to the install command:
|
|
308
|
+
|
|
309
|
+
```
|
|
310
|
+
ChromiumUnavailableError: Failed to launch Chromium.
|
|
311
|
+
Run `npx playwright install chromium` to download the runtime,
|
|
312
|
+
then retry.
|
|
313
|
+
```
|
|
314
|
+
|
|
315
|
+
Locator failures surface as `LocatorResolutionError` with the
|
|
316
|
+
offending selector embedded:
|
|
317
|
+
|
|
318
|
+
```
|
|
319
|
+
LocatorResolutionError: Locator "button:has-text('Submit')"
|
|
320
|
+
resolved to no visible element. Check the selector matches at
|
|
321
|
+
least one element and the element is inside the captured
|
|
322
|
+
viewport.
|
|
323
|
+
```
|
|
324
|
+
|
|
325
|
+
The agent sees these as MCP tool errors and can correct + retry.
|
|
326
|
+
|
|
327
|
+
## See also
|
|
328
|
+
|
|
329
|
+
- [`docs/ai-agents.md`](../../docs/ai-agents.md) — short intro
|
|
330
|
+
guide + "which doc do I want?" map; start here if you're new
|
|
331
|
+
to the MCP integration.
|
|
332
|
+
- [`docs/plans/agent-mcp-integration.md`](../../docs/plans/agent-mcp-integration.md)
|
|
333
|
+
— full design + phase ledger.
|
|
334
|
+
- [`@ingcreators/annot-annotator`](../annotator/README.md) — the
|
|
335
|
+
underlying Tier A headless renderer.
|
|
336
|
+
- [`@ingcreators/annot-playwright`](../playwright/README.md) — the
|
|
337
|
+
test-engineer-facing Playwright fixture (sibling consumer of
|
|
338
|
+
the annotator).
|
|
339
|
+
- Model Context Protocol spec: https://modelcontextprotocol.io/
|
|
340
|
+
- Upstream `@playwright/mcp`: https://github.com/microsoft/playwright-mcp
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// `annot-mcp` CLI shim. Boots the MCP server over stdio so an MCP
|
|
4
|
+
// client (Claude Desktop, Claude Code, Cursor, …) can spawn this
|
|
5
|
+
// binary and pipe JSON-RPC over stdin / stdout.
|
|
6
|
+
//
|
|
7
|
+
// Configure in `~/.config/Claude/claude_desktop_config.json` (or
|
|
8
|
+
// the equivalent for other clients) as:
|
|
9
|
+
//
|
|
10
|
+
// {
|
|
11
|
+
// "mcpServers": {
|
|
12
|
+
// "annot": { "command": "npx", "args": ["@ingcreators/annot-mcp"] }
|
|
13
|
+
// }
|
|
14
|
+
// }
|
|
15
|
+
//
|
|
16
|
+
// The actual server lives in `../dist/index.js` after `vite build`;
|
|
17
|
+
// during workspace development run `pnpm --filter
|
|
18
|
+
// @ingcreators/annot-mcp build` before invoking the bin.
|
|
19
|
+
|
|
20
|
+
import { dirname, resolve } from "node:path";
|
|
21
|
+
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
22
|
+
|
|
23
|
+
const here = dirname(fileURLToPath(import.meta.url));
|
|
24
|
+
const entry = resolve(here, "..", "dist", "index.js");
|
|
25
|
+
|
|
26
|
+
// Windows dynamic import requires a `file://` URL; passing the raw
|
|
27
|
+
// absolute path triggers `ERR_UNSUPPORTED_ESM_URL_SCHEME` ("Only
|
|
28
|
+
// URLs with a scheme in: file, data, and node are supported"). Use
|
|
29
|
+
// `pathToFileURL` so the same code works on Linux / macOS / Windows.
|
|
30
|
+
const mod = await import(pathToFileURL(entry).href);
|
|
31
|
+
await mod.runStdioServer();
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { BrowserPool } from './pool.js';
|
|
2
|
+
export interface ViewportOptions {
|
|
3
|
+
width: number;
|
|
4
|
+
height: number;
|
|
5
|
+
deviceScaleFactor?: number;
|
|
6
|
+
}
|
|
7
|
+
export interface CapturePageOptions {
|
|
8
|
+
url: string;
|
|
9
|
+
viewport?: ViewportOptions;
|
|
10
|
+
fullPage?: boolean;
|
|
11
|
+
waitFor?: "load" | "domcontentloaded" | "networkidle";
|
|
12
|
+
}
|
|
13
|
+
export interface PageHandle {
|
|
14
|
+
/** Page-shaped object (`playwright-core`'s `Page`). */
|
|
15
|
+
page: {
|
|
16
|
+
locator(selector: string): {
|
|
17
|
+
boundingBox(): Promise<{
|
|
18
|
+
x: number;
|
|
19
|
+
y: number;
|
|
20
|
+
width: number;
|
|
21
|
+
height: number;
|
|
22
|
+
} | null>;
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
/** Close the page and release the browser borrow. Idempotent. */
|
|
26
|
+
close(): Promise<void>;
|
|
27
|
+
}
|
|
28
|
+
export interface CapturePageResult {
|
|
29
|
+
pngBytes: Uint8Array;
|
|
30
|
+
handle: PageHandle;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Acquire a browser, open a new context + page, navigate to the
|
|
34
|
+
* given URL, take a screenshot, and return the bytes + a page
|
|
35
|
+
* handle for follow-up locator resolution.
|
|
36
|
+
*
|
|
37
|
+
* On any error after browser acquisition, the page + context are
|
|
38
|
+
* closed and the browser is released before the error propagates.
|
|
39
|
+
*/
|
|
40
|
+
export declare function capturePage(pool: BrowserPool, options: CapturePageOptions): Promise<CapturePageResult>;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
export interface BrowserLike {
|
|
2
|
+
/** Close the browser. Mirrors `playwright-core` `Browser.close`. */
|
|
3
|
+
close(): Promise<void>;
|
|
4
|
+
}
|
|
5
|
+
export interface BrowserLauncher {
|
|
6
|
+
/** Launch a headless browser instance. */
|
|
7
|
+
launch(): Promise<BrowserLike>;
|
|
8
|
+
}
|
|
9
|
+
export interface BrowserPoolOptions {
|
|
10
|
+
/** Milliseconds the pool will keep a browser alive after the last
|
|
11
|
+
* release before closing it. Default 30000. */
|
|
12
|
+
idleTimeoutMs?: number;
|
|
13
|
+
}
|
|
14
|
+
export declare class BrowserPool {
|
|
15
|
+
#private;
|
|
16
|
+
constructor(launcher: BrowserLauncher, options?: BrowserPoolOptions);
|
|
17
|
+
/**
|
|
18
|
+
* Acquire a browser instance. The pool launches lazily on the
|
|
19
|
+
* first call. Subsequent acquires return the same shared
|
|
20
|
+
* instance until every borrow has been released and the idle
|
|
21
|
+
* timeout has elapsed.
|
|
22
|
+
*
|
|
23
|
+
* The caller MUST call {@link release} (typically in a `finally`)
|
|
24
|
+
* after they're done so the pool can track outstanding borrows
|
|
25
|
+
* accurately.
|
|
26
|
+
*/
|
|
27
|
+
acquire(): Promise<BrowserLike>;
|
|
28
|
+
/**
|
|
29
|
+
* Release a previously-acquired browser. Decrements the
|
|
30
|
+
* refcount; when it reaches zero an idle timer starts. A
|
|
31
|
+
* follow-up `acquire` within the idle window reuses the same
|
|
32
|
+
* instance; otherwise the timer fires and the browser closes.
|
|
33
|
+
*/
|
|
34
|
+
release(): void;
|
|
35
|
+
/**
|
|
36
|
+
* Close the pooled browser immediately, regardless of refcount.
|
|
37
|
+
* Intended for explicit teardown (e.g. SIGINT / SIGTERM
|
|
38
|
+
* handlers); regular flows should rely on the idle timer.
|
|
39
|
+
*/
|
|
40
|
+
shutdown(): Promise<void>;
|
|
41
|
+
/** Refcount of outstanding borrows. Exposed for tests / metrics. */
|
|
42
|
+
get activeBorrows(): number;
|
|
43
|
+
/** Whether a browser is currently launched. Exposed for tests. */
|
|
44
|
+
get isLaunched(): boolean;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Construct a {@link BrowserPool} backed by `playwright-core`'s
|
|
48
|
+
* Chromium launcher. Uses dynamic import so consumers who never
|
|
49
|
+
* touch `_url` tools don't pay the playwright-core load cost on
|
|
50
|
+
* startup AND so we can surface a friendly error when the
|
|
51
|
+
* package is missing (e.g. accidentally stripped from
|
|
52
|
+
* dependencies).
|
|
53
|
+
*/
|
|
54
|
+
export declare function createChromiumPool(options?: BrowserPoolOptions): BrowserPool;
|
|
55
|
+
export declare class ChromiumUnavailableError extends Error {
|
|
56
|
+
readonly cause: unknown;
|
|
57
|
+
constructor(message: string, cause?: unknown);
|
|
58
|
+
}
|