@mambalabsdev/mcp-substack-scraper 0.0.0-stage → 1.0.1
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/LICENSE +21 -0
- package/README.md +121 -2
- package/SECURITY.md +31 -0
- package/build/index.js +199 -0
- package/package.json +48 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Mamba Labs
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,122 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Substack Scraper MCP Server
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://glama.ai/mcp/servers/mambalabsdev/mcp-substack-scraper) [](https://registry.modelcontextprotocol.io/v0/servers?search=com.mambabuilt/mcp-substack-scraper&limit=1) [](https://www.npmjs.com/package/@mambalabsdev/mcp-substack-scraper) [](https://www.npmjs.com/package/@mambalabsdev/mcp-substack-scraper) [](https://github.com/mambalabsdev/mcp-substack-scraper/blob/main/LICENSE) [](https://mcpservers.org/servers/mambalabsdev/mcp-substack-scraper)
|
|
4
|
+
|
|
5
|
+
<a href="https://mcprush.com/to/mcp-substack-scraper?ref=badge"><img width="380" height="200" src="https://mcprush.com/badge/mcp-substack-scraper/card.svg" alt="Substack Scraper MCP server" /></a>
|
|
6
|
+
|
|
7
|
+
An MCP server for the Mamba Labs [Substack Newsletter and Posts Scraper](https://apify.com/mambalabs/substack-scraper) actor on Apify. Give it Substack publications or keywords. It returns publication profiles and posts as flat rows.
|
|
8
|
+
|
|
9
|
+
## What's Inside
|
|
10
|
+
|
|
11
|
+
- [What it does](#what-it-does)
|
|
12
|
+
- [Quick start](#quick-start)
|
|
13
|
+
- [Prerequisites](#prerequisites)
|
|
14
|
+
- [Example prompts](#example-prompts)
|
|
15
|
+
- [Tool](#tool)
|
|
16
|
+
- [Inputs](#inputs)
|
|
17
|
+
- [Pricing](#pricing)
|
|
18
|
+
- [Your keys](#your-keys)
|
|
19
|
+
- [Full actor documentation](#full-actor-documentation)
|
|
20
|
+
- [License](#license)
|
|
21
|
+
|
|
22
|
+
## What it does
|
|
23
|
+
|
|
24
|
+
- **Publications**: name, author, tagline, subscriber count as Substack shows it (`subscriber_count_text`, and `subscriber_count_min` as a number), subscriber tier text, and monthly, yearly, and founding plan prices.
|
|
25
|
+
- **Posts**: title, URL, date, `audience` (free, paid, or founding), likes, comments, restacks, word count, bylines, and tags. Optional post text with `include_body`.
|
|
26
|
+
- **Search**: keyword search across Substack posts, returned as posts or as the publications behind them.
|
|
27
|
+
|
|
28
|
+
All of the work runs on Apify. This package is a thin client that starts the actor run, waits for it, and hands back the dataset rows.
|
|
29
|
+
|
|
30
|
+
## Quick start
|
|
31
|
+
|
|
32
|
+
You need Node.js 18 or newer and an Apify account with an API token.
|
|
33
|
+
|
|
34
|
+
Add this to your Claude Desktop config (`claude_desktop_config.json`), Cursor, or any MCP client:
|
|
35
|
+
|
|
36
|
+
```json
|
|
37
|
+
{
|
|
38
|
+
"mcpServers": {
|
|
39
|
+
"mamba-substack-scraper": {
|
|
40
|
+
"command": "npx",
|
|
41
|
+
"args": [
|
|
42
|
+
"-y",
|
|
43
|
+
"@mambalabsdev/mcp-substack-scraper"
|
|
44
|
+
],
|
|
45
|
+
"env": {
|
|
46
|
+
"APIFY_TOKEN": "your-apify-token"
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Restart the client. The `scrape_substack` tool appears.
|
|
54
|
+
|
|
55
|
+
## Prerequisites
|
|
56
|
+
|
|
57
|
+
- Node.js 18 or newer.
|
|
58
|
+
- An Apify API token from [console.apify.com/account/integrations](https://console.apify.com/account/integrations), set as `APIFY_TOKEN`. The server lists its tool without a token; a call needs one.
|
|
59
|
+
|
|
60
|
+
## Example prompts
|
|
61
|
+
|
|
62
|
+
- "How many subscribers does Lenny's Newsletter have, and what does a paid plan cost?"
|
|
63
|
+
- "Find Substack newsletters that write about cold email and list their subscriber counts."
|
|
64
|
+
- "What did notboring.co publish in the last 30 days, and which posts were paid only?"
|
|
65
|
+
|
|
66
|
+
## Tool
|
|
67
|
+
|
|
68
|
+
`scrape_substack`. One tool. Example arguments:
|
|
69
|
+
|
|
70
|
+
```json
|
|
71
|
+
{
|
|
72
|
+
"publications": [
|
|
73
|
+
"lenny.substack.com"
|
|
74
|
+
],
|
|
75
|
+
"search_queries": [
|
|
76
|
+
"cold email"
|
|
77
|
+
],
|
|
78
|
+
"max_posts_per_publication": "5",
|
|
79
|
+
"max_search_results": "5"
|
|
80
|
+
}
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## Inputs
|
|
84
|
+
|
|
85
|
+
Every buyer facing input of the actor, unchanged. Omitted inputs take the actor's own defaults. Numbers and booleans are sent as strings.
|
|
86
|
+
|
|
87
|
+
| Input | Type | Description |
|
|
88
|
+
|---|---|---|
|
|
89
|
+
| `publications` | array | Substack publications, one per line, up to 100: a URL (https://www.lennysnewsletter.com), a domain (lenny.substack.com), a profile (substack.com/@lenny), or a bare Substack name (lenny). Each one returns a publication row and its newest posts |
|
|
90
|
+
| `search_queries` | array | Keywords to search across Substack posts, one per line, up to 20. Each query returns matching posts, or the publications behind them when Search output is publications |
|
|
91
|
+
| `search_output` | string | What a search query returns Default posts |
|
|
92
|
+
| `max_posts_per_publication` | string | Newest posts returned per publication, 0 to 1000. 0 returns only the publication row Default 20 |
|
|
93
|
+
| `max_search_results` | string | Rows returned per search query, 1 to 1000 Default 50 |
|
|
94
|
+
| `since_days` | string | Optional. Skip posts older than this many days. 0 or empty keeps every post up to the max Default 0 |
|
|
95
|
+
| `include_publication_row` | string | true to return one publication row per listed publication (name, author, subscribers, paid plan prices), billed as a publication row. false returns only post rows Default true |
|
|
96
|
+
| `include_body` | string | true to add the post text (up to 20,000 characters) to each post row of a listed publication. A paid post gives its free preview. Reads one more page per post; no extra charge Default false |
|
|
97
|
+
| `max_charge_usd` | string | Optional. The run stops before it would charge more than this |
|
|
98
|
+
| `proxy_mode` | string | How pages are fetched Default auto |
|
|
99
|
+
|
|
100
|
+
## Pricing
|
|
101
|
+
|
|
102
|
+
Pay per event on Apify, billed to your Apify account. Prices in USD.
|
|
103
|
+
|
|
104
|
+
| Event | Free plan | Bronze | Silver | Gold |
|
|
105
|
+
|---|---|---|---|---|
|
|
106
|
+
| `post-row`, one Substack post returned as a row: from a listed publication or from a search | $0.00115 | $0.001093 | $0.001035 | $0.000977 |
|
|
107
|
+
| `publication-row`, one Substack publication profile returned as a row: name, author, subscriber count as shown, and paid plan prices | $0.002 | $0.0019 | $0.0018 | $0.0017 |
|
|
108
|
+
| `apify-actor-start`, per run start | $0.001057 | $0.001057 | $0.001057 | $0.001057 |
|
|
109
|
+
|
|
110
|
+
`no_results` and `error` rows are free, including the one row a refused input returns.
|
|
111
|
+
|
|
112
|
+
## Your keys
|
|
113
|
+
|
|
114
|
+
The actor needs no key. It reads Substack's public pages and public JSON routes and holds no key of any kind. Proxy traffic adds nothing to your price: Mamba Labs pays the platform costs of the run.
|
|
115
|
+
|
|
116
|
+
## Full actor documentation
|
|
117
|
+
|
|
118
|
+
[apify.com/mambalabs/substack-scraper](https://apify.com/mambalabs/substack-scraper)
|
|
119
|
+
|
|
120
|
+
## License
|
|
121
|
+
|
|
122
|
+
MIT. See [LICENSE](LICENSE).
|
package/SECURITY.md
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# Security Policy
|
|
2
|
+
|
|
3
|
+
## Supported versions
|
|
4
|
+
|
|
5
|
+
The latest published `1.x` release of
|
|
6
|
+
`@mambalabsdev/mcp-substack-scraper` receives security updates.
|
|
7
|
+
|
|
8
|
+
| Version | Supported |
|
|
9
|
+
| ------- | ------------------ |
|
|
10
|
+
| 1.x | :white_check_mark: |
|
|
11
|
+
| < 1.0 | :x: |
|
|
12
|
+
|
|
13
|
+
## Reporting a vulnerability
|
|
14
|
+
|
|
15
|
+
Please do not open a public GitHub issue for security reports.
|
|
16
|
+
|
|
17
|
+
Email security reports to **labs@mambamindsetgrowth.com** with:
|
|
18
|
+
|
|
19
|
+
- a description of the issue and its impact,
|
|
20
|
+
- steps to reproduce, and
|
|
21
|
+
- any relevant logs or proof of concept.
|
|
22
|
+
|
|
23
|
+
We aim to acknowledge reports within 3 business days and to provide a remediation
|
|
24
|
+
timeline after triage. Coordinated disclosure is appreciated.
|
|
25
|
+
|
|
26
|
+
## Handling of credentials
|
|
27
|
+
|
|
28
|
+
This server reads an `APIFY_TOKEN` from the environment and uses it only to call
|
|
29
|
+
the Apify API on your behalf. The token is never logged or written to disk by this
|
|
30
|
+
package. Treat your `APIFY_TOKEN` as a secret and rotate it at
|
|
31
|
+
https://console.apify.com/account/integrations if you believe it has been exposed.
|
package/build/index.js
ADDED
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { readFileSync } from "node:fs";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
import { dirname, join } from "node:path";
|
|
5
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
6
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
7
|
+
import { z } from "zod";
|
|
8
|
+
const here = dirname(fileURLToPath(import.meta.url));
|
|
9
|
+
const pkg = JSON.parse(readFileSync(join(here, "..", "package.json"), "utf8"));
|
|
10
|
+
// Distinctive UA so Apify run meta.userAgent marks MCP-originated runs.
|
|
11
|
+
const USER_AGENT = `mambalabs-mcp ${pkg.name}@${pkg.version}`;
|
|
12
|
+
// Drop undefined values so optional inputs are not sent to the actor.
|
|
13
|
+
function compact(obj) {
|
|
14
|
+
const out = {};
|
|
15
|
+
for (const [k, v] of Object.entries(obj)) {
|
|
16
|
+
if (v !== undefined)
|
|
17
|
+
out[k] = v;
|
|
18
|
+
}
|
|
19
|
+
return out;
|
|
20
|
+
}
|
|
21
|
+
// How long the actor run itself is allowed to take, in seconds. The suite's
|
|
22
|
+
// slowest measured run on 2026-09-22 was 152 s on a seven platform search, so
|
|
23
|
+
// 1800 s is roughly twelve times that: headroom for a slow day without letting a
|
|
24
|
+
// hung run bill indefinitely.
|
|
25
|
+
const ACTOR_RUN_TIMEOUT_SECS = 1800;
|
|
26
|
+
// How long this wrapper waits for that run, in milliseconds. The actor's own
|
|
27
|
+
// timeout plus two minutes, so the run's own TIMED-OUT status is what the
|
|
28
|
+
// caller sees rather than the wrapper giving up first and reporting nothing.
|
|
29
|
+
const WRAPPER_WAIT_MS = (ACTOR_RUN_TIMEOUT_SECS + 120) * 1000;
|
|
30
|
+
const POLL_INTERVAL_MS = 3000;
|
|
31
|
+
const TERMINAL = new Set(["SUCCEEDED", "FAILED", "TIMED-OUT", "ABORTED", "ABORTING"]);
|
|
32
|
+
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
33
|
+
// Shared caller. actorPath is the actor's immutable Apify actor ID (a stable key
|
|
34
|
+
// that survives Store renames). The /v2/acts/{id} endpoint accepts it directly,
|
|
35
|
+
// so a Store rename never breaks these calls.
|
|
36
|
+
//
|
|
37
|
+
// START AND POLL, NOT RUN-SYNC. Apify's synchronous endpoints carry a platform
|
|
38
|
+
// ceiling of 300 seconds on the HTTP wait itself and answer 408 past it whatever
|
|
39
|
+
// the timeout parameter says, so a long run reads as a timeout even though the
|
|
40
|
+
// actor goes on to finish. Starting the run, polling it to a terminal status and
|
|
41
|
+
// then reading the dataset is the only way to wait as long as the actor needs.
|
|
42
|
+
//
|
|
43
|
+
// The token is read here rather than at module load, so the tool registers
|
|
44
|
+
// unconditionally and a server started without APIFY_TOKEN still advertises its
|
|
45
|
+
// capabilities instead of reporting none.
|
|
46
|
+
async function runActor(actorPath, actorLabel, input) {
|
|
47
|
+
const APIFY_TOKEN = process.env.APIFY_TOKEN;
|
|
48
|
+
if (!APIFY_TOKEN) {
|
|
49
|
+
return { isError: true, content: [{ type: "text", text: "APIFY_TOKEN is not set. Create a token at https://console.apify.com/account/integrations and set it as the APIFY_TOKEN environment variable." }] };
|
|
50
|
+
}
|
|
51
|
+
const headers = {
|
|
52
|
+
Authorization: `Bearer ${APIFY_TOKEN}`,
|
|
53
|
+
"Content-Type": "application/json",
|
|
54
|
+
"User-Agent": USER_AGENT,
|
|
55
|
+
};
|
|
56
|
+
const httpError = async (response) => {
|
|
57
|
+
let detail = "";
|
|
58
|
+
try {
|
|
59
|
+
const body = (await response.json());
|
|
60
|
+
if (body?.error?.message)
|
|
61
|
+
detail = ` ${body.error.message}`;
|
|
62
|
+
}
|
|
63
|
+
catch {
|
|
64
|
+
detail = "";
|
|
65
|
+
}
|
|
66
|
+
switch (response.status) {
|
|
67
|
+
case 400:
|
|
68
|
+
return `The ${actorLabel} run was rejected as invalid input.${detail}`;
|
|
69
|
+
case 401:
|
|
70
|
+
return "Invalid Apify token. Check your APIFY_TOKEN environment variable.";
|
|
71
|
+
case 402:
|
|
72
|
+
return "Insufficient Apify credits. Check your account balance at https://console.apify.com/billing";
|
|
73
|
+
default:
|
|
74
|
+
return `Apify request to ${actorLabel} failed with status ${response.status}.${detail}`;
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
// 1. Start the run.
|
|
78
|
+
let started;
|
|
79
|
+
try {
|
|
80
|
+
started = await fetch(`https://api.apify.com/v2/acts/${actorPath}/runs?timeout=${ACTOR_RUN_TIMEOUT_SECS}`, { method: "POST", headers, body: JSON.stringify(input) });
|
|
81
|
+
}
|
|
82
|
+
catch (err) {
|
|
83
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
84
|
+
return { isError: true, content: [{ type: "text", text: `Could not reach the Apify API: ${message}` }] };
|
|
85
|
+
}
|
|
86
|
+
if (!started.ok) {
|
|
87
|
+
return { isError: true, content: [{ type: "text", text: await httpError(started) }] };
|
|
88
|
+
}
|
|
89
|
+
let run;
|
|
90
|
+
try {
|
|
91
|
+
run = (await started.json()).data ?? {};
|
|
92
|
+
}
|
|
93
|
+
catch (err) {
|
|
94
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
95
|
+
return { isError: true, content: [{ type: "text", text: `The ${actorLabel} run start returned a response that could not be parsed: ${message}` }] };
|
|
96
|
+
}
|
|
97
|
+
const runId = run.id;
|
|
98
|
+
if (!runId) {
|
|
99
|
+
return { isError: true, content: [{ type: "text", text: `The ${actorLabel} run start returned no run id, so there is nothing to wait for.` }] };
|
|
100
|
+
}
|
|
101
|
+
// 2. Poll to a terminal status.
|
|
102
|
+
const deadline = Date.now() + WRAPPER_WAIT_MS;
|
|
103
|
+
let status = run.status ?? "READY";
|
|
104
|
+
let datasetId = run.defaultDatasetId;
|
|
105
|
+
while (!TERMINAL.has(status)) {
|
|
106
|
+
if (Date.now() >= deadline) {
|
|
107
|
+
return {
|
|
108
|
+
isError: true,
|
|
109
|
+
content: [{ type: "text", text: `The ${actorLabel} run ${runId} was still ${status} after ${Math.round(WRAPPER_WAIT_MS / 1000)} seconds and this call stopped waiting. The run itself is still on Apify: read it at https://console.apify.com/actors/runs/${runId}` }],
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
await sleep(POLL_INTERVAL_MS);
|
|
113
|
+
let poll;
|
|
114
|
+
try {
|
|
115
|
+
poll = await fetch(`https://api.apify.com/v2/actor-runs/${runId}`, { headers });
|
|
116
|
+
}
|
|
117
|
+
catch (err) {
|
|
118
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
119
|
+
return { isError: true, content: [{ type: "text", text: `Lost contact with the Apify API while waiting for ${actorLabel} run ${runId}: ${message}` }] };
|
|
120
|
+
}
|
|
121
|
+
if (!poll.ok) {
|
|
122
|
+
return { isError: true, content: [{ type: "text", text: await httpError(poll) }] };
|
|
123
|
+
}
|
|
124
|
+
const body = (await poll.json());
|
|
125
|
+
status = body.data?.status ?? status;
|
|
126
|
+
datasetId = body.data?.defaultDatasetId ?? datasetId;
|
|
127
|
+
}
|
|
128
|
+
// 3. A run that did not succeed is a failure the caller must see, never an
|
|
129
|
+
// empty success. Surfacing it here is what keeps a crashed run from reading
|
|
130
|
+
// as "no results found".
|
|
131
|
+
if (status !== "SUCCEEDED") {
|
|
132
|
+
return {
|
|
133
|
+
isError: true,
|
|
134
|
+
content: [{ type: "text", text: `The ${actorLabel} run did not succeed (run ID: ${runId}, status: ${status}).` }],
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
if (!datasetId) {
|
|
138
|
+
return { isError: true, content: [{ type: "text", text: `The ${actorLabel} run ${runId} succeeded but reported no dataset, so there is nothing to return.` }] };
|
|
139
|
+
}
|
|
140
|
+
// 4. Read the dataset.
|
|
141
|
+
let ds;
|
|
142
|
+
try {
|
|
143
|
+
ds = await fetch(`https://api.apify.com/v2/datasets/${datasetId}/items?format=json`, { headers });
|
|
144
|
+
}
|
|
145
|
+
catch (err) {
|
|
146
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
147
|
+
return { isError: true, content: [{ type: "text", text: `Could not read the ${actorLabel} dataset: ${message}` }] };
|
|
148
|
+
}
|
|
149
|
+
if (!ds.ok) {
|
|
150
|
+
return { isError: true, content: [{ type: "text", text: await httpError(ds) }] };
|
|
151
|
+
}
|
|
152
|
+
let items;
|
|
153
|
+
try {
|
|
154
|
+
items = await ds.json();
|
|
155
|
+
}
|
|
156
|
+
catch (err) {
|
|
157
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
158
|
+
return { isError: true, content: [{ type: "text", text: `The ${actorLabel} run returned a response that could not be parsed: ${message}` }] };
|
|
159
|
+
}
|
|
160
|
+
if (!Array.isArray(items)) {
|
|
161
|
+
const asObj = items;
|
|
162
|
+
const detail = asObj?.error?.message
|
|
163
|
+
? `${asObj.error.message}`
|
|
164
|
+
: JSON.stringify(items);
|
|
165
|
+
return { isError: true, content: [{ type: "text", text: `The ${actorLabel} run did not return a dataset. ${detail}` }] };
|
|
166
|
+
}
|
|
167
|
+
return { content: [{ type: "text", text: JSON.stringify(items, null, 2) }] };
|
|
168
|
+
}
|
|
169
|
+
const server = new McpServer({
|
|
170
|
+
name: "mamba-substack-scraper",
|
|
171
|
+
version: pkg.version,
|
|
172
|
+
});
|
|
173
|
+
// Substack Scraper (immutable actor ID UEFsdwiPLmPNVy9xd). Every buyer facing input of the actor
|
|
174
|
+
// is exposed. The actor takes numbers and booleans as strings, so those inputs are strings here too.
|
|
175
|
+
server.registerTool("scrape_substack", {
|
|
176
|
+
title: "Scrape Substack publications, posts, and search",
|
|
177
|
+
description: "Read Substack publications and posts, or search Substack by keyword. Give publications as URLs, domains, substack.com profiles, or bare Substack names (for example lenny.substack.com, https://www.notboring.co, lenny). Each publication returns one publication row (name, author, subscriber count as Substack shows it, subscriber tier text, paid plan prices) and its newest posts, one row each with date, free or paid audience, likes, comments, restacks, word count, bylines, and tags. Search queries return matching posts with their publication and subscriber count, or one row per publication when search_output is publications. Input with nothing to run returns one free row whose error_reason starts with input_invalid:. A run that does not succeed is returned as an error with its run ID. Read-only; requires an APIFY_TOKEN; Apify charges per post row and per publication row.",
|
|
178
|
+
annotations: {
|
|
179
|
+
title: "Scrape Substack publications, posts, and search",
|
|
180
|
+
readOnlyHint: true,
|
|
181
|
+
destructiveHint: false,
|
|
182
|
+
idempotentHint: true,
|
|
183
|
+
openWorldHint: true,
|
|
184
|
+
},
|
|
185
|
+
inputSchema: {
|
|
186
|
+
publications: z.array(z.string()).optional().describe("Substack publications, one per line, up to 100: a URL (https://www.lennysnewsletter.com), a domain (lenny.substack.com), a profile (substack.com/@lenny), or a bare Substack name (lenny). Each one returns a publication row and its newest posts."),
|
|
187
|
+
search_queries: z.array(z.string()).optional().describe("Keywords to search across Substack posts, one per line, up to 20. Each query returns matching posts, or the publications behind them when Search output is publications."),
|
|
188
|
+
search_output: z.enum(["posts", "publications"]).optional().describe("What a search query returns. Default posts."),
|
|
189
|
+
max_posts_per_publication: z.string().optional().describe("Newest posts returned per publication, 0 to 1000. 0 returns only the publication row. Default 20."),
|
|
190
|
+
max_search_results: z.string().optional().describe("Rows returned per search query, 1 to 1000. Default 50."),
|
|
191
|
+
since_days: z.string().optional().describe("Optional. Skip posts older than this many days. 0 or empty keeps every post up to the max. Default 0."),
|
|
192
|
+
include_publication_row: z.string().optional().describe("true to return one publication row per listed publication (name, author, subscribers, paid plan prices), billed as a publication row. false returns only post rows. Default true."),
|
|
193
|
+
include_body: z.string().optional().describe("true to add the post text (up to 20,000 characters) to each post row of a listed publication. A paid post gives its free preview. Reads one more page per post; no extra charge. Default false."),
|
|
194
|
+
max_charge_usd: z.string().optional().describe("Optional. The run stops before it would charge more than this."),
|
|
195
|
+
proxy_mode: z.enum(["auto", "direct"]).optional().describe("How pages are fetched. Default auto."),
|
|
196
|
+
},
|
|
197
|
+
}, async (args) => runActor("UEFsdwiPLmPNVy9xd", "Substack Scraper", compact(args)));
|
|
198
|
+
const transport = new StdioServerTransport();
|
|
199
|
+
await server.connect(transport);
|
package/package.json
CHANGED
|
@@ -1,6 +1,50 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mambalabsdev/mcp-substack-scraper",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"description": "MCP server for Substack Scraper. Read Substack publications and posts, or search Substack by keyword: subscriber counts, paid plan prices, and every post with date, paid flag, likes, comments, and restacks. Runs on Apify. Clay-ready output.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"mcp-substack-scraper": "./build/index.js"
|
|
8
|
+
},
|
|
9
|
+
"files": [
|
|
10
|
+
"build",
|
|
11
|
+
"README.md",
|
|
12
|
+
"LICENSE",
|
|
13
|
+
"SECURITY.md"
|
|
14
|
+
],
|
|
15
|
+
"scripts": {
|
|
16
|
+
"build": "tsc && chmod +x build/index.js",
|
|
17
|
+
"test": "npm run build && node --test test/*.test.js",
|
|
18
|
+
"prepublishOnly": "npm run build"
|
|
19
|
+
},
|
|
20
|
+
"keywords": [
|
|
21
|
+
"mcp",
|
|
22
|
+
"model-context-protocol",
|
|
23
|
+
"substack",
|
|
24
|
+
"newsletter",
|
|
25
|
+
"substack-scraper",
|
|
26
|
+
"creator-economy",
|
|
27
|
+
"sponsorship",
|
|
28
|
+
"clay",
|
|
29
|
+
"apify"
|
|
30
|
+
],
|
|
31
|
+
"author": "Mamba Labs <labs@mambamindsetgrowth.com>",
|
|
32
|
+
"license": "MIT",
|
|
33
|
+
"homepage": "https://apify.com/mambalabs/substack-scraper",
|
|
34
|
+
"repository": {
|
|
35
|
+
"type": "git",
|
|
36
|
+
"url": "https://github.com/mambalabsdev/mcp-substack-scraper"
|
|
37
|
+
},
|
|
38
|
+
"engines": {
|
|
39
|
+
"node": ">=18"
|
|
40
|
+
},
|
|
41
|
+
"dependencies": {
|
|
42
|
+
"@modelcontextprotocol/sdk": "^1.32.2",
|
|
43
|
+
"zod": "^4.4.3"
|
|
44
|
+
},
|
|
45
|
+
"devDependencies": {
|
|
46
|
+
"@types/node": "^26.2.0",
|
|
47
|
+
"typescript": "5.9.3"
|
|
48
|
+
},
|
|
49
|
+
"mcpName": "com.mambabuilt/mcp-substack-scraper"
|
|
50
|
+
}
|