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.
- package/package.json +1 -1
- package/server/dist/auth/users.js +13 -0
- package/server/dist/cli.js +4 -0
- package/server/dist/feedkeeper.js +5 -0
- package/server/dist/mcp/server.js +162 -159
- package/server/dist/mcp-stdio.js +29 -0
- package/server/dist/native/editions.js +9 -9
- package/server/package.json +1 -1
- package/web/dist/assets/index-DQ0jYGch.js +32 -0
- package/web/dist/index.html +1 -1
- package/web/dist/sw.js +1 -1
- package/web/dist/assets/index-CilgZLF5.js +0 -32
|
@@ -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,
|
|
17
|
-
import { getNativePreferences
|
|
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("
|
|
29
|
-
until: dateInput.optional().describe("
|
|
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("
|
|
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("
|
|
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
|
-
|
|
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
|
|
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
|
|
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: {
|
|
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
|
|
166
|
-
inputSchema: {
|
|
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: "
|
|
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
|
|
191
|
-
label: z.string().max(200).nullable().optional().describe("Custom display name; null or empty
|
|
192
|
-
pollIntervalMinutes: z.number().int().positive().max(10_080).optional(),
|
|
193
|
-
fullText: z.enum(["auto", "never"]).optional().describe("auto
|
|
194
|
-
notify: z.boolean().optional().describe("
|
|
195
|
-
badge: z.boolean().optional().describe("
|
|
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
|
|
228
|
-
inputSchema: {
|
|
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
|
|
243
|
-
inputSchema: {
|
|
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: "
|
|
252
|
-
description: "Returns unread
|
|
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("
|
|
261
|
-
snippetChars: z.number().int().positive().max(2000).optional().describe("
|
|
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: "
|
|
290
|
-
description: "Lists
|
|
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
|
|
311
|
-
description: "Returns
|
|
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("
|
|
315
|
-
format: z.enum(["html", "text"]).optional().describe("
|
|
316
|
-
offset: z.number().int().nonnegative().max(10_000_000).optional(),
|
|
317
|
-
revision: z.number().int().positive().optional().describe("
|
|
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: "
|
|
331
|
-
description: "Downloads the full article from
|
|
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("
|
|
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
|
|
352
|
-
description: "Searches
|
|
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
|
|
366
|
-
["mark_unread", "Mark
|
|
367
|
-
["bookmark_item", "Bookmark
|
|
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
|
|
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
|
|
395
|
-
description: "Marks all
|
|
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
|
|
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: "
|
|
412
|
-
inputSchema: {
|
|
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: "
|
|
417
|
-
description: "
|
|
418
|
-
inputSchema: {
|
|
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
|
|
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
|
|
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
|
|
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
|
|
449
|
-
description: "Requests an
|
|
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
|
|
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
|
|
503
|
-
description: "Returns a bounded shortlist of unread articles from the last
|
|
504
|
-
inputSchema: {
|
|
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
|
|
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
|
|
537
|
-
inputSchema: {
|
|
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
|