mcp-scraper 0.2.8 → 0.2.10

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.
Files changed (54) hide show
  1. package/README.md +40 -3
  2. package/dist/bin/api-server.cjs +2073 -506
  3. package/dist/bin/api-server.cjs.map +1 -1
  4. package/dist/bin/api-server.js +3 -3
  5. package/dist/bin/browser-agent-stdio-server.cjs +1 -1
  6. package/dist/bin/browser-agent-stdio-server.cjs.map +1 -1
  7. package/dist/bin/browser-agent-stdio-server.js +2 -2
  8. package/dist/bin/mcp-scraper-cli.cjs +1276 -0
  9. package/dist/bin/mcp-scraper-cli.cjs.map +1 -0
  10. package/dist/bin/mcp-scraper-cli.d.cts +1 -0
  11. package/dist/bin/mcp-scraper-cli.d.ts +1 -0
  12. package/dist/bin/mcp-scraper-cli.js +476 -0
  13. package/dist/bin/mcp-scraper-cli.js.map +1 -0
  14. package/dist/bin/mcp-scraper-combined-stdio-server.cjs +3 -3
  15. package/dist/bin/mcp-scraper-combined-stdio-server.cjs.map +1 -1
  16. package/dist/bin/mcp-scraper-combined-stdio-server.js +3 -3
  17. package/dist/bin/mcp-scraper-install.cjs +4 -1
  18. package/dist/bin/mcp-scraper-install.cjs.map +1 -1
  19. package/dist/bin/mcp-scraper-install.js +4 -1
  20. package/dist/bin/mcp-scraper-install.js.map +1 -1
  21. package/dist/bin/mcp-stdio-server.cjs +3 -3
  22. package/dist/bin/mcp-stdio-server.cjs.map +1 -1
  23. package/dist/bin/mcp-stdio-server.js +2 -2
  24. package/dist/{chunk-5HMOPP76.js → chunk-2OHP6WWF.js} +2 -2
  25. package/dist/{chunk-D4CJBZBY.js → chunk-7GCCOT3M.js} +372 -1
  26. package/dist/chunk-7GCCOT3M.js.map +1 -0
  27. package/dist/chunk-L6IS63WS.js +869 -0
  28. package/dist/chunk-L6IS63WS.js.map +1 -0
  29. package/dist/{chunk-IQOCZGJJ.js → chunk-ROS67BNV.js} +5 -5
  30. package/dist/chunk-WKWFO45O.js +7 -0
  31. package/dist/chunk-WKWFO45O.js.map +1 -0
  32. package/dist/{chunk-6NEXSNSA.js → chunk-YAKKRQRH.js} +4 -4
  33. package/dist/chunk-YAKKRQRH.js.map +1 -0
  34. package/dist/{db-YWCNHBLH.js → db-BVHYI57K.js} +38 -2
  35. package/dist/{server-BTTDFPSQ.js → server-USOIPC2I.js} +585 -266
  36. package/dist/server-USOIPC2I.js.map +1 -0
  37. package/dist/{worker-5O44YBF4.js → worker-TDJQ6TH3.js} +8 -8
  38. package/docs/specs/agent-ready-seo-packet-spec.md +237 -0
  39. package/docs/specs/cli-agent-wiring-spec.md +203 -0
  40. package/docs/specs/deferred-work-spec.md +12 -0
  41. package/docs/specs/local-competitive-audit-spec.md +312 -0
  42. package/docs/specs/scheduled-workflows-api-spec.md +304 -0
  43. package/docs/specs/seo-cli-growth-roadmap-spec.md +179 -0
  44. package/docs/specs/seo-workflow-runner-and-reports-spec.md +241 -0
  45. package/package.json +20 -19
  46. package/dist/chunk-6NEXSNSA.js.map +0 -1
  47. package/dist/chunk-D4CJBZBY.js.map +0 -1
  48. package/dist/chunk-I26QN7WQ.js +0 -7
  49. package/dist/chunk-I26QN7WQ.js.map +0 -1
  50. package/dist/server-BTTDFPSQ.js.map +0 -1
  51. /package/dist/{chunk-5HMOPP76.js.map → chunk-2OHP6WWF.js.map} +0 -0
  52. /package/dist/{chunk-IQOCZGJJ.js.map → chunk-ROS67BNV.js.map} +0 -0
  53. /package/dist/{db-YWCNHBLH.js.map → db-BVHYI57K.js.map} +0 -0
  54. /package/dist/{worker-5O44YBF4.js.map → worker-TDJQ6TH3.js.map} +0 -0
