reddit-mcp-server 1.0.1 → 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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "reddit-mcp-server",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
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": {
|
|
@@ -52,12 +52,12 @@ export class RedditClient {
|
|
|
52
52
|
const authData = new URLSearchParams()
|
|
53
53
|
|
|
54
54
|
if (this.username && this.password) {
|
|
55
|
-
console.
|
|
55
|
+
console.error(`[Auth] Authenticating with user credentials for ${this.username}`)
|
|
56
56
|
authData.append("grant_type", "password")
|
|
57
57
|
authData.append("username", this.username)
|
|
58
58
|
authData.append("password", this.password)
|
|
59
59
|
} else {
|
|
60
|
-
console.
|
|
60
|
+
console.error("[Auth] Authenticating with client credentials (read-only)")
|
|
61
61
|
authData.append("grant_type", "client_credentials")
|
|
62
62
|
}
|
|
63
63
|
|
|
@@ -77,7 +77,7 @@ export class RedditClient {
|
|
|
77
77
|
this.authenticated = true
|
|
78
78
|
this.api.defaults.headers.common["Authorization"] = `Bearer ${this.accessToken}`
|
|
79
79
|
|
|
80
|
-
console.
|
|
80
|
+
console.error("[Auth] Successfully authenticated with Reddit API")
|
|
81
81
|
} catch (error) {
|
|
82
82
|
console.error("[Auth] Authentication error:", error)
|
|
83
83
|
throw new Error("Failed to authenticate with Reddit API")
|
package/src/index.ts
CHANGED
|
@@ -12,7 +12,7 @@ class RedditServer {
|
|
|
12
12
|
private server: Server
|
|
13
13
|
|
|
14
14
|
constructor() {
|
|
15
|
-
console.
|
|
15
|
+
console.error("[Setup] Initializing Reddit Server...")
|
|
16
16
|
|
|
17
17
|
// Initialize the Reddit client
|
|
18
18
|
this.initializeRedditClient()
|
|
@@ -61,11 +61,11 @@ class RedditServer {
|
|
|
61
61
|
password,
|
|
62
62
|
})
|
|
63
63
|
|
|
64
|
-
console.
|
|
64
|
+
console.error("[Setup] Reddit client initialized")
|
|
65
65
|
if (username && password) {
|
|
66
|
-
console.
|
|
66
|
+
console.error(`[Setup] Authenticated as user: ${username}`)
|
|
67
67
|
} else {
|
|
68
|
-
console.
|
|
68
|
+
console.error("[Setup] Running in read-only mode (no user authentication)")
|
|
69
69
|
}
|
|
70
70
|
} catch (error) {
|
|
71
71
|
console.error("[Error] Failed to initialize Reddit client:", error)
|
|
@@ -222,7 +222,7 @@ class RedditServer {
|
|
|
222
222
|
const toolName = request.params.name
|
|
223
223
|
const toolParams = request.params.arguments || {}
|
|
224
224
|
|
|
225
|
-
console.
|
|
225
|
+
console.error(`[Request] Tool call: ${toolName}`, toolParams)
|
|
226
226
|
|
|
227
227
|
switch (toolName) {
|
|
228
228
|
case "test_reddit_mcp_server":
|
|
@@ -293,7 +293,7 @@ class RedditServer {
|
|
|
293
293
|
async run() {
|
|
294
294
|
const transport = new StdioServerTransport()
|
|
295
295
|
await this.server.connect(transport)
|
|
296
|
-
console.
|
|
296
|
+
console.error("[Server] Server is running")
|
|
297
297
|
}
|
|
298
298
|
}
|
|
299
299
|
|
package/src/tools/post-tools.ts
CHANGED
|
@@ -11,7 +11,7 @@ export async function getRedditPost(params: { subreddit: string; post_id: string
|
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
try {
|
|
14
|
-
console.
|
|
14
|
+
console.error(`[Tool] Getting post ${post_id} from r/${subreddit}`)
|
|
15
15
|
const post = await client.getPost(post_id, subreddit)
|
|
16
16
|
const formattedPost = formatPostInfo(post)
|
|
17
17
|
|
|
@@ -68,7 +68,7 @@ export async function getTopPosts(params: { subreddit: string; time_filter?: str
|
|
|
68
68
|
}
|
|
69
69
|
|
|
70
70
|
try {
|
|
71
|
-
console.
|
|
71
|
+
console.error(`[Tool] Getting top posts from r/${subreddit}`)
|
|
72
72
|
const posts = await client.getTopPosts(subreddit, time_filter, limit)
|
|
73
73
|
const formattedPosts = posts.map(formatPostInfo)
|
|
74
74
|
|
|
@@ -112,7 +112,7 @@ export async function createPost(params: { subreddit: string; title: string; con
|
|
|
112
112
|
}
|
|
113
113
|
|
|
114
114
|
try {
|
|
115
|
-
console.
|
|
115
|
+
console.error(`[Tool] Creating ${is_self ? "text" : "link"} post in r/${subreddit}`)
|
|
116
116
|
const post = await client.createPost(subreddit, title, content, is_self)
|
|
117
117
|
const formattedPost = formatPostInfo(post)
|
|
118
118
|
|
|
@@ -149,7 +149,7 @@ export async function replyToPost(params: { post_id: string; content: string; su
|
|
|
149
149
|
}
|
|
150
150
|
|
|
151
151
|
try {
|
|
152
|
-
console.
|
|
152
|
+
console.error(`[Tool] Replying to post ${post_id}`)
|
|
153
153
|
const comment = await client.replyToPost(post_id, content)
|
|
154
154
|
const formattedComment = formatCommentInfo(comment)
|
|
155
155
|
|
|
@@ -11,7 +11,7 @@ export async function getSubredditInfo(params: { subreddit_name: string }) {
|
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
try {
|
|
14
|
-
console.
|
|
14
|
+
console.error(`[Tool] Getting info for r/${subreddit_name}`)
|
|
15
15
|
const subreddit = await client.getSubredditInfo(subreddit_name)
|
|
16
16
|
const formattedSubreddit = formatSubredditInfo(subreddit)
|
|
17
17
|
|
|
@@ -69,7 +69,7 @@ export async function getTrendingSubreddits() {
|
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
try {
|
|
72
|
-
console.
|
|
72
|
+
console.error("[Tool] Getting trending subreddits")
|
|
73
73
|
const trendingSubreddits = await client.getTrendingSubreddits()
|
|
74
74
|
|
|
75
75
|
return {
|
package/src/tools/user-tools.ts
CHANGED
|
@@ -11,7 +11,7 @@ export async function getUserInfo(params: { username: string }) {
|
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
try {
|
|
14
|
-
console.
|
|
14
|
+
console.error(`[Tool] Getting info for u/${username}`)
|
|
15
15
|
const user = await client.getUser(username)
|
|
16
16
|
const formattedUser = formatUserInfo(user)
|
|
17
17
|
|