redditapis-mcp 0.10.1 → 0.10.3

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 CHANGED
@@ -1,5 +1,40 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.10.3 (2026-10-14)
4
+
5
+ ### reddit_post_comments takes limit, depth and sort
6
+
7
+ A thread read had no knobs, so a 33-comment thread came back as 75k chars in one
8
+ line and a 2,700-comment thread was unreadable from any MCP client. The tool now
9
+ accepts `limit` (top-level comments, 1 to 500, default 100), `depth` (reply depth,
10
+ 1 to 10; `depth=1` is top-level only; absent is the full tree) and `sort`
11
+ (confidence, top, new, controversial, old, qa). The API echoes what it applied in
12
+ `meta` (`limit_used`, `depth_used`, `sort_used`). Reported through feedback
13
+ cbf0156d.
14
+
15
+ ### Fan-out tools say when an answer is partial
16
+
17
+ `reddit_deep_comment_search` reports `meta.partial`, `meta.trees_failed` and
18
+ `meta.trees_fetched` when one of its comment-tree reads failed while the others
19
+ succeeded, and fails only when every tree failed and at least one was refused
20
+ upstream. `reddit_post_visibility` answers `undecidable` with
21
+ `checked.listing_error` when the post resolved but the author listing read did
22
+ not (`upstream_unavailable` and `upstream_timeout` are not billed;
23
+ `listing_unavailable` means Reddit answered the listing with 403 or 404 and is
24
+ billed). The descriptions carry both contracts.
25
+
26
+ ## 0.10.2 (2026-10-14)
27
+
28
+ ### The 408 upstream_timeout read gets the same one retry
29
+
30
+ The API now answers `408 {"error":"upstream_timeout"}` when a read did not complete in
31
+ time (the body says it was not billed and names `retry_after`); before this release that
32
+ case was a 500 and the model saw it as a failed tool call. A read answered that way is
33
+ retried once after its `retry_after` (clamped 1..5 s), exactly like the 503
34
+ `upstream_unavailable` retry from 0.10.1, and a 408 that is not retried carries a hint
35
+ naming the retry. A 408 with any other error value, and a 408 on a write, are never
36
+ retried.
37
+
3
38
  ## 0.10.1 (2026-10-14)
4
39
 
5
40
  ### One bounded retry on the API's transient 503, and a clearer 429
package/README.md CHANGED
@@ -317,6 +317,8 @@ Reads need nothing but your API key -- no account linking, login, or cookie step
317
317
 
318
318
  **`HTTP 429 (rate limited)`** Wait a few seconds and retry, or reduce request frequency. For bulk work, space out calls and raise `REDDITAPIS_TIMEOUT_MS`.
319
319
 
320
+ **`HTTP 408 (upstream_timeout)`** The read did not finish in time and was not billed. The server already retried once after `retry_after`; call the tool again shortly. A `503 upstream_unavailable` on a read gets the same one retry.
321
+
320
322
  **`Request failed: timed out after 30000ms`** The default timeout is 30 seconds. For large `reddit_deep_comment_search` or paginated fetches, set `REDDITAPIS_TIMEOUT_MS` higher (for example `60000`).
321
323
 
322
324
  **Tools do not appear in Claude / Cursor** Ensure `npx` is on your PATH and Node.js 18+ is installed (`node --version`). Check your MCP client logs for startup errors.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "redditapis-mcp",
3
- "version": "0.10.1",
3
+ "version": "0.10.3",
4
4
  "mcpName": "io.github.redditapis/redditapis-mcp",
5
5
  "description": "Official MCP server for redditapis.com. Search Reddit posts, comments, communities, users and media; read subreddits, comment trees, top posts and profiles; create and manage monitors and webhooks. Native tools for Claude, Cursor and any MCP client.",
