@mrfentmen/rss-mcp 1.0.0 → 1.0.2
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/README.md +18 -0
- package/dist/api.js +52 -0
- package/dist/license.js +79 -0
- package/dist/server.js +38 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -17,3 +17,21 @@ npm run build
|
|
|
17
17
|
node dist/index.js
|
|
18
18
|
```
|
|
19
19
|
|
|
20
|
+
<!-- paywall -->
|
|
21
|
+
## Premium tools
|
|
22
|
+
|
|
23
|
+
These tools need a license key:
|
|
24
|
+
|
|
25
|
+
* `search_feed`
|
|
26
|
+
* `feed_info`
|
|
27
|
+
|
|
28
|
+
Buy a key at https://mcp-marketplace.io/server/io-github-mrfentmen-rss-mcp and set it in your MCP client config:
|
|
29
|
+
|
|
30
|
+
```json
|
|
31
|
+
"env": { "MCP_LICENSE_KEY": "mcp_live_..." }
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
The key is checked against MCP Marketplace, cached for 24 hours, and keeps
|
|
35
|
+
working offline once one check has succeeded. Every other tool on this server
|
|
36
|
+
stays free.
|
|
37
|
+
<!-- /paywall -->
|
package/dist/api.js
CHANGED
|
@@ -71,3 +71,55 @@ export async function feedJson(args) {
|
|
|
71
71
|
.map((item, i) => `${i + 1}. ${item.title ?? 'untitled'} | ${(item.pubDate ?? '').slice(0, 16)}${item.link ? `\n ${item.link}` : ''}`)
|
|
72
72
|
.join('\n');
|
|
73
73
|
}
|
|
74
|
+
// ---- muxC tools:
|
|
75
|
+
const RSS_UA = "mrfentmen-rss-mcp/1.0 (https://github.com/mrfentmen)";
|
|
76
|
+
class Rss2JsonError extends Error {
|
|
77
|
+
}
|
|
78
|
+
/** rss2json is a free public endpoint, so the feed is read the same way its siblings are. */
|
|
79
|
+
async function feed(rssUrl, limit) {
|
|
80
|
+
const res = await fetch(`https://api.rss2json.com/v1/api.json?rss_url=${encodeURIComponent(rssUrl)}&count=${limit}`, {
|
|
81
|
+
headers: { "User-Agent": RSS_UA, Accept: "application/json" },
|
|
82
|
+
signal: AbortSignal.timeout(30000),
|
|
83
|
+
});
|
|
84
|
+
if (!res.ok)
|
|
85
|
+
throw new Rss2JsonError(`rss2json returned ${res.status} for that feed`);
|
|
86
|
+
const d = (await res.json());
|
|
87
|
+
if (d.status !== "ok")
|
|
88
|
+
throw new Rss2JsonError(`rss2json could not read that feed: ${d.message ?? d.status}`);
|
|
89
|
+
return d;
|
|
90
|
+
}
|
|
91
|
+
/** Find items across a feed by word, which is how you pull one story out of a busy site. */
|
|
92
|
+
export async function searchFeed(args) {
|
|
93
|
+
const url = (args.url ?? "").trim();
|
|
94
|
+
if (!url)
|
|
95
|
+
throw new Rss2JsonError("Provide the feed url to search");
|
|
96
|
+
const query = (args.query ?? "").trim().toLowerCase();
|
|
97
|
+
if (!query)
|
|
98
|
+
throw new Rss2JsonError("Provide a word or phrase to look for in the feed's items");
|
|
99
|
+
const limit = Math.max(1, Math.min(args.limit ?? 20, 100));
|
|
100
|
+
const d = await feed(url, Math.min(limit * 3, 100));
|
|
101
|
+
const items = d.items ?? [];
|
|
102
|
+
const hits = items.filter((i) => `${i.title ?? ""} ${i.description ?? ""} ${i.content ?? ""}`.toLowerCase().includes(query));
|
|
103
|
+
if (!hits.length)
|
|
104
|
+
return `None of ${items.length} items in ${d.title ?? url} mention "${query}".`;
|
|
105
|
+
return `${hits.length} of ${items.length} items in ${d.title ?? url} mention "${query}":\n` +
|
|
106
|
+
hits.slice(0, limit).map((i, n) => `${n + 1}. ${String(i.title ?? "untitled").replace(/<[^>]*>/g, " ").replace(/\s+/g, " ").trim()}\n ${String(i.pubDate ?? "").slice(0, 25)}\n ${i.link ?? ""}`).join("\n");
|
|
107
|
+
}
|
|
108
|
+
/** A feed's own metadata and channel image, which the item list does not show. */
|
|
109
|
+
export async function feedInfo(args) {
|
|
110
|
+
const url = (args.url ?? "").trim();
|
|
111
|
+
if (!url)
|
|
112
|
+
throw new Rss2JsonError("Provide a feed url to describe");
|
|
113
|
+
const d = await feed(url, 1);
|
|
114
|
+
return [
|
|
115
|
+
`Feed: ${d.title ?? "untitled"}`,
|
|
116
|
+
d.description ? `about: ${String(d.description).replace(/<[^>]*>/g, " ").replace(/\s+/g, " ").trim().slice(0, 300)}` : null,
|
|
117
|
+
d.link ? `site: ${d.link}` : null,
|
|
118
|
+
d.feedUrl ? `feed url: ${d.feedUrl}` : null,
|
|
119
|
+
d.image ? `image: ${d.image}` : null,
|
|
120
|
+
`items available: ${d.items?.length ?? 0} (rss2json caps a single call at 100)`,
|
|
121
|
+
d.copyright ? `copyright: ${d.copyright}` : null,
|
|
122
|
+
]
|
|
123
|
+
.filter(Boolean)
|
|
124
|
+
.join("\n");
|
|
125
|
+
}
|
package/dist/license.js
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
// Premium tools on this server need a license key bought from MCP Marketplace.
|
|
2
|
+
// Buyers put the key in their MCP client config as MCP_LICENSE_KEY. Every tool
|
|
3
|
+
// that is not listed in PREMIUM keeps working without a key.
|
|
4
|
+
const SLUG = "rss-mcp";
|
|
5
|
+
// Tools that need a key. Everything else is free.
|
|
6
|
+
const PREMIUM = new Set([
|
|
7
|
+
"search_feed",
|
|
8
|
+
"feed_info",
|
|
9
|
+
]);
|
|
10
|
+
const BUY_URL = `https://mcp-marketplace.io/server/io-github-mrfentmen-${SLUG}`;
|
|
11
|
+
// The license check calls the marketplace's verify endpoint directly instead of
|
|
12
|
+
// using @mcp_marketplace/license. That SDK sends no `apikey` header, so every
|
|
13
|
+
// check it makes is rejected by Supabase before it reaches the function. The
|
|
14
|
+
// publishable key below is public by design - it ships in mcp-marketplace.io's
|
|
15
|
+
// own JavaScript and only ever reaches their licence check.
|
|
16
|
+
const DEFAULT_VERIFY_URL = "https://virupvwhtkpkjsiskckg.supabase.co/functions/v1/verify-key";
|
|
17
|
+
const PUBLISHABLE_KEY = "sb_publishable_BuqlW96Ke8C_zzJG-LQv1Q_YHi_r_4h";
|
|
18
|
+
const OK_CACHE_MS = 60 * 60 * 1000;
|
|
19
|
+
const BAD_CACHE_MS = 60 * 1000;
|
|
20
|
+
const seen = new Map();
|
|
21
|
+
const REASONS = {
|
|
22
|
+
missing_key: "no key is set",
|
|
23
|
+
invalid_format: "that key is not a valid MCP Marketplace key",
|
|
24
|
+
not_found: "that key was not found",
|
|
25
|
+
revoked: "that key has been revoked",
|
|
26
|
+
rotated: "that key was rotated, use your new one",
|
|
27
|
+
expired: "that key has expired, renew it",
|
|
28
|
+
rate_limited: "there were too many checks just now, try again shortly",
|
|
29
|
+
network_error: "the license server could not be reached",
|
|
30
|
+
};
|
|
31
|
+
function blocked(tool, reason) {
|
|
32
|
+
const why = REASONS[reason] ?? `the license server answered "${reason}"`;
|
|
33
|
+
return `"${tool}" needs a license key, but ${why}. ` +
|
|
34
|
+
`Set MCP_LICENSE_KEY in your MCP client config. Get a key: ${BUY_URL}`;
|
|
35
|
+
}
|
|
36
|
+
async function verify(key) {
|
|
37
|
+
const res = await fetch(process.env.MCP_LICENSE_VERIFY_URL || DEFAULT_VERIFY_URL, {
|
|
38
|
+
method: "POST",
|
|
39
|
+
headers: {
|
|
40
|
+
apikey: PUBLISHABLE_KEY,
|
|
41
|
+
Authorization: `Bearer ${PUBLISHABLE_KEY}`,
|
|
42
|
+
"Content-Type": "application/json",
|
|
43
|
+
},
|
|
44
|
+
body: JSON.stringify({ key, slug: SLUG }),
|
|
45
|
+
// an unusable key answers 400 with a JSON body, so read the body either way
|
|
46
|
+
signal: AbortSignal.timeout(15000),
|
|
47
|
+
});
|
|
48
|
+
const data = (await res.json());
|
|
49
|
+
if (typeof data?.valid !== "boolean")
|
|
50
|
+
return { valid: false, reason: "unexpected_response" };
|
|
51
|
+
return data;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Returns null when the caller may run the tool, or a short message telling
|
|
55
|
+
* them how to get a key.
|
|
56
|
+
*
|
|
57
|
+
* A good key is remembered for an hour, so a busy session does not hit the
|
|
58
|
+
* license server on every call and keeps working through a brief outage.
|
|
59
|
+
*/
|
|
60
|
+
export async function premiumRequired(tool) {
|
|
61
|
+
if (!PREMIUM.has(tool))
|
|
62
|
+
return null;
|
|
63
|
+
const key = process.env.MCP_LICENSE_KEY;
|
|
64
|
+
if (!key)
|
|
65
|
+
return blocked(tool, "missing_key");
|
|
66
|
+
const hit = seen.get(key);
|
|
67
|
+
if (hit && Date.now() - hit.at < (hit.valid ? OK_CACHE_MS : BAD_CACHE_MS)) {
|
|
68
|
+
return hit.valid ? null : blocked(tool, hit.reason ?? "invalid");
|
|
69
|
+
}
|
|
70
|
+
let result;
|
|
71
|
+
try {
|
|
72
|
+
result = await verify(key);
|
|
73
|
+
}
|
|
74
|
+
catch {
|
|
75
|
+
result = { valid: false, reason: "network_error" };
|
|
76
|
+
}
|
|
77
|
+
seen.set(key, { ...result, at: Date.now() });
|
|
78
|
+
return result.valid ? null : blocked(tool, result.reason ?? "invalid");
|
|
79
|
+
}
|
package/dist/server.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
2
|
import { z } from 'zod';
|
|
3
|
-
import { readFeed, feedJson } from './api.js';
|
|
3
|
+
import { readFeed, feedJson, searchFeed, feedInfo } from './api.js';
|
|
4
|
+
import { premiumRequired } from "./license.js";
|
|
4
5
|
const text = (value) => ({ content: [{ type: 'text', text: value }] });
|
|
5
6
|
const textError = (t) => ({ content: [{ type: "text", text: t }], isError: true });
|
|
6
7
|
const READ_ONLY = { readOnlyHint: true, openWorldHint: true };
|
|
@@ -33,5 +34,41 @@ export function createServer() {
|
|
|
33
34
|
return textError(error(e));
|
|
34
35
|
}
|
|
35
36
|
});
|
|
37
|
+
server.registerTool("search_feed", {
|
|
38
|
+
title: "Search feed",
|
|
39
|
+
description: "Find items inside an RSS feed by word or phrase, which is how you pull one story out of a busy site instead of reading the whole feed.",
|
|
40
|
+
inputSchema: z.object({ url: z.string().describe("Feed url."), query: z.string().describe("Word or phrase to look for."), limit: z.number().describe("Max matches.").optional() }),
|
|
41
|
+
annotations: READ_ONLY,
|
|
42
|
+
}, async (args) => {
|
|
43
|
+
// ---- paywall: search_feed ----
|
|
44
|
+
const paywallMessage = await premiumRequired("search_feed");
|
|
45
|
+
if (paywallMessage)
|
|
46
|
+
return { content: [{ type: "text", text: paywallMessage }], isError: true };
|
|
47
|
+
// ---- paywall: end ----
|
|
48
|
+
try {
|
|
49
|
+
return text(await searchFeed(args));
|
|
50
|
+
}
|
|
51
|
+
catch (e) {
|
|
52
|
+
return textError(error(e));
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
server.registerTool("feed_info", {
|
|
56
|
+
title: "Feed info",
|
|
57
|
+
description: "A feed's own channel metadata: title, description, site link, image and item count, which reading its items does not show.",
|
|
58
|
+
inputSchema: z.object({ url: z.string().describe("Feed url."), }),
|
|
59
|
+
annotations: READ_ONLY,
|
|
60
|
+
}, async (args) => {
|
|
61
|
+
// ---- paywall: feed_info ----
|
|
62
|
+
const paywallMessage = await premiumRequired("feed_info");
|
|
63
|
+
if (paywallMessage)
|
|
64
|
+
return { content: [{ type: "text", text: paywallMessage }], isError: true };
|
|
65
|
+
// ---- paywall: end ----
|
|
66
|
+
try {
|
|
67
|
+
return text(await feedInfo(args));
|
|
68
|
+
}
|
|
69
|
+
catch (e) {
|
|
70
|
+
return textError(error(e));
|
|
71
|
+
}
|
|
72
|
+
});
|
|
36
73
|
return server;
|
|
37
74
|
}
|
package/package.json
CHANGED