@@ -4,12 +4,7 @@ import {
4
4
  createHarvestAttemptRecorder,
5
5
  harvestProblemResponse,
6
6
  serializeHarvestProblem
7
- } from "./chunk-IQOCZGJJ.js";
8
- import {
9
- browserServiceApiKey,
10
- harvest
11
- } from "./chunk-CQTAKXBN.js";
12
- import "./chunk-M2S27J6Z.js";
7
+ } from "./chunk-ROS67BNV.js";
13
8
  import {
14
9
  claimPendingJob,
15
10
  completeJob,
@@ -17,7 +12,12 @@ import {
17
12
  debitMc,
18
13
  failJob,
19
14
  listHarvestAttempts
20
- } from "./chunk-D4CJBZBY.js";
15
+ } from "./chunk-7GCCOT3M.js";
16
+ import {
17
+ browserServiceApiKey,
18
+ harvest
19
+ } from "./chunk-CQTAKXBN.js";
20
+ import "./chunk-M2S27J6Z.js";
21
21
 
22
22
  // src/api/webhook.ts
23
23
  async function deliverWebhook(url, payload, retries = 3) {
@@ -122,4 +122,4 @@ export {
122
122
  startWorker,
123
123
  tickOnce
124
124
  };
125
- //# sourceMappingURL=worker-5O44YBF4.js.map
125
+ //# sourceMappingURL=worker-TDJQ6TH3.js.map
@@ -0,0 +1,237 @@
1
+ # Agent-Ready SEO Packet — Implementation Spec
2
+
3
+ `agent-packet` turns live SEO evidence into a folder an AI agent can use without re-discovering context. It is both a CLI workflow and a product wedge: MCP Scraper becomes the evidence layer for Codex, Claude, Cursor, and other agents.
4
+
5
+ ## User promise
6
+
7
+ ```bash
8
+ mcp-scraper-cli workflow run agent-packet \
9
+ --keyword "roof repair Denver" \
10
+ --domain example.com \
11
+ --location "Denver, CO"
12
+ ```
13
+
14
+ Output:
15
+
16
+ ```text
17
+ agent-packet/
18
+ report.html
19
+ brief.md
20
+ evidence.json
21
+ sources.csv
22
+ competitors.csv
23
+ tasks.md
24
+ agent-instructions.md
25
+ manifest.json
26
+ ```
27
+
28
+ The packet should answer:
29
+
30
+ - What does the live search landscape show?
31
+ - Which sources and competitors matter?
32
+ - What questions do people ask?
33
+ - Is the target domain present?
34
+ - What should an AI agent do next?
35
+
36
+ ## Inputs
37
+
38
+ CLI flags:
39
+
40
+ ```bash
41
+ --keyword <query> # required
42
+ --domain <domain> # optional but recommended
43
+ --location <city,state> # optional
44
+ --max-questions <n> # default 40, max 150
45
+ --include-serp # default true
46
+ --include-paa # default true
47
+ --include-ai-overview # default true through search/PAA tools
48
+ --include-page-snapshots # default false, cap 5
49
+ --output-dir <path>
50
+ --return-partial # default true
51
+ ```
52
+
53
+ Structured input:
54
+
55
+ ```ts
56
+ interface AgentPacketInput {
57
+ keyword: string
58
+ domain?: string
59
+ location?: string
60
+ maxQuestions: number
61
+ includeSerp: boolean
62
+ includePaa: boolean
63
+ includeAiOverview: boolean
64
+ includePageSnapshots: boolean
65
+ pageSnapshotLimit: number
66
+ returnPartial: boolean
67
+ }
68
+ ```
69
+
70
+ ## Evidence collection plan
71
+
72
+ Use existing tools/API paths:
73
+
74
+ 1. `search_serp`
75
+ - Capture organic results, local pack when present, AI Overview detection/citations when available.
76
+ - Use `location` if provided.
77
+ 2. `harvest_paa`
78
+ - Capture PAA tree, answers, source titles/sites/cites, forums/videos when available.
79
+ - Use `maxQuestions`.
80
+ 3. Optional `extract_url`
81
+ - Extract target domain page if the target appears in SERP or user passes a URL later.
82
+ - Extract top source pages only when `includePageSnapshots` is true.
83
+
84
+ No server-side LLM is required. The workflow produces structured evidence and instructions; the calling agent can synthesize if desired.
85
+
86
+ ## Artifact formats
87
+
88
+ ### `evidence.json`
89
+
90
+ ```ts
91
+ interface AgentPacketEvidence {
92
+ input: AgentPacketInput
93
+ serp: {
94
+ status: 'ok' | 'failed' | 'skipped'
95
+ organic: Array<{ position: number; title: string; url: string; domain: string; snippet?: string | null }>
96
+ localPack: Array<{ position: number; name: string; rating?: string | null; reviewCount?: string | null; websiteUrl?: string | null }>
97
+ aiOverview: { detected: boolean; text?: string | null; citations: Array<{ title?: string; url?: string; domain?: string }> }
98
+ }
99
+ paa: {
100
+ status: 'ok' | 'failed' | 'skipped'
101
+ questions: Array<{ question: string; answer?: string | null; sourceTitle?: string | null; sourceSite?: string | null; sourceUrl?: string | null }>
102
+ }
103
+ target: {
104
+ domain: string | null
105
+ organicPositions: number[]
106
+ citedInAiOverview: boolean
107
+ citedInPaa: boolean
108
+ localPackPositions: number[]
109
+ }
110
+ competitors: Array<{
111
+ domain: string
112
+ organicPositions: number[]
113
+ paaMentions: number
114
+ aiOverviewCitations: number
115
+ sourceUrls: string[]
116
+ }>
117
+ warnings: string[]
118
+ }
119
+ ```
120
+
121
+ ### `sources.csv`
122
+
123
+ Columns:
124
+
125
+ ```text
126
+ surface,position,title,url,domain,question,answer_excerpt,is_target,is_competitor
127
+ ```
128
+
129
+ ### `competitors.csv`
130
+
131
+ Columns:
132
+
133
+ ```text
134
+ domain,organic_best_position,organic_count,paa_mentions,ai_overview_citations,source_url_count
135
+ ```
136
+
137
+ ### `brief.md`
138
+
139
+ Sections:
140
+
141
+ ```md
142
+ # SEO Evidence Brief
143
+
144
+ ## Search Intent
145
+ ## SERP Evidence
146
+ ## PAA Evidence
147
+ ## AI Overview Evidence
148
+ ## Target Presence
149
+ ## Competitor Sources
150
+ ## Content Gaps
151
+ ## Recommended Page Additions
152
+ ```
153
+
154
+ Content should be evidence-grounded. If the workflow cannot determine a gap deterministically, phrase it as an evidence prompt:
155
+
156
+ ```md
157
+ - Review these competitor source URLs before writing: ...
158
+ - The target was not found in the captured AI/PAA sources.
159
+ ```
160
+
161
+ ### `tasks.md`
162
+
163
+ Action checklist for an AI/code agent:
164
+
165
+ ```md
166
+ # Agent Tasks
167
+
168
+ - [ ] Read `evidence.json`.
169
+ - [ ] Compare the target domain against `competitors.csv`.
170
+ - [ ] Draft or update page sections using only evidence from `sources.csv`.
171
+ - [ ] Add citations/links where appropriate.
172
+ - [ ] Preserve claims that can be traced to an evidence row.
173
+ ```
174
+
175
+ ### `agent-instructions.md`
176
+
177
+ Stable instructions:
178
+
179
+ ```md
180
+ You are working from an MCP Scraper SEO evidence packet. Use `evidence.json` and CSV files as source of truth. Do not invent citations. If a recommendation is not supported by evidence, mark it as an assumption.
181
+ ```
182
+
183
+ ## HTML report
184
+
185
+ Report sections:
186
+
187
+ 1. Executive summary.
188
+ 2. Target visibility.
189
+ 3. SERP table.
190
+ 4. AI Overview citations.
191
+ 5. PAA source table.
192
+ 6. Competitor domains.
193
+ 7. Agent task list.
194
+ 8. Diagnostics and warnings.
195
+
196
+ ## Partial-result behavior
197
+
198
+ The workflow should return partial artifacts when one surface fails.
199
+
200
+ Examples:
201
+
202
+ - SERP succeeds, PAA CAPTCHA-exhausts: write report with SERP evidence and PAA warning.
203
+ - PAA succeeds, SERP fails: write PAA evidence and source table.
204
+ - Target domain omitted: skip target-presence calculations and focus on market evidence.
205
+
206
+ ## Files
207
+
208
+ New:
209
+
210
+ - `src/workflows/workflows/agent-packet.ts`
211
+ - `src/workflows/renderers/agent-packet-report.ts`
212
+ - `tests/unit/workflow-agent-packet.test.ts`
213
+ - `tests/fixtures/workflows/agent-packet/`
214
+
215
+ Modified:
216
+
217
+ - `src/workflows/registry.ts`
218
+ - `docs/specs/seo-workflow-runner-and-reports-spec.md` when implemented.
219
+
220
+ ## Tests
221
+
222
+ - Fixture SERP + PAA evidence produces stable `evidence.json`.
223
+ - Target domain matching handles `www.` and protocol differences.
224
+ - CSV escaping handles commas, quotes, and newlines.
225
+ - Partial SERP/PAA failures still write manifest and report.
226
+ - `agent-instructions.md` warns against unsupported citations.
227
+
228
+ ## Future MCP tool
229
+
230
+ After the CLI workflow is proven, consider an MCP tool:
231
+
232
+ ```text
233
+ seo_agent_packet
234
+ ```
235
+
236
+ Description should say it creates an evidence packet for downstream AI agents and returns local artifact paths. It should use `outputSchema` and structured content containing artifact paths, counts, and warnings.
237
+
@@ -0,0 +1,203 @@
1
+ # CLI Agent Wiring — Implementation Spec
2
+
3
+ Make MCP Scraper easy to wire into AI agents. This is the lowest-friction market-share feature: users should be able to install, verify, and prompt their agent correctly without reading a long README.
4
+
5
+ ## Goals
6
+
7
+ - Generate correct MCP configs for common AI-agent hosts.
8
+ - Verify local setup with a single `doctor` command.
9
+ - Provide copyable prompts for high-value workflows.
10
+ - Keep stdio MCP servers protocol-safe and silent.
11
+ - Make updates obvious: users on `mcp-scraper@latest` still need to restart their MCP client.
12
+
13
+ ## New binary
14
+
15
+ Add a human-facing CLI binary:
16
+
17
+ ```json
18
+ {
19
+ "bin": {
20
+ "mcp-scraper-cli": "dist/bin/mcp-scraper-cli.js"
21
+ }
22
+ }
23
+ ```
24
+
25
+ Do not repurpose `mcp-scraper`; it is already a stdio MCP server. Do not print terminal UI from any stdio MCP server.
26
+
27
+ ## Command surface
28
+
29
+ ```bash
30
+ mcp-scraper-cli doctor
31
+ mcp-scraper-cli agent install codex
32
+ mcp-scraper-cli agent install claude
33
+ mcp-scraper-cli agent install claude-desktop
34
+ mcp-scraper-cli agent prompt list
35
+ mcp-scraper-cli agent prompt agent-packet
36
+ mcp-scraper-cli agent prompt local-competitive-audit
37
+ mcp-scraper-cli agent config codex --api-key sk_live_...
38
+ mcp-scraper-cli agent config claude --api-key sk_live_...
39
+ ```
40
+
41
+ Flags:
42
+
43
+ ```bash
44
+ --api-key <key> # optional; if omitted, use env placeholder
45
+ --output <path> # write generated config/prompt to a file
46
+ --combined # default true; uses mcp-scraper-combined
47
+ --browser-tools # default true in combined mode
48
+ --no-color
49
+ --json # machine-readable output for scripts
50
+ ```
51
+
52
+ ## `doctor`
53
+
54
+ Checks:
55
+
56
+ | Check | Pass condition | Fix text |
57
+ |---|---|---|
58
+ | Node version | `>=20` | Install Node 20+ |
59
+ | npm package | `npm view mcp-scraper version` succeeds | Check npm/network |
60
+ | local CLI version | package version available from `PACKAGE_VERSION` | Update/reinstall |
61
+ | API key | `MCP_SCRAPER_API_KEY` set or key file exists | Set env or config |
62
+ | hosted API | `GET /me` with key succeeds | Verify key/account |
63
+ | output dir | writable `MCP_SCRAPER_OUTPUT_DIR` or default downloads dir | Create/fix permissions |
64
+ | MCP command | generated `npx -y -p mcp-scraper@latest mcp-scraper-combined` | Restart MCP client |
65
+ | browser service readiness | only check if browser tools are requested | Configure API key |
66
+
67
+ Output shape for `--json`:
68
+
69
+ ```ts
70
+ interface DoctorOutput {
71
+ ok: boolean
72
+ version: string
73
+ npmLatest: string | null
74
+ checks: Array<{
75
+ id: string
76
+ label: string
77
+ status: 'pass' | 'warn' | 'fail' | 'skip'
78
+ detail: string
79
+ fix?: string
80
+ }>
81
+ recommendedConfig: {
82
+ command: 'npx'
83
+ args: string[]
84
+ env: Record<string, string>
85
+ }
86
+ }
87
+ ```
88
+
89
+ ## Agent install generators
90
+
91
+ ### Codex
92
+
93
+ Print TOML:
94
+
95
+ ```toml
96
+ [mcp_servers.mcp-scraper]
97
+ command = "npx"
98
+ args = ["-y", "-p", "mcp-scraper@latest", "mcp-scraper-combined"]
99
+ env = { MCP_SCRAPER_API_KEY = "sk_live_your_key" }
100
+ ```
101
+
102
+ Also print the restart requirement:
103
+
104
+ ```text
105
+ Restart Codex so the MCP client starts a fresh npx process.
106
+ ```
107
+
108
+ ### Claude Code
109
+
110
+ Print command:
111
+
112
+ ```bash
113
+ claude mcp add mcp-scraper --scope user \
114
+ --env MCP_SCRAPER_API_KEY=sk_live_your_key \
115
+ -- npx -y -p mcp-scraper@latest mcp-scraper-combined
116
+ ```
117
+
118
+ ### Claude Desktop
119
+
120
+ Print JSON:
121
+
122
+ ```json
123
+ {
124
+ "mcpServers": {
125
+ "mcp-scraper": {
126
+ "command": "npx",
127
+ "args": ["-y", "-p", "mcp-scraper@latest", "mcp-scraper-combined"],
128
+ "env": {
129
+ "MCP_SCRAPER_API_KEY": "sk_live_your_key"
130
+ }
131
+ }
132
+ }
133
+ }
134
+ ```
135
+
136
+ Also point to the MCPB:
137
+
138
+ ```text
139
+ Desktop Extension: https://mcpscraper.dev/downloads/mcp-scraper.mcpb
140
+ ```
141
+
142
+ ## Prompt library
143
+
144
+ Store prompt templates in:
145
+
146
+ ```text
147
+ src/cli/prompts/
148
+ agent-packet.md
149
+ local-competitive-audit.md
150
+ directory-workflow.md
151
+ ai-citation-monitor.md
152
+ serp-brief.md
153
+ ```
154
+
155
+ Command:
156
+
157
+ ```bash
158
+ mcp-scraper-cli agent prompt agent-packet
159
+ ```
160
+
161
+ Example `agent-packet.md`:
162
+
163
+ ```md
164
+ Use MCP Scraper as the evidence layer. First call search/PAA tools for the keyword and target domain. Save all source URLs and cite every recommendation to a live evidence item. Then produce: brief.md, tasks.md, and a concise HTML-ready summary.
165
+ ```
166
+
167
+ Prompts should name tool intent, not implementation vendors.
168
+
169
+ ## Files
170
+
171
+ New:
172
+
173
+ - `bin/mcp-scraper-cli.ts`
174
+ - `src/cli/agent-config.ts`
175
+ - `src/cli/doctor.ts`
176
+ - `src/cli/prompts.ts`
177
+ - `src/cli/prompts/*.md`
178
+ - `tests/unit/cli-agent-config.test.ts`
179
+ - `tests/unit/cli-doctor.test.ts`
180
+ - `tests/unit/cli-prompts.test.ts`
181
+
182
+ Modified:
183
+
184
+ - `package.json` bin and tsup entries.
185
+ - `README.md` install section.
186
+ - `src/install-terminal.ts` to mention `mcp-scraper-cli doctor`.
187
+
188
+ ## Tests
189
+
190
+ - Snapshot generated Codex TOML, Claude command, Claude Desktop JSON.
191
+ - `doctor --json` with mocked checks returns stable JSON.
192
+ - Prompt listing and prompt rendering works.
193
+ - No generated prompt or CLI text includes hidden vendor names.
194
+ - `mcp-scraper-cli --help` exits 0 and does not require an API key.
195
+
196
+ ## Release notes
197
+
198
+ Installer message candidate:
199
+
200
+ ```text
201
+ Newest: agent install helpers, setup doctor, and workflow prompts for Codex and Claude.
202
+ ```
203
+
@@ -72,3 +72,15 @@ When a decision lands, the implementation is:
72
72
  ## 7. API Forge
73
73
 
74
74
  Specified separately in `docs/specs/api-forge-spec.md`. Recommended to schedule after §1 and §2 (ops hygiene first), before §3/§4 (it produces revenue surface; progress/OAuth polish can follow demand).
75
+
76
+ ## 8. SEO CLI growth workflows
77
+
78
+ Specified separately in `docs/specs/seo-cli-growth-roadmap-spec.md`, with buildable sub-specs for agent wiring, workflow reports, agent-ready SEO packets, local competitive audits, and scheduled workflow APIs:
79
+
80
+ - `docs/specs/cli-agent-wiring-spec.md`
81
+ - `docs/specs/seo-workflow-runner-and-reports-spec.md`
82
+ - `docs/specs/agent-ready-seo-packet-spec.md`
83
+ - `docs/specs/local-competitive-audit-spec.md`
84
+ - `docs/specs/scheduled-workflows-api-spec.md`
85
+
86
+ Recommended priority: ship agent wiring and local workflow reports first, then the agent packet and local competitive audit workflows, then hosted schedules/API once report artifacts are durable.