reddit-mcp-server 1.0.3 → 1.0.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/dist/bin.d.ts +1 -0
- package/dist/bin.js +1098 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +1107 -0
- package/package.json +1 -1
- package/src/bin.ts +3 -3
- package/src/client/reddit-client.ts +8 -8
- package/src/index.ts +7 -6
- package/src/tools/post-tools.ts +4 -4
- package/src/tools/subreddit-tools.ts +2 -2
- package/src/tools/user-tools.ts +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "reddit-mcp-server",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4",
|
|
4
4
|
"description": "A Model Context Protocol (MCP) that provides tools for fetching and creating Reddit content. Fork of the alexandros-lekkas/reddit-mcp-server.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"bin": {
|
package/src/bin.ts
CHANGED
|
@@ -78,7 +78,7 @@ export class RedditClient {
|
|
|
78
78
|
this.api.defaults.headers.common["Authorization"] = `Bearer ${this.accessToken}`
|
|
79
79
|
|
|
80
80
|
// Successfully authenticated with Reddit API
|
|
81
|
-
} catch
|
|
81
|
+
} catch {
|
|
82
82
|
// Authentication error occurred
|
|
83
83
|
throw new Error("Failed to authenticate with Reddit API")
|
|
84
84
|
}
|
|
@@ -114,7 +114,7 @@ export class RedditClient {
|
|
|
114
114
|
createdUtc: data.created_utc,
|
|
115
115
|
profileUrl: `https://reddit.com/user/${data.name}`,
|
|
116
116
|
}
|
|
117
|
-
} catch
|
|
117
|
+
} catch {
|
|
118
118
|
// Failed to get user info
|
|
119
119
|
throw new Error(`Failed to get user info for ${username}`)
|
|
120
120
|
}
|
|
@@ -138,7 +138,7 @@ export class RedditClient {
|
|
|
138
138
|
subredditType: data.subreddit_type,
|
|
139
139
|
url: data.url,
|
|
140
140
|
}
|
|
141
|
-
} catch
|
|
141
|
+
} catch {
|
|
142
142
|
// Failed to get subreddit info
|
|
143
143
|
throw new Error(`Failed to get subreddit info for ${subredditName}`)
|
|
144
144
|
}
|
|
@@ -176,7 +176,7 @@ export class RedditClient {
|
|
|
176
176
|
permalink: post.permalink,
|
|
177
177
|
}
|
|
178
178
|
})
|
|
179
|
-
} catch
|
|
179
|
+
} catch {
|
|
180
180
|
// Failed to get top posts
|
|
181
181
|
throw new Error(`Failed to get top posts for ${subreddit || "home"}`)
|
|
182
182
|
}
|
|
@@ -219,7 +219,7 @@ export class RedditClient {
|
|
|
219
219
|
linkFlairText: post.link_flair_text,
|
|
220
220
|
permalink: post.permalink,
|
|
221
221
|
}
|
|
222
|
-
} catch
|
|
222
|
+
} catch {
|
|
223
223
|
// Failed to get post
|
|
224
224
|
throw new Error(`Failed to get post with ID ${postId}`)
|
|
225
225
|
}
|
|
@@ -233,7 +233,7 @@ export class RedditClient {
|
|
|
233
233
|
})
|
|
234
234
|
|
|
235
235
|
return response.data.data.children.map((child: any) => child.data.display_name)
|
|
236
|
-
} catch
|
|
236
|
+
} catch {
|
|
237
237
|
// Failed to get trending subreddits
|
|
238
238
|
throw new Error("Failed to get trending subreddits")
|
|
239
239
|
}
|
|
@@ -267,7 +267,7 @@ export class RedditClient {
|
|
|
267
267
|
} else {
|
|
268
268
|
throw new Error("Failed to create post")
|
|
269
269
|
}
|
|
270
|
-
} catch
|
|
270
|
+
} catch {
|
|
271
271
|
// Failed to create post
|
|
272
272
|
throw new Error(`Failed to create post in ${subreddit}`)
|
|
273
273
|
}
|
|
@@ -320,7 +320,7 @@ export class RedditClient {
|
|
|
320
320
|
isSubmitter: false,
|
|
321
321
|
permalink: commentData.permalink,
|
|
322
322
|
}
|
|
323
|
-
} catch
|
|
323
|
+
} catch {
|
|
324
324
|
// Failed to reply to post
|
|
325
325
|
throw new Error(`Failed to reply to post ${postId}`)
|
|
326
326
|
}
|
package/src/index.ts
CHANGED
|
@@ -36,7 +36,7 @@ class RedditServer {
|
|
|
36
36
|
data: `Server error: ${error}`,
|
|
37
37
|
})
|
|
38
38
|
}
|
|
39
|
-
|
|
39
|
+
|
|
40
40
|
process.on("SIGINT", async () => {
|
|
41
41
|
await this.server.close()
|
|
42
42
|
process.exit(0)
|
|
@@ -305,23 +305,24 @@ class RedditServer {
|
|
|
305
305
|
async run() {
|
|
306
306
|
const transport = new StdioServerTransport()
|
|
307
307
|
await this.server.connect(transport)
|
|
308
|
-
|
|
308
|
+
|
|
309
309
|
// Log server startup
|
|
310
310
|
await this.server.sendLoggingMessage({
|
|
311
311
|
level: "info",
|
|
312
312
|
logger: "reddit-server",
|
|
313
313
|
data: "Reddit MCP Server is running",
|
|
314
314
|
})
|
|
315
|
-
|
|
315
|
+
|
|
316
316
|
// Log authentication status
|
|
317
317
|
const username = process.env.REDDIT_USERNAME
|
|
318
318
|
const password = process.env.REDDIT_PASSWORD
|
|
319
319
|
await this.server.sendLoggingMessage({
|
|
320
320
|
level: "info",
|
|
321
321
|
logger: "reddit-server",
|
|
322
|
-
data:
|
|
323
|
-
|
|
324
|
-
|
|
322
|
+
data:
|
|
323
|
+
username && password
|
|
324
|
+
? `Authenticated as user: ${username}`
|
|
325
|
+
: "Running in read-only mode (no user authentication)",
|
|
325
326
|
})
|
|
326
327
|
}
|
|
327
328
|
}
|
package/src/tools/post-tools.ts
CHANGED
|
@@ -55,7 +55,7 @@ ${formattedPost.bestTimeToEngage}
|
|
|
55
55
|
}
|
|
56
56
|
} catch (error) {
|
|
57
57
|
// Error will be logged by the server
|
|
58
|
-
throw new McpError(ErrorCode.InternalError, `Failed to fetch post data: ${error}`)
|
|
58
|
+
throw new McpError(ErrorCode.InternalError, `Failed to fetch post data: ${String(error)}`)
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
61
|
|
|
@@ -99,7 +99,7 @@ ${postSummaries}
|
|
|
99
99
|
}
|
|
100
100
|
} catch (error) {
|
|
101
101
|
// Error will be logged by the server
|
|
102
|
-
throw new McpError(ErrorCode.InternalError, `Failed to fetch top posts: ${error}`)
|
|
102
|
+
throw new McpError(ErrorCode.InternalError, `Failed to fetch top posts: ${String(error)}`)
|
|
103
103
|
}
|
|
104
104
|
}
|
|
105
105
|
|
|
@@ -136,7 +136,7 @@ Your post has been successfully submitted to r/${formattedPost.subreddit}.
|
|
|
136
136
|
}
|
|
137
137
|
} catch (error) {
|
|
138
138
|
// Error will be logged by the server
|
|
139
|
-
throw new McpError(ErrorCode.InternalError, `Failed to create post: ${error}`)
|
|
139
|
+
throw new McpError(ErrorCode.InternalError, `Failed to create post: ${String(error)}`)
|
|
140
140
|
}
|
|
141
141
|
}
|
|
142
142
|
|
|
@@ -173,6 +173,6 @@ Your reply has been successfully posted.
|
|
|
173
173
|
}
|
|
174
174
|
} catch (error) {
|
|
175
175
|
// Error will be logged by the server
|
|
176
|
-
throw new McpError(ErrorCode.InternalError, `Failed to reply to post: ${error}`)
|
|
176
|
+
throw new McpError(ErrorCode.InternalError, `Failed to reply to post: ${String(error)}`)
|
|
177
177
|
}
|
|
178
178
|
}
|
|
@@ -57,7 +57,7 @@ ${formattedSubreddit.description.full}
|
|
|
57
57
|
}
|
|
58
58
|
} catch (error) {
|
|
59
59
|
// Error will be logged by the server
|
|
60
|
-
throw new McpError(ErrorCode.InternalError, `Failed to fetch subreddit data: ${error}`)
|
|
60
|
+
throw new McpError(ErrorCode.InternalError, `Failed to fetch subreddit data: ${String(error)}`)
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
63
|
|
|
@@ -86,6 +86,6 @@ ${trendingSubreddits.map((subreddit, index) => `${index + 1}. r/${subreddit}`).j
|
|
|
86
86
|
}
|
|
87
87
|
} catch (error) {
|
|
88
88
|
// Error will be logged by the server
|
|
89
|
-
throw new McpError(ErrorCode.InternalError, `Failed to fetch trending subreddits: ${error}`)
|
|
89
|
+
throw new McpError(ErrorCode.InternalError, `Failed to fetch trending subreddits: ${String(error)}`)
|
|
90
90
|
}
|
|
91
91
|
}
|
package/src/tools/user-tools.ts
CHANGED
|
@@ -43,6 +43,6 @@ export async function getUserInfo(params: { username: string }) {
|
|
|
43
43
|
}
|
|
44
44
|
} catch (error) {
|
|
45
45
|
// Error will be logged by the server
|
|
46
|
-
throw new McpError(ErrorCode.InternalError, `Failed to fetch user data: ${error}`)
|
|
46
|
+
throw new McpError(ErrorCode.InternalError, `Failed to fetch user data: ${String(error)}`)
|
|
47
47
|
}
|
|
48
48
|
}
|