feedkeeper 0.36.2 → 0.36.4

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.
@@ -13,8 +13,8 @@ import { generateOpml, importOpmlFeeds } from "../feeds/opml.js";
13
13
  import { pollFeed } from "../feeds/poller.js";
14
14
  import { discoverFeeds } from "../feeds/discovery.js";
15
15
  import { APP_VERSION } from "../version.js";
16
- import { dismissEdition, editionCandidates, ensureEditionSchema, getEdition, getEditionState, publishCuratedEdition, publishEditionFields } from "../native/editions.js";
17
- import { getNativePreferences, patchNativePreferences, preferencePatchSchema } from "../native/preferences.js";
16
+ import { dismissEdition, editionCandidates, getEditionState, publishCuratedEdition, publishEditionFields } from "../native/editions.js";
17
+ import { getNativePreferences } from "../native/preferences.js";
18
18
  import { NativeError } from "../native/requests.js";
19
19
  import { capabilityDenial, hasUserCapability } from "../auth/capabilities.js";
20
20
  function textResult(payload) {
@@ -25,13 +25,13 @@ function errorResult(message) {
25
25
  }
26
26
  const dateInput = z.union([z.string().datetime({ offset: true }), z.string().date()]);
27
27
  const publishedRange = {
28
- since: dateInput.optional().describe("Only items published at or after this ISO date or date-time"),
29
- until: dateInput.optional().describe("Only items published at or before this ISO date or date-time"),
28
+ since: dateInput.optional().describe("Filter for items published at or after this ISO date or date-time"),
29
+ until: dateInput.optional().describe("Filter for items published at or before this ISO date or date-time"),
30
30
  };
31
31
  // Item actions accept one ID or a batch, so clients can triage many articles in one call.
32
32
  const itemSelection = {
33
- itemId: z.number().int().positive().optional().describe("A single item ID"),
34
- itemIds: z.array(z.number().int().positive()).min(1).max(200).optional().describe("Up to 200 item IDs"),
33
+ itemId: z.number().int().positive().optional().describe("A single item ID to target"),
34
+ itemIds: z.array(z.number().int().positive()).min(1).max(200).optional().describe("An array of up to 200 item IDs to target in batch"),
35
35
  };
36
36
  function selectedItemIds({ itemId, itemIds }) {
37
37
  return [...(itemIds ?? []), ...(itemId ? [itemId] : [])];
@@ -45,25 +45,37 @@ export function createMcpServerForUser(userId, scope) {
45
45
  "Use it to read, search, and triage RSS/Atom feeds, fetch full article text, manage reading lists, " +
46
46
  "and read or publish curated newspaper editions.",
47
47
  });
48
+ const mcpUrlSchema = z.preprocess((val) => (typeof val === "string" ? normalizeUrlCandidate(val) : val), z.string().url());
48
49
  server.registerTool("list_feeds", {
49
50
  title: "List subscribed feeds",
50
- description: "Lists all RSS/Atom feeds the current user is subscribed to, including unread counts and polling health.",
51
+ description: "Lists all RSS/Atom feeds the current user is subscribed to, including subscription settings, unread counts, and polling health status. Safe read-only operation. To inspect a single feed in detail, use get_feed. To discover new feeds, use discover_feeds.",
51
52
  inputSchema: {
52
- onlyWithErrors: z.boolean().optional().describe("Only return feeds whose last poll failed"),
53
+ onlyWithErrors: z.boolean().optional().describe("When true, only returns feeds whose last poll failed or that have consecutive errors"),
53
54
  },
54
55
  }, async ({ onlyWithErrors }) => {
55
56
  const feeds = listSubscriptionsForUser(userId);
56
57
  return textResult(onlyWithErrors ? feeds.filter((feed) => feed.last_error || feed.consecutive_errors > 0) : feeds);
57
58
  });
58
- const mcpUrlSchema = z.preprocess((val) => (typeof val === "string" ? normalizeUrlCandidate(val) : val), z.string().url());
59
+ server.registerTool("get_feed", {
60
+ title: "Get subscribed feed details",
61
+ description: "Returns metadata, subscription settings, polling health status, and unread count for a single subscribed feed by its numeric feed ID. Safe read-only operation. Use list_feeds to view all subscribed feeds.",
62
+ inputSchema: {
63
+ feedId: z.number().int().positive().describe("The numeric ID of the subscribed feed to inspect"),
64
+ },
65
+ }, async ({ feedId }) => {
66
+ const feed = listSubscriptionsForUser(userId).find((f) => f.id === feedId);
67
+ if (!feed)
68
+ return errorResult("feed_not_found: Feed does not exist or user is not subscribed");
69
+ return textResult(feed);
70
+ });
59
71
  if (scope === "write")
60
72
  server.registerTool("subscribe_feed", {
61
73
  title: "Subscribe to a feed",
62
- description: "Subscribes the current user to an RSS/Atom feed URL or website URL (auto-discovering the feed).",
74
+ description: "Subscribes the current user to an RSS/Atom feed URL or website URL (auto-discovering the feed link if a website URL is provided). Requires write scope. Idempotent: subscribing to an already subscribed feed returns the existing subscription. Returns the subscription record.",
63
75
  inputSchema: {
64
- url: mcpUrlSchema.describe("The feed URL or website URL"),
65
- label: z.string().max(200).optional().describe("Optional display name for this feed"),
66
- folderId: z.number().int().positive().optional().describe("Optional folder/category ID"),
76
+ url: mcpUrlSchema.describe("The RSS/Atom feed URL or website URL to subscribe to"),
77
+ label: z.string().max(200).optional().describe("Optional custom display name for this feed subscription"),
78
+ folderId: z.number().int().positive().optional().describe("Optional folder/category ID to place the new subscription in"),
67
79
  },
68
80
  }, async ({ url, label, folderId }) => {
69
81
  if (!hasUserCapability(userId, "sync"))
@@ -89,9 +101,9 @@ export function createMcpServerForUser(userId, scope) {
89
101
  });
90
102
  server.registerTool("discover_feeds", {
91
103
  title: "Discover feeds on a website",
92
- description: "Inspects a website URL and discovers available RSS/Atom feed links.",
104
+ description: "Inspects a website URL and discovers available RSS, Atom, and JSON feed links from HTML link tags. Safe read-only operation: does NOT subscribe to any feed. Returns a list of discovered candidate feed URLs and titles. Use subscribe_feed to subscribe to one of the discovered URLs.",
93
105
  inputSchema: {
94
- url: mcpUrlSchema.describe("The website URL to discover feeds from"),
106
+ url: mcpUrlSchema.describe("The website URL to scan for available RSS/Atom feed links"),
95
107
  },
96
108
  }, async ({ url }) => {
97
109
  if (!hasUserCapability(userId, "sync"))
@@ -109,8 +121,10 @@ export function createMcpServerForUser(userId, scope) {
109
121
  if (scope === "write")
110
122
  server.registerTool("unsubscribe_feed", {
111
123
  title: "Unsubscribe from a feed",
112
- description: "Unsubscribes the current user from a feed. Feeds and other users' subscriptions are unaffected.",
113
- inputSchema: { feedId: z.number().int().positive() },
124
+ description: "Unsubscribes the current user from a feed by its feed ID. Destructive action. Feeds and other users' subscriptions are unaffected. Returns { ok: true } on success.",
125
+ inputSchema: {
126
+ feedId: z.number().int().positive().describe("The numeric ID of the feed to unsubscribe from"),
127
+ },
114
128
  }, async ({ feedId }) => {
115
129
  try {
116
130
  unsubscribeFromFeed(userId, feedId);
@@ -122,14 +136,14 @@ export function createMcpServerForUser(userId, scope) {
122
136
  });
123
137
  if (scope === "write")
124
138
  server.registerTool("save_to_inbox", {
125
- title: "Save article or clipping to Inbox",
126
- description: "Saves a web article URL, raw HTML, text clipping, or note directly into the user's Universal Inbox.",
139
+ title: "Save article or clipping to Universal Inbox",
140
+ description: "Saves a web article URL, raw HTML, plain text/markdown clipping, or personal note directly into the user's Universal Inbox. At least one of url, contentHtml, or textContent must be provided. Returns { success: true, itemId: number, title: string, url: string, hasNote: boolean }.",
127
141
  inputSchema: {
128
- url: mcpUrlSchema.optional().describe("Web page URL to fetch, extract, and save"),
129
- title: z.string().max(500).optional().describe("Optional custom title"),
130
- contentHtml: z.string().optional().describe("Optional pre-rendered HTML content"),
131
- textContent: z.string().optional().describe("Optional plain text or markdown clipping"),
132
- note: z.string().max(20000).optional().describe("Optional note or summary attached to the saved item"),
142
+ url: mcpUrlSchema.optional().describe("Web page URL to fetch, extract via Readability, and save"),
143
+ title: z.string().max(500).optional().describe("Optional custom title for the saved inbox item"),
144
+ contentHtml: z.string().optional().describe("Optional pre-rendered HTML content for the clipping"),
145
+ textContent: z.string().optional().describe("Optional plain text or markdown clipping content"),
146
+ note: z.string().max(20000).optional().describe("Optional personal note or editorial summary attached to the saved item"),
133
147
  },
134
148
  }, async ({ url, title, contentHtml, textContent, note }) => {
135
149
  if (!url && !contentHtml && !textContent) {
@@ -156,22 +170,24 @@ export function createMcpServerForUser(userId, scope) {
156
170
  });
157
171
  server.registerTool("list_folders", {
158
172
  title: "List folders / categories",
159
- description: "Lists all feed categories/folders created by the user, including feed and unread counts.",
173
+ description: "Lists all feed categories/folders created by the current user, including feed counts and unread article counts per folder. Safe read-only operation.",
160
174
  inputSchema: {},
161
175
  }, async () => textResult(listFoldersForUser(userId)));
162
176
  if (scope === "write")
163
177
  server.registerTool("create_folder", {
164
- title: "Create folder",
165
- description: "Creates a new category/folder to organize feeds.",
166
- inputSchema: { name: z.string().trim().min(1).max(100) },
178
+ title: "Create a feed folder",
179
+ description: "Creates a new category folder to organize feed subscriptions. Requires write scope. Returns the created folder object with its assigned id, name, and position. Folders can be assigned to feeds using move_feed_to_folder.",
180
+ inputSchema: {
181
+ name: z.string().trim().min(1).max(100).describe("The unique display name for the new folder (1 to 100 characters)"),
182
+ },
167
183
  }, async ({ name }) => textResult(createFolder(userId, name)));
168
184
  if (scope === "write")
169
185
  server.registerTool("move_feed_to_folder", {
170
186
  title: "Move feed to folder",
171
- description: "Assigns a feed to a folder, or removes it from all folders if folderId is null.",
187
+ description: "Assigns a subscribed feed to a folder, or removes it from all folders (unfiled) if folderId is null. Requires write scope. Returns { ok: true } on success.",
172
188
  inputSchema: {
173
- feedId: z.number().int().positive(),
174
- folderId: z.number().int().positive().nullable(),
189
+ feedId: z.number().int().positive().describe("The numeric ID of the subscribed feed to move"),
190
+ folderId: z.number().int().positive().nullable().describe("The target folder ID, or null to move the feed to unfiled (root level)"),
175
191
  },
176
192
  }, async ({ feedId, folderId }) => {
177
193
  if (!isUserSubscribed(userId, feedId))
@@ -184,15 +200,15 @@ export function createMcpServerForUser(userId, scope) {
184
200
  if (scope === "write")
185
201
  server.registerTool("update_feed", {
186
202
  title: "Update feed settings",
187
- description: "Changes a subscription: its feed URL (e.g. when a site moved its feed and polling keeps failing), display name, poll interval, whether the reader may fetch full articles, and whether new articles trigger push notifications or count in the app icon number. A new URL is fetched and validated before it replaces the old one. If the returned feed ID differs from the one passed in, use the new ID from now on. The poll interval applies to every subscriber of the feed and has a server-wide minimum.",
203
+ description: "Updates subscription settings for a feed: custom display name, poll interval, full-text extraction policy, push notification preference, badge counter inclusion, or updates the feed URL if the publisher relocated. Returns the updated subscription record.",
188
204
  inputSchema: {
189
- feedId: z.number().int().positive(),
190
- url: mcpUrlSchema.optional().describe("New feed URL or website URL (the feed is auto-discovered)"),
191
- label: z.string().max(200).nullable().optional().describe("Custom display name; null or empty restores the feed title"),
192
- pollIntervalMinutes: z.number().int().positive().max(10_080).optional(),
193
- fullText: z.enum(["auto", "never"]).optional().describe("auto: the reader may fetch full articles; never: always show the feed content"),
194
- notify: z.boolean().optional().describe("Send push notifications to the user's devices when this feed has new articles"),
195
- badge: z.boolean().optional().describe("Count this feed's unread articles in the number on the app icon"),
205
+ feedId: z.number().int().positive().describe("The numeric ID of the subscribed feed to update"),
206
+ url: mcpUrlSchema.optional().describe("New feed URL or website URL if the feed moved (auto-discovered and validated)"),
207
+ label: z.string().max(200).nullable().optional().describe("Custom display name; pass null or empty string to restore the original feed title"),
208
+ pollIntervalMinutes: z.number().int().positive().max(10_080).optional().describe("Poll interval in minutes (subject to server minimum)"),
209
+ fullText: z.enum(["auto", "never"]).optional().describe("'auto' allows the reader to fetch full articles; 'never' always retains the feed content"),
210
+ notify: z.boolean().optional().describe("Whether to send push notifications to user devices when new articles arrive"),
211
+ badge: z.boolean().optional().describe("Whether to count unread articles from this feed in the app icon badge number"),
196
212
  },
197
213
  }, async ({ feedId, url, label, pollIntervalMinutes, fullText, notify, badge }) => {
198
214
  if (url && !hasUserCapability(userId, "sync"))
@@ -223,9 +239,12 @@ export function createMcpServerForUser(userId, scope) {
223
239
  });
224
240
  if (scope === "write")
225
241
  server.registerTool("rename_folder", {
226
- title: "Rename folder",
227
- description: "Renames one of the user's folders.",
228
- inputSchema: { folderId: z.number().int().positive(), name: z.string().trim().min(1).max(100) },
242
+ title: "Rename a feed folder",
243
+ description: "Renames an existing feed category folder for the current user. Requires write scope. Returns the updated folder record { id, name, position }. Returns error if folderId is not found or name is already taken.",
244
+ inputSchema: {
245
+ folderId: z.number().int().positive().describe("The numeric ID of the folder to rename"),
246
+ name: z.string().trim().min(1).max(100).describe("The new unique display name for the folder (1 to 100 characters)"),
247
+ },
229
248
  }, async ({ folderId, name }) => {
230
249
  if (!findFolderById(userId, folderId))
231
250
  return errorResult("folder_not_found");
@@ -238,27 +257,47 @@ export function createMcpServerForUser(userId, scope) {
238
257
  });
239
258
  if (scope === "write")
240
259
  server.registerTool("delete_folder", {
241
- title: "Delete folder",
242
- description: "Deletes a folder category. Its subscribed feeds remain intact and are moved to the root level (unfiled).",
243
- inputSchema: { folderId: z.number().int().positive() },
260
+ title: "Delete a feed folder",
261
+ description: "Deletes a feed category folder. Subscribed feeds inside the folder remain intact and are moved to the root level (unfiled). Destructive action for the folder organization. Returns { ok: true } on success.",
262
+ inputSchema: {
263
+ folderId: z.number().int().positive().describe("The numeric ID of the folder to delete"),
264
+ },
244
265
  }, async ({ folderId }) => {
245
266
  if (!findFolderById(userId, folderId))
246
267
  return errorResult("folder_not_found");
247
268
  deleteFolder(userId, folderId);
248
269
  return textResult({ ok: true });
249
270
  });
271
+ server.registerTool("get_digest", {
272
+ title: "Digest of recent articles grouped by feed",
273
+ description: "Returns recent articles grouped by subscribed feed with short summaries (newest first). This is the fastest and most token-efficient way to scan what is new. Defaults to unread articles. Do NOT use this tool for pagination, full text, or deep filtering—use list_items for cursor pagination or get_new_items for unread filtering, and follow up with get_item for full article bodies.",
274
+ inputSchema: {
275
+ feedId: z.number().int().positive().optional().describe("Optional feed ID to limit the digest to a single feed"),
276
+ folderId: z.number().int().positive().optional().describe("Optional folder ID to limit the digest to feeds in that folder"),
277
+ unreadOnly: z.boolean().optional().describe("When true (default), includes only unread articles; set false to include read articles"),
278
+ hours: z.number().int().positive().max(720).optional().describe("Only include articles published in the last N hours (e.g. 24)"),
279
+ since: dateInput.optional().describe("Only articles published at or after this ISO date or date-time (overrides hours)"),
280
+ maxItemsPerFeed: z.number().int().positive().max(20).optional().describe("Maximum number of articles to include per feed (default: 5)"),
281
+ snippetChars: z.number().int().positive().max(1000).optional().describe("Maximum character length of each article summary snippet (default: 200)"),
282
+ },
283
+ }, async (args) => textResult(buildDigest(userId, args)));
284
+ server.registerTool("get_overview", {
285
+ title: "Account overview and reading statistics",
286
+ description: "Returns account-wide statistics: total subscribed feeds, total unread articles, saved/bookmarked count, top feeds with the most unread items, folder unread counts, and feeds currently experiencing poll failures. Safe read-only overview.",
287
+ inputSchema: {},
288
+ }, async () => textResult(buildOverview(userId)));
250
289
  server.registerTool("get_new_items", {
251
- title: "Get new feed items",
252
- description: "Returns unread items, optionally filtered by feed, folder, search term, or bookmarks.",
290
+ title: "List unread articles with optional filters",
291
+ description: "Returns a flat list of unread articles matching specified filters (feed, folder, search query, bookmarked status, date range). Use this tool when you specifically need unread articles as a flat list or need article HTML content. Unlike get_digest, articles are flat rather than grouped. Unlike list_items, this tool returns only unread articles and does not use cursors. Follow up with get_item for individual full articles.",
253
292
  inputSchema: {
254
- feedId: z.number().int().positive().optional(),
255
- folderId: z.number().int().positive().optional(),
256
- search: z.string().max(200).optional(),
257
- bookmarkedOnly: z.boolean().optional(),
293
+ feedId: z.number().int().positive().optional().describe("Optional feed ID filter"),
294
+ folderId: z.number().int().positive().optional().describe("Optional folder ID filter"),
295
+ search: z.string().max(200).optional().describe("Optional search phrase to match against title or summary"),
296
+ bookmarkedOnly: z.boolean().optional().describe("When true, only returns unread articles that are bookmarked"),
258
297
  ...publishedRange,
259
- limit: z.number().int().positive().max(200).optional(),
260
- includeContent: z.boolean().optional().describe("Set to false to leave out the article HTML and save tokens (default: true)"),
261
- snippetChars: z.number().int().positive().max(2000).optional().describe("Shorten each item's summary to this many characters"),
298
+ limit: z.number().int().positive().max(200).optional().describe("Maximum number of unread items to return (1 to 200, default: 50)"),
299
+ includeContent: z.boolean().optional().describe("When false, omits article HTML content to save tokens (default: true)"),
300
+ snippetChars: z.number().int().positive().max(2000).optional().describe("Truncate each item summary to this many characters"),
262
301
  },
263
302
  }, async ({ feedId, folderId, search, bookmarkedOnly, since, until, limit, includeContent, snippetChars }) => textResult(listItemsForUser(userId, {
264
303
  feedId, folderId, search, bookmarkedOnly, limit, unreadOnly: true, publishedSince: since, publishedUntil: until,
@@ -267,36 +306,18 @@ export function createMcpServerForUser(userId, scope) {
267
306
  ...(includeContent === false ? {} : { content_html, full_content_html }),
268
307
  content_snippet: snippetChars ? truncate(item.content_snippet, snippetChars) : item.content_snippet,
269
308
  }))));
270
- server.registerTool("get_digest", {
271
- title: "Digest of new articles",
272
- description: "Returns articles grouped by feed with short snippets, newest first: the cheapest way to see what is new. Defaults to unread articles. Use hours (e.g. 24) or since to limit the period, and maxItemsPerFeed / snippetChars to control size. Follow up with get_item for the full article.",
273
- inputSchema: {
274
- feedId: z.number().int().positive().optional(),
275
- folderId: z.number().int().positive().optional(),
276
- unreadOnly: z.boolean().optional().describe("Include read articles too when false (default: true)"),
277
- hours: z.number().int().positive().max(720).optional().describe("Only articles published in the last N hours"),
278
- since: dateInput.optional().describe("Only articles published at or after this ISO date or date-time (overrides hours)"),
279
- maxItemsPerFeed: z.number().int().positive().max(20).optional().describe("Articles listed per feed (default: 5)"),
280
- snippetChars: z.number().int().positive().max(1000).optional().describe("Length of each snippet (default: 200)"),
281
- },
282
- }, async (args) => textResult(buildDigest(userId, args)));
283
- server.registerTool("get_overview", {
284
- title: "Account overview",
285
- description: "Returns counts for the whole account: subscribed feeds, unread and saved articles, the feeds with the most unread articles, folders with their unread counts, and feeds that are failing.",
286
- inputSchema: {},
287
- }, async () => textResult(buildOverview(userId)));
288
309
  server.registerTool("list_items", {
289
- title: "List items with a cursor",
290
- description: "Lists compact article records by time added. Use nextCursor as before to fetch older pages, or newestCursor as after to fetch newly added items. When paging new items, keep the original after cursor while following nextCursor.",
310
+ title: "Paginate items chronologically with cursors",
311
+ description: "Lists articles chronologically with bidirectional cursor-based pagination. Use this tool for comprehensive browsing or historical paging through both read and unread articles. Pass nextCursor as 'before' to page backwards into older history, or newestCursor as 'after' to stream newly added items. Do NOT use for quick digests (use get_digest) or unread-only triage (use get_new_items).",
291
312
  inputSchema: {
292
- feedId: z.number().int().positive().optional(),
293
- folderId: z.number().int().positive().optional(),
294
- unreadOnly: z.boolean().optional(),
295
- bookmarkedOnly: z.boolean().optional(),
296
- before: z.string().max(256).optional(),
297
- after: z.string().max(256).optional(),
313
+ feedId: z.number().int().positive().optional().describe("Optional feed ID filter"),
314
+ folderId: z.number().int().positive().optional().describe("Optional folder ID filter"),
315
+ unreadOnly: z.boolean().optional().describe("When true, only lists unread articles; default is false (all articles)"),
316
+ bookmarkedOnly: z.boolean().optional().describe("When true, only lists bookmarked articles"),
317
+ before: z.string().max(256).optional().describe("Cursor to fetch older items (pass nextCursor from a previous page)"),
318
+ after: z.string().max(256).optional().describe("Cursor to fetch newer items (pass newestCursor from a previous page)"),
298
319
  ...publishedRange,
299
- limit: z.number().int().positive().max(100).optional(),
320
+ limit: z.number().int().positive().max(100).optional().describe("Number of items to fetch per page (1 to 100, default: 20)"),
300
321
  },
301
322
  }, async (args) => {
302
323
  try {
@@ -307,14 +328,14 @@ export function createMcpServerForUser(userId, scope) {
307
328
  }
308
329
  });
309
330
  server.registerTool("get_item", {
310
- title: "Get an article",
311
- description: "Returns one subscribed article, including cached feed or reader content when available. Content is paginated at 40,000 characters; follow nextOffset with offset and the returned content.revision to read every part. Pass maxChars for less.",
331
+ title: "Get single article content and metadata",
332
+ description: "Returns full metadata and stored content (HTML or plain text) for a single subscribed article by its numeric itemId. Content is chunked at 40,000 characters; use offset and content.revision to paginate large articles. If an article only has an RSS teaser/summary and full web text is desired, call fetch_full_text.",
312
333
  inputSchema: {
313
- itemId: z.number().int().positive(),
314
- maxChars: z.number().int().positive().max(40_000).optional().describe("Shorten the content to this many characters"),
315
- format: z.enum(["html", "text"]).optional().describe("Use text to read plain publisher text without HTML markup"),
316
- offset: z.number().int().nonnegative().max(10_000_000).optional(),
317
- revision: z.number().int().positive().optional().describe("Keep pagination on the same content revision"),
334
+ itemId: z.number().int().positive().describe("The numeric ID of the article to retrieve"),
335
+ maxChars: z.number().int().positive().max(40_000).optional().describe("Maximum character length of content to return (up to 40,000)"),
336
+ format: z.enum(["html", "text"]).optional().describe("Format of content: 'html' for sanitized HTML, 'text' for plain text extraction"),
337
+ offset: z.number().int().nonnegative().max(10_000_000).optional().describe("Character offset for reading subsequent chunks of large articles"),
338
+ revision: z.number().int().positive().optional().describe("Revision token returned in previous chunk to ensure pagination consistency"),
318
339
  },
319
340
  }, async ({ itemId, maxChars, offset, revision, format }) => {
320
341
  try {
@@ -327,11 +348,11 @@ export function createMcpServerForUser(userId, scope) {
327
348
  });
328
349
  if (scope === "write")
329
350
  server.registerTool("fetch_full_text", {
330
- title: "Fetch an article's full text",
331
- description: "Downloads the full article from its website when the feed only has a teaser, caches it and returns it. Content is capped at 40,000 characters; use get_item with nextOffset and content.revision for remaining text.",
351
+ title: "Extract full web article text",
352
+ description: "Downloads and extracts the clean, full-length article text from the original publisher website via Readability, permanently caching it on the server and returning it. Use this tool ONLY when get_item indicates that the feed provided only an excerpt or teaser. If full text is already cached, it returns cached content unless force=true is passed.",
332
353
  inputSchema: {
333
- itemId: z.number().int().positive(),
334
- force: z.boolean().optional().describe("Fetch again even when a cached full text exists"),
354
+ itemId: z.number().int().positive().describe("The numeric ID of the article whose full web content should be extracted"),
355
+ force: z.boolean().optional().describe("When true, forces re-downloading and re-extracting from the web even if already cached"),
335
356
  },
336
357
  }, async ({ itemId, force }) => {
337
358
  if (!hasUserCapability(userId, "fulltext"))
@@ -348,29 +369,29 @@ export function createMcpServerForUser(userId, scope) {
348
369
  });
349
370
  });
350
371
  server.registerTool("search_items", {
351
- title: "Search feed items",
352
- description: "Searches item titles and summaries for a phrase across all items the user can access.",
372
+ title: "Search articles by keyword or phrase",
373
+ description: "Searches article titles and summaries using SQLite FTS5 full-text search across all accessible items. Returns matching articles matching the query phrase, with optional feed, folder, bookmark, and date filters. Safe read-only search.",
353
374
  inputSchema: {
354
- query: z.string().min(1).max(200),
355
- feedId: z.number().int().positive().optional(),
356
- folderId: z.number().int().positive().optional(),
357
- bookmarkedOnly: z.boolean().optional(),
375
+ query: z.string().min(1).max(200).describe("The search term or phrase to find in article titles and content summaries"),
376
+ feedId: z.number().int().positive().optional().describe("Optional feed ID filter"),
377
+ folderId: z.number().int().positive().optional().describe("Optional folder ID filter"),
378
+ bookmarkedOnly: z.boolean().optional().describe("When true, restricts search to bookmarked items"),
358
379
  ...publishedRange,
359
- limit: z.number().int().positive().max(200).optional(),
380
+ limit: z.number().int().positive().max(200).optional().describe("Maximum number of search results to return (1 to 200, default: 50)"),
360
381
  },
361
382
  }, async ({ query, feedId, folderId, bookmarkedOnly, since, until, limit }) => textResult(listItemsForUser(userId, {
362
383
  search: query, feedId, folderId, bookmarkedOnly, limit, publishedSince: since, publishedUntil: until,
363
384
  })));
364
385
  const itemActions = [
365
- ["mark_read", "Mark items as read", "Marks one or more subscribed items as read.", markItemRead],
366
- ["mark_unread", "Mark items as unread", "Marks one or more subscribed items as unread.", markItemUnread],
367
- ["bookmark_item", "Bookmark items", "Saves one or more items for later. Saved items keep their full text and images, survive retention cleanup and unsubscribing.", (userId, itemId) => {
386
+ ["mark_read", "Mark articles as read", "Marks one or more subscribed articles as read. Accepts a single itemId or an array of itemIds for batch processing. Idempotent: already-read articles remain read. Returns { ok: true, updated: number } where updated is the count of items that actually transitioned from unread to read.", markItemRead],
387
+ ["mark_unread", "Mark articles as unread", "Marks one or more subscribed articles as unread. Accepts a single itemId or an array of itemIds for batch processing. Idempotent. Returns { ok: true, updated: number } where updated is the count of items that actually transitioned to unread.", markItemUnread],
388
+ ["bookmark_item", "Bookmark articles for later", "Bookmarks (stars) one or more articles for permanent retention. Bookmarked articles retain full text and images and survive automatic retention cleanup and feed unsubscription. Idempotent. Returns { ok: true, updated: number }.", (userId, itemId) => {
368
389
  const changed = bookmarkItem(userId, itemId);
369
390
  if (changed)
370
391
  scheduleArchive(itemId);
371
392
  return changed;
372
393
  }],
373
- ["unbookmark_item", "Remove bookmarks", "Removes the bookmark from one or more items.", (userId, itemId) => {
394
+ ["unbookmark_item", "Remove article bookmarks", "Removes bookmark status from one or more articles. Safely triggers archive pruning for unreferenced cached assets. Idempotent. Returns { ok: true, updated: number }.", (userId, itemId) => {
374
395
  const changed = unbookmarkItem(userId, itemId);
375
396
  if (changed)
376
397
  pruneArchive();
@@ -385,52 +406,55 @@ export function createMcpServerForUser(userId, scope) {
385
406
  const itemIds = selectedItemIds(args);
386
407
  if (itemIds.length === 0)
387
408
  return errorResult("Provide itemId or itemIds");
388
- // `updated` counts items whose state actually changed.
389
409
  return textResult({ ok: true, updated: applyToItems(itemIds, (itemId) => change(userId, itemId)) });
390
410
  });
391
411
  }
392
412
  if (scope === "write")
393
413
  server.registerTool("mark_all_read", {
394
- title: "Mark all items as read",
395
- description: "Marks all subscribed items as read, optionally limited to one feed or folder.",
414
+ title: "Mark all articles as read",
415
+ description: "Marks all unread articles as read in a single operation. Can be scoped to a single feed or an entire folder. Idempotent. Returns { marked: number } with the count of newly read items.",
396
416
  inputSchema: {
397
- feedId: z.number().int().positive().optional(),
398
- folderId: z.number().int().positive().optional(),
417
+ feedId: z.number().int().positive().optional().describe("Optional feed ID to limit the mark-all-read operation to one feed"),
418
+ folderId: z.number().int().positive().optional().describe("Optional folder ID to limit the mark-all-read operation to one folder"),
399
419
  },
400
420
  }, async ({ feedId, folderId }) => hasUserCapability(userId, "sync")
401
421
  ? textResult({ marked: markAllRead(userId, { feedId, folderId }) })
402
422
  : { ...textResult(capabilityDenial(userId, "sync")), isError: true });
403
423
  server.registerTool("list_muted_keywords", {
404
424
  title: "List muted keywords",
405
- description: "Lists all muted keywords configured for the current user.",
425
+ description: "Lists all keyword filters configured for the current user. Articles matching any active muted keyword are automatically filtered out from new item views and newspaper editions. Safe read-only.",
406
426
  inputSchema: {},
407
427
  }, async () => textResult(listMutedKeywords(userId)));
408
428
  if (scope === "write")
409
429
  server.registerTool("add_muted_keyword", {
410
- title: "Add muted keyword",
411
- description: "Mutes a keyword. Articles containing this keyword will be filtered out from your feed.",
412
- inputSchema: { keyword: z.string().min(1).max(100) },
430
+ title: "Add a muted keyword filter",
431
+ description: "Adds a new keyword filter rule. Articles whose title or summary contains this keyword (case-insensitive) will be suppressed from feeds and editions. Requires write scope. Returns the created keyword rule { id, keyword, created_at }.",
432
+ inputSchema: {
433
+ keyword: z.string().trim().min(1).max(100).describe("The keyword phrase to filter out from feeds and editions (1 to 100 characters)"),
434
+ },
413
435
  }, async ({ keyword }) => textResult(addMutedKeyword(userId, keyword)));
414
436
  if (scope === "write")
415
437
  server.registerTool("unmute_keyword", {
416
- title: "Unmute keyword",
417
- description: "Unmutes a previously muted keyword by its ID (removes the keyword filter rule).",
418
- inputSchema: { keywordId: z.number().int().positive() },
438
+ title: "Remove a muted keyword filter",
439
+ description: "Removes an existing muted keyword filter by its numeric keywordId. Future and existing articles matching this keyword will once again be visible. Returns { ok: true } on success.",
440
+ inputSchema: {
441
+ keywordId: z.number().int().positive().describe("The numeric ID of the muted keyword rule to remove"),
442
+ },
419
443
  }, async ({ keywordId }) => {
420
444
  removeMutedKeyword(userId, keywordId);
421
445
  return textResult({ ok: true });
422
446
  });
423
447
  server.registerTool("export_opml", {
424
- title: "Export feeds as OPML",
425
- description: "Exports all subscribed feeds of the current user as an OPML 2.0 XML string.",
448
+ title: "Export feeds as OPML XML",
449
+ description: "Exports all subscribed feeds and folder structures of the current user as an OPML 2.0 XML document. Safe read-only operation.",
426
450
  inputSchema: {},
427
451
  }, async () => ({ content: [{ type: "text", text: generateOpml(userId) }] }));
428
452
  if (scope === "write")
429
453
  server.registerTool("import_opml", {
430
- title: "Import feeds from OPML",
431
- description: "Imports feeds from an OPML 2.0 XML string for the current user.",
454
+ title: "Import feeds from OPML XML",
455
+ description: "Imports feed subscriptions and folders from an OPML 2.0 XML string for the current user. Existing subscriptions are preserved. Requires write scope. Returns { imported: number, failed: number, foldersCreated: number }.",
432
456
  inputSchema: {
433
- opml: z.string().min(1).describe("The OPML XML content to import"),
457
+ opml: z.string().min(1).describe("The OPML 2.0 XML document string to parse and import"),
434
458
  },
435
459
  }, async ({ opml }) => {
436
460
  if (!hasUserCapability(userId, "sync"))
@@ -445,10 +469,10 @@ export function createMcpServerForUser(userId, scope) {
445
469
  });
446
470
  if (scope === "write")
447
471
  server.registerTool("refresh_feed", {
448
- title: "Refresh a feed",
449
- description: "Requests an update of a subscribed feed and returns its health. Respects source pauses; deferred=true means work is still pending.",
472
+ title: "Refresh feed poll",
473
+ description: "Requests an immediate poll of a subscribed feed from its origin URL and returns its updated health status, number of new items found, and error state. Respects origin HTTP cache headers and backoff pauses. Returns { success: boolean, newItems: number, error: string | null, deferred: boolean, retryAt: string | null, feed: object }.",
450
474
  inputSchema: {
451
- feedId: z.number().int().positive().describe("The ID of the feed to refresh"),
475
+ feedId: z.number().int().positive().describe("The numeric ID of the subscribed feed to refresh"),
452
476
  },
453
477
  }, async ({ feedId }) => {
454
478
  if (!hasUserCapability(userId, "sync"))
@@ -488,53 +512,32 @@ export function createMcpServerForUser(userId, scope) {
488
512
  return { ...textResult(capabilityDenial(userId, capability)), isError: true };
489
513
  return editionAction(action);
490
514
  };
491
- server.registerTool("get_native_preferences", {
492
- title: "Get native reading preferences",
493
- description: "Returns the user's app-only folder order, newspaper exclusions, preferred sections, time zone and edition size. These settings do not change the web reader.",
494
- inputSchema: {},
495
- }, async () => textResult(getNativePreferences(userId)));
496
515
  server.registerTool("get_edition", {
497
- title: "Get current edition",
498
- description: "Returns the authoritative edition state and revision, including when absent, expired or dismissed. Call before publishing with expectedRevision.",
516
+ title: "Get current curated newspaper edition",
517
+ description: "Returns the authoritative edition state, publication metadata, article list, and revision number for the user's curated newspaper edition ('Deine Zeitung'). Returns the current revision (even if empty, expired, or dismissed), which must be passed as expectedRevision when calling publish_edition. Safe read-only.",
499
518
  inputSchema: {},
500
519
  }, async () => textResult(getEditionState(userId)));
501
520
  server.registerTool("get_edition_candidates", {
502
- title: "Get edition candidates",
503
- description: "Returns a bounded shortlist of unread articles from the last seven days, respecting muted keywords and app-only section visibility. Includes the current revision and user preferences. Includes sourceName and folderName. Use get_item to inspect selected articles, then publish_edition with expectedRevision and a stable requestId.",
504
- inputSchema: { limit: z.number().int().min(1).max(200).default(100) },
521
+ title: "Get candidate articles for newspaper curation",
522
+ description: "Use this tool ONLY when preparing to curate a newspaper edition with publish_edition. Returns a bounded shortlist of unread articles from the last 7 days scored for editorial curation, user reading preferences, and current revision. Do NOT use for general reading or browsing (use get_digest or get_new_items instead).",
523
+ inputSchema: {
524
+ limit: z.number().int().min(1).max(200).default(100).describe("Maximum number of candidate articles to evaluate (1 to 200, default: 100)"),
525
+ },
505
526
  }, async ({ limit }) => capabilityAction("editions", () => ({ preferences: getNativePreferences(userId), current: getEditionState(userId), candidates: editionCandidates(userId, new Date(), limit) })));
506
- if (scope === "write")
507
- server.registerTool("update_native_preferences", {
508
- title: "Update native reading preferences",
509
- description: "Patches app-only preferences using expectedRevision and a UUID requestId. Retried requests return their original result; conflicts include the current settings. Folder IDs must belong to the current user. Never changes the web folder list or stream.",
510
- inputSchema: preferencePatchSchema.shape,
511
- }, async (input) => capabilityAction("sync", () => patchNativePreferences(userId, input)));
512
527
  if (scope === "write")
513
528
  server.registerTool("publish_edition", {
514
- title: "Publish curated edition",
515
- description: "Publishes an ordered list of 1 to 24 accessible article IDs. The latest curated edition stays readable until another is published; expiry (default 24 hours, maximum seven days) controls when a new publication is due. App-only hidden sections and muted keywords are respected. Supply the revision from get_edition as expectedRevision and a UUID requestId for conflict detection and safe retries. Optional title and summary are editorial text; original articles stay unchanged. Optional layout (version 1) says how the issue is set: a character (dominant, calm or briefing) and blocks (lead, dossier, feature, standard, briefs, photo, quote) that reference the issue's article IDs at most once each; it never changes the articles.",
529
+ title: "Publish curated newspaper edition",
530
+ description: "Publishes an ordered selection of 1 to 24 article IDs as the user's official curated edition ('Deine Zeitung'). The published edition remains available until the next edition is published or expires. Pass the revision from get_edition as expectedRevision for optimistic concurrency, and a UUID requestId for idempotent retries. Does NOT alter underlying articles. Requires write scope.",
516
531
  inputSchema: publishEditionFields,
517
532
  }, async (input) => capabilityAction("editions", () => publishCuratedEdition(userId, input)));
518
- if (scope === "write")
519
- server.registerTool("generate_edition", {
520
- title: "Get the latest curated edition",
521
- description: "Compatibility alias for reading the latest curated publication. It never selects articles or publishes an edition. force is accepted for older clients but does not create a replacement; use publish_edition to publish a new curated selection.",
522
- inputSchema: ensureEditionSchema.shape,
523
- }, async (input) => capabilityAction("editions", () => {
524
- const parsed = ensureEditionSchema.safeParse(input);
525
- if (!parsed.success)
526
- throw new NativeError("invalid_input");
527
- const current = getEditionState(userId);
528
- if (parsed.data.expectedRevision !== undefined && parsed.data.expectedRevision !== current.revision) {
529
- throw new NativeError("revision_conflict", 409, current);
530
- }
531
- return { edition: getEdition(userId), current };
532
- }));
533
533
  if (scope === "write")
534
534
  server.registerTool("dismiss_edition", {
535
- title: "Dismiss the current edition",
536
- description: "Explicitly dismisses the current edition, including curated issues, using a revision and stable UUID requestId. Automatic scheduling waits until the next time slot; generate_edition with force=true can start a new issue immediately.",
537
- inputSchema: { requestId: z.uuid(), expectedRevision: z.number().int().min(0) },
535
+ title: "Dismiss the current newspaper edition",
536
+ description: "Explicitly dismisses the current curated edition so it is no longer shown as active. Requires a UUID requestId and the current revision as expectedRevision for conflict detection. Requires write scope. Returns { ok: true } on success.",
537
+ inputSchema: {
538
+ requestId: z.uuid().describe("Unique idempotency UUID for this dismiss operation"),
539
+ expectedRevision: z.number().int().min(0).describe("The current edition revision number obtained from get_edition"),
540
+ },
538
541
  }, async (input) => editionAction(() => dismissEdition(userId, input)));
539
542
  registerPromptsAndResources(server, userId, scope);
540
543
  return server;
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env node
2
+ import { existsSync } from "node:fs";
3
+ import { resolve } from "node:path";
4
+ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
5
+ import { prepareEnvironment } from "./cli.js";
6
+ // Ensure stdout is exclusively reserved for MCP JSON-RPC messages.
7
+ console.log = console.error;
8
+ console.info = console.error;
9
+ export async function runMcpStdio() {
10
+ const envFile = resolve(process.cwd(), ".env");
11
+ if (existsSync(envFile))
12
+ process.loadEnvFile(envFile);
13
+ prepareEnvironment({ action: "start", forwarded: [] }, process.env);
14
+ const { runMigrations } = await import("./db/index.js");
15
+ runMigrations();
16
+ const { getOrCreateDefaultUser } = await import("./auth/users.js");
17
+ const { createMcpServerForUser } = await import("./mcp/server.js");
18
+ const user = getOrCreateDefaultUser();
19
+ const server = createMcpServerForUser(user.id, "write");
20
+ const transport = new StdioServerTransport();
21
+ await server.connect(transport);
22
+ }
23
+ if (import.meta.url === `file://${process.argv[1]}` || process.argv[1]?.endsWith("mcp-stdio.js")) {
24
+ runMcpStdio().catch((error) => {
25
+ console.error("mcp-stdio error:", error);
26
+ process.exit(1);
27
+ });
28
+ }
29
+ //# sourceMappingURL=mcp-stdio.js.map