reddit-mcp-server 1.0.0

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.
@@ -0,0 +1,18 @@
1
+ {
2
+ "permissions": {
3
+ "allow": [
4
+ "Bash(pnpm add:*)",
5
+ "Bash(pnpm lint)",
6
+ "Bash(pnpm lint:*)",
7
+ "WebFetch(domain:www.npmjs.com)",
8
+ "WebFetch(domain:github.com)",
9
+ "Bash(npm view:*)",
10
+ "Bash(npm pack:*)",
11
+ "Bash(mkdir:*)",
12
+ "Bash(tar:*)",
13
+ "Bash(ls:*)",
14
+ "Bash(rm:*)"
15
+ ],
16
+ "deny": []
17
+ }
18
+ }
package/.env.example ADDED
@@ -0,0 +1,7 @@
1
+ # Reddit API Credentials (required)
2
+ REDDIT_CLIENT_ID=
3
+ REDDIT_CLIENT_SECRET=
4
+
5
+ # Reddit User Credentials (optional, for posting/commenting)
6
+ REDDIT_USERNAME=
7
+ REDDIT_PASSWORD=
@@ -0,0 +1,7 @@
1
+ node_modules
2
+ dist
3
+ build
4
+ .pnpm-store
5
+ pnpm-lock.yaml
6
+ *.log
7
+ .env
package/.prettierrc ADDED
@@ -0,0 +1,8 @@
1
+ {
2
+ "semi": false,
3
+ "trailingComma": "all",
4
+ "singleQuote": false,
5
+ "printWidth": 120,
6
+ "tabWidth": 2,
7
+ "endOfLine": "auto"
8
+ }
package/CLAUDE.md ADDED
@@ -0,0 +1,104 @@
1
+ # CLAUDE.md
2
+
3
+ This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4
+
5
+ ## Project Overview
6
+
7
+ This is a Reddit MCP (Model Context Protocol) server that provides tools for interacting with the Reddit API. It's built with TypeScript and uses the MCP SDK to expose Reddit functionality as tools that can be used by AI assistants.
8
+
9
+ ## Development Commands
10
+
11
+ ```bash
12
+ # Install dependencies
13
+ pnpm install
14
+
15
+ # Build TypeScript to JavaScript with tsup
16
+ pnpm build
17
+
18
+ # Run the MCP inspector for development/testing
19
+ pnpm inspect
20
+
21
+ # Build and run inspector in one command
22
+ pnpm dev
23
+
24
+ # Build and start the server via npx
25
+ pnpm start
26
+
27
+ # Format code with Prettier
28
+ pnpm format
29
+
30
+ # Check code formatting
31
+ pnpm format:check
32
+
33
+ # Lint code with ESLint
34
+ pnpm lint
35
+
36
+ # Fix linting issues
37
+ pnpm lint:fix
38
+ ```
39
+
40
+ ## Architecture
41
+
42
+ ### Core Components
43
+
44
+ 1. **Reddit Client** (`src/client/reddit-client.ts`): Singleton pattern implementation that handles:
45
+ - OAuth2 authentication (client credentials and password flow)
46
+ - Automatic token refresh via axios interceptors
47
+ - Rate limiting and error handling
48
+ - Both read-only and authenticated operations
49
+
50
+ 2. **Tool Modules** (`src/tools/`): Modular organization by functionality:
51
+ - `post-tools.ts`: Post creation, replying to posts/comments
52
+ - `subreddit-tools.ts`: Subreddit info, statistics, trending
53
+ - `user-tools.ts`: User information and engagement insights
54
+
55
+ 3. **Type Definitions** (`src/types.ts`): Comprehensive TypeScript types for all Reddit entities
56
+
57
+ ### Authentication Flow
58
+
59
+ - **Read-only operations**: Only require client credentials (REDDIT_CLIENT_ID, REDDIT_CLIENT_SECRET)
60
+ - **Write operations**: Additionally require user credentials (REDDIT_USERNAME, REDDIT_PASSWORD)
61
+ - Token management is handled automatically by the Reddit client
62
+
63
+ ## Environment Setup
64
+
65
+ Required environment variables:
66
+ ```bash
67
+ REDDIT_CLIENT_ID=your_client_id
68
+ REDDIT_CLIENT_SECRET=your_client_secret
69
+ REDDIT_USER_AGENT=YourApp/1.0.0 # Optional, defaults to "RedditMCPServer/0.1.0"
70
+ REDDIT_USERNAME=your_username # Optional, for write operations
71
+ REDDIT_PASSWORD=your_password # Optional, for write operations
72
+ ```
73
+
74
+ ## Key Implementation Details
75
+
76
+ 1. **Error Handling**: All tools use try-catch blocks and return MCP-compliant error responses
77
+ 2. **Rate Limiting**: Built into the Reddit client to respect API limits
78
+ 3. **Token Refresh**: Automatic via axios interceptors when tokens expire
79
+ 4. **Singleton Client**: Ensures single authenticated instance across all tools
80
+
81
+ ## Testing Approach
82
+
83
+ Currently no test framework is configured. When implementing tests:
84
+ - Use the MCP inspector (`pnpm inspect`) for manual testing
85
+ - Test both authenticated and unauthenticated flows
86
+ - Verify error handling for invalid inputs and API failures
87
+
88
+ ## Common Development Tasks
89
+
90
+ 1. **Adding a new Reddit tool**:
91
+ - Create new function in appropriate tool file (`src/tools/`)
92
+ - Define TypeScript types in `src/types.ts` if needed
93
+ - Export from `src/tools/index.ts`
94
+ - Register in main server (`src/index.ts`)
95
+
96
+ 2. **Modifying Reddit client**:
97
+ - Update `src/client/reddit-client.ts`
98
+ - Ensure backward compatibility with existing tools
99
+ - Test both auth flows if authentication logic changes
100
+
101
+ 3. **Debugging**:
102
+ - Use `pnpm inspect` to test tools interactively
103
+ - Check axios interceptors for auth issues
104
+ - Verify environment variables are set correctly
package/Dockerfile ADDED
@@ -0,0 +1,17 @@
1
+ # Generated by https://smithery.ai. See: https://smithery.ai/docs/build/project-config
2
+ FROM node:lts-alpine
3
+
4
+ WORKDIR /app
5
+
6
+ # Install dependencies without running prepare scripts
7
+ COPY package*.json ./
8
+ RUN npm install --ignore-scripts && npm install dotenv @types/dotenv
9
+
10
+ # Copy all source files
11
+ COPY . .
12
+
13
+ # Build TypeScript
14
+ RUN npm run build
15
+
16
+ # Default command to start the MCP server via stdio transport
17
+ CMD ["node", "build/index.js"]
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Alexandros Lekkas
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,101 @@
1
+ # Reddit MCP Server ⚙️
2
+
3
+ A Model Context Protocol (MCP) that provides tools for fetching and creating Reddit content.
4
+
5
+ > **Note**: This is a fork of the original [reddit-mcp-server](https://github.com/alexandros-lekkas/reddit-mcp-server) by Alexandros Lekkas, updated with pnpm, tsup build system, and npx execution support.
6
+
7
+ [![smithery badge](https://smithery.ai/badge/@jordanburke/reddit-mcp-server)](https://smithery.ai/server/@jordanburke/reddit-mcp-server)
8
+
9
+ https://github.com/user-attachments/assets/caa37704-7c92-4bf8-b7e8-56d02ccb4983
10
+
11
+ ## 🧑‍💻 About
12
+
13
+ https://www.linkedin.com/feed/update/urn:li:activity:7328864060534419457/
14
+
15
+ ![image](https://github.com/user-attachments/assets/aedc0966-75d4-45c4-a384-df03d232e29d)
16
+
17
+ ## 🔧 Available Tools (Features)
18
+
19
+ **Read-only Tools (Client Credentials):**
20
+
21
+ - `get_user_info(username)` - Get detailed user analysis with engagement insights
22
+ - `get_top_posts(subreddit, time_filter, limit)` - Get and analyze top posts
23
+ - `get_subreddit_stats(subreddit)` - Get comprehensive subreddit analysis
24
+ - `get_trending_subreddits()` - Get list of trending subreddits
25
+
26
+ **Read-write Tools (User Credentials):**
27
+
28
+ - `create_post(subreddit, title, content, flair, is_self)` - Create an optimized post
29
+ - `reply_to_post(post_id, content, subreddit)` - Add a reply with engagement insights
30
+ - `reply_to_comment(comment_id, content, subreddit)` - Add a strategic reply
31
+
32
+ ## 🔌 Installation
33
+
34
+ ### Installing via Smithery
35
+
36
+ To install Reddit Content Integration Server for Claude Desktop automatically via [Smithery](https://smithery.ai/server/@alexandros-lekkas/reddit-mcp-server):
37
+
38
+ ```bash
39
+ npx -y @smithery/cli install @jordanburke/reddit-mcp-server --client claude
40
+ ```
41
+
42
+ ### Manual Installation
43
+ 1. `git clone https://github.com/jordanburke/reddit-mcp-server`
44
+
45
+ 2. Create a Reddit app [here](https://www.reddit.com/prefs/apps)
46
+
47
+ ![image](https://github.com/user-attachments/assets/bb7582d6-abf2-4282-a102-bd2e0f2c1c41)
48
+
49
+ Make sure to select "script"!
50
+
51
+ 3. Copy the client ID and client secret
52
+
53
+ 4. Create a `.env` file based on `.env.example`
54
+
55
+ Do this with your `REDDIT_CLIENT_ID` and `REDDIT_CLIENT_SECRET`
56
+
57
+ If you want to write posts you need to include your `REDDIT_USERNAME` and `REDDIT_PASSWORD` (don't worry, I won't steal them 😜)
58
+
59
+ 5. Install dependencies with `pnpm install`
60
+
61
+ 6. Run with `pnpm dev` and open the inspection server (http://127.0.0.1:6274/)
62
+
63
+ ![image](https://github.com/user-attachments/assets/705c63ef-5d3c-4a68-8d3b-18dfda0a29f2)
64
+
65
+ 7. If the connection works, add this to your MCP config (for Cursor or Claude, depending on which agent you are using)
66
+
67
+ ```json
68
+ "mcpServers": {
69
+ "reddit": {
70
+ "command": "npx",
71
+ "args": [
72
+ "reddit-mcp-server"
73
+ ],
74
+ "env": {
75
+ "REDDIT_CLIENT_ID": "😜",
76
+ "REDDIT_CLIENT_SECRET": "😜",
77
+ "REDDIT_USERNAME": "😜",
78
+ "REDDIT_PASSWORD": "😜"
79
+ },
80
+ "autoApprove": [
81
+ "get_reddit_post",
82
+ "get_top_posts",
83
+ "get_user_info",
84
+ "get_subreddit_info",
85
+ "get_trending_subreddits",
86
+ "create_post",
87
+ "reply_to_post"
88
+ ] // You don't need to add this, but it makes it so that you don't have to keep clicking approve
89
+ }
90
+ }
91
+ ```
92
+
93
+ (Make sure to replace the environmental variables with your actual keys, not the 😜 emoji)
94
+
95
+ ## 📚 Credits
96
+
97
+ - This is a fork of the original [reddit-mcp-server](https://github.com/alexandros-lekkas/reddit-mcp-server) by Alexandros Lekkas.
98
+
99
+ - Credit goes to the [Python Reddit MCP Server](https://github.com/Arindam200/reddit-mcp) by Arindam200 for the inspiration and implementation of these tools. This repository is, at the moment, simply a Node.js port of the Python implementation.
100
+
101
+ - Credit goes to [Eugene Sh](https://medium.com/@eugenesh4work/how-to-build-an-mcp-server-fast-a-step-by-step-tutorial-e09faa5f7e3b) for the tutorial on how to build an MCP server (which was used as a reference for this implementation).
@@ -0,0 +1 @@
1
+ #!/usr/bin/env node