devrant-mcp 1.0.5 → 1.0.6
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/dist/api.js +31 -0
- package/dist/server.js +2 -3
- package/package.json +2 -2
- package/server.json +2 -2
package/dist/api.js
CHANGED
|
@@ -127,3 +127,34 @@ export async function rantDigest(args = {}) {
|
|
|
127
127
|
lines.push(' every figure above is tallied from the rants on this one page, not from a stored summary.');
|
|
128
128
|
return lines.join('\n');
|
|
129
129
|
}
|
|
130
|
+
|
|
131
|
+
const DEVRANT = 'https://devrant.com/api/devrant';
|
|
132
|
+
export async function rantDetails(args = {}) {
|
|
133
|
+
const id = Number(args?.rant_id);
|
|
134
|
+
if (!Number.isInteger(id) || id < 1)
|
|
135
|
+
throw new Error('Provide a rant id, like 194632.');
|
|
136
|
+
const app = Number(args?.app ?? 3) || 3;
|
|
137
|
+
const res = await fetch(`${DEVRANT}/rants/${id}?app=${app}&sort=algo`, {
|
|
138
|
+
headers: { 'User-Agent': 'mrfentmen-devrant-mcp/1.0', Accept: 'application/json' },
|
|
139
|
+
signal: AbortSignal.timeout(25000),
|
|
140
|
+
});
|
|
141
|
+
if (!res.ok)
|
|
142
|
+
throw new Error(`devRant returned ${res.status}`);
|
|
143
|
+
const body = (await res.json());
|
|
144
|
+
if (body.error || !body.rant)
|
|
145
|
+
throw new Error(`devRant has no rant ${id}`);
|
|
146
|
+
const r = body.rant;
|
|
147
|
+
const comments = Array.isArray(body.comments) ? body.comments : [];
|
|
148
|
+
return [
|
|
149
|
+
`Rant ${r.id} by ${r.user_username ?? 'unknown'} (author score ${r.user_score ?? '?'})`,
|
|
150
|
+
`Score: ${r.score ?? '?'} · comments: ${r.num_comments ?? comments.length} · posted ${new Date(Number(r.created_time) * 1000).toISOString().slice(0, 10)}`,
|
|
151
|
+
`Tags: ${(r.tags ?? []).join(', ') || 'none'}${r.edited ? ' · edited' : ''}${r.attached_image ? ` · image ${r.attached_image}` : ''}`,
|
|
152
|
+
(r.links ?? []).length ? `Links: ${r.links.join(', ')}` : '',
|
|
153
|
+
'',
|
|
154
|
+
String(r.text ?? '').trim(),
|
|
155
|
+
'',
|
|
156
|
+
comments.length ? `${comments.length} comment(s):` : 'No comments loaded.',
|
|
157
|
+
...comments.slice(0, 8).map((c) => `- ${c.user_username ?? 'anon'} (score ${c.score ?? '?'}): ${String(c.body ?? '').replace(/\s+/g, ' ').slice(0, 160)}`),
|
|
158
|
+
`https://devrant.com/rants/${r.id}`,
|
|
159
|
+
].filter(Boolean).join('\n');
|
|
160
|
+
}
|
package/dist/server.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
2
|
import { z } from "zod";
|
|
3
|
-
import { rants, rantDigest } from "./api.js";
|
|
3
|
+
import { rants, rantDigest, rantDetails } from "./api.js";
|
|
4
4
|
const text = (value) => ({ content: [{ type: "text", text: value }] });
|
|
5
5
|
const textError = (t) => ({ content: [{ type: "text", text: t }], isError: true });
|
|
6
6
|
const READ_ONLY = { readOnlyHint: true, openWorldHint: true };
|
|
@@ -26,9 +26,8 @@ export function createServer() {
|
|
|
26
26
|
inputSchema: z.object({ rant_id: z.number().describe("Rant id, like 194632."), app: z.number().describe("devRant app id, 3 is the public one.").optional() }),
|
|
27
27
|
annotations: READ_ONLY,
|
|
28
28
|
}, async (args) => {
|
|
29
|
-
// TODO: implement details locally (paywall removed)
|
|
30
29
|
try {
|
|
31
|
-
return
|
|
30
|
+
return text(await rantDetails(args));
|
|
32
31
|
}
|
|
33
32
|
catch (e) {
|
|
34
33
|
return textError(String(e));
|
package/package.json
CHANGED
package/server.json
CHANGED
|
@@ -6,12 +6,12 @@
|
|
|
6
6
|
"url": "https://github.com/mrfentmen/devrant-mcp",
|
|
7
7
|
"source": "github"
|
|
8
8
|
},
|
|
9
|
-
"version": "1.0.
|
|
9
|
+
"version": "1.0.6",
|
|
10
10
|
"packages": [
|
|
11
11
|
{
|
|
12
12
|
"registryType": "npm",
|
|
13
13
|
"identifier": "devrant-mcp",
|
|
14
|
-
"version": "1.0.
|
|
14
|
+
"version": "1.0.6",
|
|
15
15
|
"transport": {
|
|
16
16
|
"type": "stdio"
|
|
17
17
|
}
|