6
6
  "repository": {
@@ -31,10 +31,11 @@
31
31
  "scripts": {
32
32
  "start": "node src/index.js",
33
33
  "check": "node --check src/index.js && node --check src/tools.js && node --check src/feedback.js && node --check src/server.js && node --check src/watch.js && node --check src/watch-text.js && node --check src/provenance.js && node --check src/playbooks.js",
34
- "test": "node test/tools.test.mjs && node test/watch.test.mjs && node test/watch-invariants.test.mjs && node test/provenance.test.mjs && node test/playbooks.test.mjs && node test/description-compliance.test.mjs && node test/inline-credentials.test.mjs && node test/feedback.test.mjs && node test/index-lasterror.test.mjs && node test/scannable-without-key.test.mjs && node test/per-caller-state.test.mjs && node test/paywall.test.mjs && node test/remote-host.test.mjs",
34
+ "test": "node test/tools.test.mjs && node test/watch.test.mjs && node test/watch-invariants.test.mjs && node test/provenance.test.mjs && node test/playbooks.test.mjs && node test/description-compliance.test.mjs && node test/inline-credentials.test.mjs && node test/feedback.test.mjs && node test/index-lasterror.test.mjs && node test/scannable-without-key.test.mjs && node test/per-caller-state.test.mjs && node test/paywall.test.mjs && node test/remote-host.test.mjs && node test/hub-parity.test.mjs && node test/version-parity.test.mjs",
35
35
  "prepublishOnly": "node scripts/prepublish-tenant-check.mjs",
36
- "postpublish": "node scripts/registry-drift.mjs --publish",
37
- "check:registry-drift": "node scripts/registry-drift.mjs"
36
+ "postpublish": "node scripts/postpublish.mjs",
37
+ "check:registry-drift": "node scripts/registry-drift.mjs",
38
+ "check:hub-parity": "node scripts/hosted-hub-parity.mjs"
38
39
  },
39
40
  "dependencies": {
40
41
  "@modelcontextprotocol/sdk": "^1.29.0",
package/src/server.js CHANGED
@@ -134,6 +134,7 @@ export function hintFor(status, path) {
134
134
  for (const [re, hint] of NOT_FOUND_HINTS) if (re.test(path || "")) return hint;
135
135
  return DEFAULT_NOT_FOUND_HINT;
136
136
  }
137
+ if (status === 408) return " (the read did not complete in time; retry after the retry_after seconds)";
137
138
  if (status === 429) return " (slow down: wait the retry_after seconds, keep this key's reads in flight under the limit the message names, then retry)";
138
139
  if (status >= 500) return " (upstream API error. Retry in a moment; if persistent, contact https://www.redditapis.com)";
139
140
  return "";
@@ -279,8 +280,9 @@ export function createServer({
279
280
  // An API restart makes the gateway answer an HTML 502/503 or refuse the
280
281
  // connection for a short window. A READ is retried through it; timeouts and
281
282
  // writes never are, so a request the API may already have handled is never sent
282
- // twice (a gateway 504 is not retried for that reason). The one API JSON error
283
- // that IS retried is the read-side 503 upstream_unavailable below (0.10.1).
283
+ // twice (a gateway 504 is not retried for that reason). The API JSON errors
284
+ // that ARE retried, once, are the read-side 503 upstream_unavailable (0.10.1)
285
+ // and 408 upstream_timeout (0.10.2) below.
284
286
  // Only a REFUSED connection is retried: the request never reached the API,
285
287
  // so it cannot have been handled or billed. A reset, a broken pipe or a
286
288
  // socket dropped mid-answer can all happen after the API did the work, and
@@ -288,7 +290,9 @@ export function createServer({
288
290
  const RETRYABLE_NET = new Set(["ECONNREFUSED"]);
289
291
  const gatewayFailure = (status, text) =>
290
292
  (status === 502 || status === 503) && /^\s*<(!doctype|html)/i.test(text);
291
- // The API's own transient refusal of a READ: 503 with error upstream_unavailable.
293
+ // The API's own transient refusal of a READ: 503 with error upstream_unavailable,
294
+ // and since 0.10.2 the 408 upstream_timeout it answers when a read did not
295
+ // complete in time (the body says it was not billed and names retry_after).
292
296
  // Its body says the call was not billed and names retry_after, so ONE retry after
293
297
  // that many seconds (clamped 1..5) never double-bills and turns a per-read refusal
294
298
  // into a slow success instead of a failed tool call (0.10.1). Never a write, never
@@ -296,8 +300,10 @@ export function createServer({
296
300
  // The TOP-LEVEL error value, parsed, never a substring match (review 2026-10-14:
297
301
  // a body nesting the string elsewhere must not be retried).
298
302
  const parsedBody = (text) => { try { const v = JSON.parse(text); return v && typeof v === "object" ? v : null; } catch { return null; } };
299
- const apiTransientRead = (status, text) =>
300
- status === 503 && parsedBody(text)?.error === "upstream_unavailable";
303
+ const apiTransientRead = (status, text) => {
304
+ const err = parsedBody(text)?.error;
305
+ return (status === 503 && err === "upstream_unavailable") || (status === 408 && err === "upstream_timeout");
306
+ };
301
307
  const retryAfterMs = (text) => {
302
308
  const s = Number(parsedBody(text)?.retry_after);
303
309
  return Math.min(5, Math.max(1, Number.isFinite(s) && s > 0 ? s : 2)) * 1000;
package/src/tools.js CHANGED
@@ -294,7 +294,7 @@ export const TOOLS = [
294
294
  name: "reddit_post_visibility",
295
295
  path: "/api/reddit/post/{id}/visibility",
296
296
  description:
297
- "Is a post still publicly visible, or did it quietly stop being so? A removed Reddit post still returns when fetched by id, so the post alone does not answer this. This fetches the post and then one page of its author's submitted listing and compares them. Returns a verdict of live, not_visible or undecidable, a plain-language reason, and a confident flag. By design it does not say WHY a post is not visible: a moderator removal, an admin removal, a spam filter and an author who has hidden their history are indistinguishable from outside. undecidable is a real answer, not a failure. Two upstream calls, billed as one $0.004 dual read.",
297
+ "Is a post still publicly visible, or did it quietly stop being so? A removed Reddit post still returns when fetched by id, so the post alone does not answer this. This fetches the post and then one page of its author's submitted listing and compares them. Returns a verdict of live, not_visible or undecidable, a plain-language reason, and a confident flag. By design it does not say WHY a post is not visible: a moderator removal, an admin removal, a spam filter and an author who has hidden their history are indistinguishable from outside. undecidable is a real answer, not a failure. When the post resolves but the author listing read fails, the answer is still returned as undecidable with checked.author_listing false and checked.listing_error naming why (upstream_unavailable or upstream_timeout: our read was refused, not billed; listing_unavailable: Reddit answered the listing with 403 or 404, billed). Two upstream calls, billed as one $0.004 dual read.",
298
298
  shape: {
299
299
  id: z.string().min(1).describe("Reddit post id, base36, with or without the t3_ prefix"),
300
300
  },
@@ -303,11 +303,20 @@ export const TOOLS = [
303
303
  name: "reddit_post_comments",
304
304
  path: "/api/reddit/comments",
305
305
  description:
306
- "Fetches a single post and its comment tree by permalink. Returns the post plus threaded comments (author, body, score, replies) and an `after` cursor. The `permalink` is the one carried by any post result.",
306
+ "Fetches a single post and its comment tree by permalink. Returns the post plus threaded comments (author, body, score, replies) and an `after` cursor. The `permalink` is the one carried by any post result. Size a big thread with the three knobs: `limit` caps top-level comments (1-500, default 100), `depth` caps reply depth (1-10; `depth=1` is top-level only; absent is the full tree) and `sort` orders them (confidence = Reddit's best, top, new, controversial, old, qa). `limit=20, depth=1, sort='top'` reads the twenty best top-level comments and nothing below them, which keeps a 2,700-comment thread readable. `meta` echoes limit_used, depth_used and sort_used.",
307
307
  shape: {
308
308
  permalink: z.string().min(1).describe(
309
309
  "The post permalink path from a prior post result, e.g. '/r/programming/comments/abc123/some_title/'. Required.",
310
310
  ),
311
+ limit: z.number().int().min(1).max(500).optional().describe(
312
+ "Maximum top-level comments, 1-500 (default 100). A small value with depth=1 gives a readable summary of a large thread.",
313
+ ),
314
+ depth: z.number().int().min(1).max(10).optional().describe(
315
+ "Maximum reply depth, 1-10. depth=1 returns top-level comments only. Absent, Reddit's full tree is returned.",
316
+ ),
317
+ sort: z.enum(["confidence", "top", "new", "controversial", "old", "qa"]).optional().describe(
318
+ "Comment ordering: confidence (Reddit's best), top, new, controversial, old or qa. Absent, Reddit's default for the thread.",
319
+ ),
311
320
  },
312
321
  },
313
322
  {
@@ -328,7 +337,7 @@ export const TOOLS = [
328
337
  name: "reddit_deep_comment_search",
329
338
  path: "/api/reddit/search/comments/deep",
330
339
  description:
331
- "Comment search that returns the ACTUAL comments whose body matches the keyword, sorted by score (highest first), with body, score, author, a comment-deep permalink, and the parent post. It fetches each matching post's comment tree and filters the comment bodies, so the results are first-hand opinions and answers rather than parent posts. Premium call (it fans out into several reads): `limit` sets how many parent POSTS to expand, 1-25 (default 5), not how many comments come back. The response's `after` cursor expands the NEXT batch of parent posts. `max_comments` optionally caps how many comments come back (the top-scored are kept). Matching is on the visible comment text at word boundaries (link URLs are ignored), so every result mentions the query where a reader can see it. Best-effort: a deleted or deeply-nested comment may be missed (meta.truncated flags when a tree was too deep). group_by='author' switches to a research mode that returns WHO is talking about the query (distinct people ranked by matching-comment count) in place of a flat comment list, capped by max_authors. Example: q='best mechanical keyboard' sort='relevance' t='year'.",
340
+ "Comment search that returns the ACTUAL comments whose body matches the keyword, sorted by score (highest first), with body, score, author, a comment-deep permalink, and the parent post. It fetches each matching post's comment tree and filters the comment bodies, so the results are first-hand opinions and answers rather than parent posts. Premium call (it fans out into several reads): `limit` sets how many parent POSTS to expand, 1-25 (default 5), not how many comments come back. The response's `after` cursor expands the NEXT batch of parent posts. `max_comments` optionally caps how many comments come back (the top-scored are kept). Matching is on the visible comment text at word boundaries (link URLs are ignored), so every result mentions the query where a reader can see it. Best-effort: a deleted or deeply-nested comment may be missed (meta.truncated flags when a tree was too deep). Each parent post is its own comment-tree read and one can fail while the others succeed: meta.partial is true with meta.trees_failed and meta.trees_fetched when that happened, so the result covers fewer parent posts than it scanned; the call fails only when every tree failed and at least one was refused upstream. group_by='author' switches to a research mode that returns WHO is talking about the query (distinct people ranked by matching-comment count) in place of a flat comment list, capped by max_authors. Example: q='best mechanical keyboard' sort='relevance' t='year'.",
332
341
  shape: {
333
342
  ...QUERY,
334
343
  ...SORT_SEARCH,