Skip to content

Commit f083f51

Browse files
author
Ondrej Machala
committed
feat: add MCP server for AI agent integration
- Add heroshot-mcp binary with tools: sync, add, list, snippet, remove - Auto-derive JSON schemas from Zod using z.toJSONSchema() - Add AI agents documentation page with platform configs - Add robot icon and feature card to landing page
1 parent 7fce156 commit f083f51

File tree

21 files changed

+1437
-13
lines changed

21 files changed

+1437
-13
lines changed

docs/.vitepress/config.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,10 @@ export default defineConfig({
163163
},
164164
{
165165
text: 'Guides',
166-
items: [{ text: 'Automated Updates', link: '/docs/guide/automated-updates' }],
166+
items: [
167+
{ text: 'Automated Updates', link: '/docs/guide/automated-updates' },
168+
{ text: 'AI Agents', link: '/docs/ai-agents' },
169+
],
167170
},
168171
{
169172
text: 'Integrations',

docs/docs/ai-agents.md

Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
---
2+
description: Use Heroshot with AI coding assistants like Claude Code, Cursor, and VS Code Copilot through MCP (Model Context Protocol).
3+
---
4+
5+
# AI Agents
6+
7+
Heroshot includes an MCP (Model Context Protocol) server that lets AI coding assistants manage your screenshots directly. Ask your AI to "add a screenshot of the pricing page" and it handles the config, capture, and code snippet generation.
8+
9+
## What It Does
10+
11+
The MCP server exposes these tools to AI agents:
12+
13+
| Tool | Description |
14+
| ------------------ | ----------------------------------------- |
15+
| `heroshot_sync` | Capture all screenshots defined in config |
16+
| `heroshot_add` | Add a new screenshot definition |
17+
| `heroshot_list` | List all configured screenshots |
18+
| `heroshot_snippet` | Generate HTML/Markdown code snippets |
19+
| `heroshot_remove` | Remove a screenshot by ID |
20+
21+
## Claude Code
22+
23+
Add to your `~/.claude/claude_code_config.json`:
24+
25+
```json
26+
{
27+
"mcpServers": {
28+
"heroshot": {
29+
"command": "npx",
30+
"args": ["-y", "heroshot-mcp"]
31+
}
32+
}
33+
}
34+
```
35+
36+
Or with a local installation:
37+
38+
```json
39+
{
40+
"mcpServers": {
41+
"heroshot": {
42+
"command": "node",
43+
"args": ["/path/to/node_modules/heroshot/dist/mcp/index.js"]
44+
}
45+
}
46+
}
47+
```
48+
49+
Restart Claude Code after editing.
50+
51+
## Cursor
52+
53+
Add to your Cursor MCP settings (Settings > MCP Servers > Add Server):
54+
55+
```json
56+
{
57+
"heroshot": {
58+
"command": "npx",
59+
"args": ["-y", "heroshot-mcp"]
60+
}
61+
}
62+
```
63+
64+
Or add directly to `.cursor/mcp.json` in your project:
65+
66+
```json
67+
{
68+
"mcpServers": {
69+
"heroshot": {
70+
"command": "npx",
71+
"args": ["-y", "heroshot-mcp"]
72+
}
73+
}
74+
}
75+
```
76+
77+
## VS Code with Copilot
78+
79+
For VS Code with GitHub Copilot, add to your `.vscode/mcp.json`:
80+
81+
```json
82+
{
83+
"servers": {
84+
"heroshot": {
85+
"command": "npx",
86+
"args": ["-y", "heroshot-mcp"]
87+
}
88+
}
89+
}
90+
```
91+
92+
## Windsurf
93+
94+
Add to your Windsurf MCP configuration:
95+
96+
```json
97+
{
98+
"mcpServers": {
99+
"heroshot": {
100+
"command": "npx",
101+
"args": ["-y", "heroshot-mcp"]
102+
}
103+
}
104+
}
105+
```
106+
107+
## Example Prompts
108+
109+
Once configured, try these prompts with your AI assistant:
110+
111+
- "List all heroshot screenshots in this project"
112+
- "Add a screenshot of the homepage hero section"
113+
- "Generate HTML snippets for all screenshots"
114+
- "Sync all heroshot screenshots"
115+
- "Remove the old pricing screenshot"
116+
117+
The AI handles the MCP tool calls automatically.
118+
119+
## How It Works
120+
121+
The MCP server runs as a subprocess spawned by your AI assistant. It communicates over stdio using JSON-RPC. Each tool call maps to Heroshot's core functions:
122+
123+
- `heroshot_sync` calls the same capture logic as `npx heroshot`
124+
- `heroshot_add` writes to `.heroshot/config.json`
125+
- `heroshot_list` reads the config and returns screenshot metadata
126+
- `heroshot_snippet` generates framework-specific code
127+
- `heroshot_remove` updates the config to remove an entry
128+
129+
No additional authentication needed - the server uses your existing Heroshot config and session.
130+
131+
## Input Schemas
132+
133+
All tool inputs are validated with Zod schemas. The MCP server auto-derives JSON Schema at runtime using `z.toJSONSchema()`, so schema definitions stay in sync with Heroshot's core types.
134+
135+
Example input for `heroshot_add`:
136+
137+
```json
138+
{
139+
"screenshot": {
140+
"name": "Dashboard Header",
141+
"url": "https://example.com/dashboard",
142+
"selector": "header.main",
143+
"viewports": ["desktop", "mobile"]
144+
}
145+
}
146+
```
147+
148+
See [Configuration Reference](/docs/config) for all screenshot options.

docs/index.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,12 @@ features:
5959
details: Encrypted sessions let you log in once and capture protected pages headlessly.
6060
link: /docs/getting-started#sites-that-need-login
6161
linkText: Session handling
62+
- icon:
63+
src: /icons/robot.svg
64+
title: AI Agent Ready
65+
details: MCP server lets Claude Code, Cursor, and Copilot manage screenshots directly. Just ask.
66+
link: /docs/ai-agents
67+
linkText: Configure MCP
6268
- icon:
6369
src: /icons/sliders.svg
6470
title: Visual Editor

docs/public/icons/robot.svg

Lines changed: 7 additions & 0 deletions
Loading

package.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,18 @@
66
"author": "Ondrej Machala",
77
"license": "MIT",
88
"bin": {
9-
"heroshot": "dist/cli.js"
9+
"heroshot": "dist/cli/cli.js",
10+
"heroshot-mcp": "dist/mcp/index.js"
1011
},
1112
"exports": {
1213
".": {
1314
"types": "./dist/index.d.ts",
1415
"import": "./dist/index.js"
1516
},
17+
"./mcp": {
18+
"types": "./dist/mcp/index.d.ts",
19+
"import": "./dist/mcp/index.js"
20+
},
1621
"./vue": {
1722
"types": "./dist/integrations/vue/index.d.ts",
1823
"import": "./dist/integrations/vue/index.js"
@@ -151,6 +156,7 @@
151156
},
152157
"dependencies": {
153158
"@clack/prompts": "^0.11.0",
159+
"@modelcontextprotocol/sdk": "^1.12.1",
154160
"commander": "^12.1.0",
155161
"p-limit": "^7.2.0",
156162
"playwright": "^1.49.0",

0 commit comments

Comments
 (0)