reddit-mcp-server 1.0.6 → 1.0.7
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/CHANGELOG.md +34 -0
- package/package.json +7 -1
- package/.claude/settings.local.json +0 -35
- package/.env.example +0 -7
- package/.prettierignore +0 -7
- package/.prettierrc +0 -8
- package/CLAUDE.md +0 -104
- package/Dockerfile +0 -17
- package/ROADMAP.md +0 -77
- package/eslint.config.js +0 -76
- package/pnpm-workspace.yaml +0 -2
- package/smithery.yaml +0 -37
- package/src/bin.ts +0 -7
- package/src/client/__tests__/reddit-client.test.ts +0 -478
- package/src/client/reddit-client.ts +0 -638
- package/src/index.ts +0 -518
- package/src/tools/__tests__/comment-tools.test.ts +0 -119
- package/src/tools/__tests__/search-tools.test.ts +0 -100
- package/src/tools/__tests__/user-tools.test.ts +0 -258
- package/src/tools/comment-tools.ts +0 -61
- package/src/tools/index.ts +0 -5
- package/src/tools/post-tools.ts +0 -178
- package/src/tools/search-tools.ts +0 -67
- package/src/tools/subreddit-tools.ts +0 -91
- package/src/tools/user-tools.ts +0 -147
- package/src/types.ts +0 -148
- package/src/utils/formatters.ts +0 -316
- package/tsconfig.json +0 -19
- package/tsup.config.ts +0 -12
- package/vitest.config.ts +0 -20
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
## [1.0.7] - 2025-06-27
|
|
6
|
+
|
|
7
|
+
### Fixed
|
|
8
|
+
- Fixed server crash issue caused by stdout pollution in bin.js
|
|
9
|
+
- Cleaned up published package to only include necessary files (reduced from 112KB to 24KB)
|
|
10
|
+
|
|
11
|
+
### Added
|
|
12
|
+
- Search Reddit functionality (`search_reddit` tool)
|
|
13
|
+
- Get post comments with threaded display (`get_post_comments` tool)
|
|
14
|
+
- Get user posts (`get_user_posts` tool)
|
|
15
|
+
- Get user comments (`get_user_comments` tool)
|
|
16
|
+
- Comprehensive test suite for all new functionality
|
|
17
|
+
|
|
18
|
+
### Changed
|
|
19
|
+
- Migrated from axios to native fetch API
|
|
20
|
+
- Improved error handling and removed console output that violated MCP protocol
|
|
21
|
+
|
|
22
|
+
## [1.0.6] - 2025-06-27
|
|
23
|
+
|
|
24
|
+
### Added
|
|
25
|
+
- New Reddit API endpoints (had packaging issues, use 1.0.7 instead)
|
|
26
|
+
|
|
27
|
+
## [1.0.5] - 2025-06-27
|
|
28
|
+
|
|
29
|
+
### Changed
|
|
30
|
+
- Migrated from axios to fetch for HTTP requests
|
|
31
|
+
- Fixed linting errors and improved code formatting
|
|
32
|
+
|
|
33
|
+
## [1.0.4] and earlier
|
|
34
|
+
- Previous versions with axios-based implementation
|
package/package.json
CHANGED
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "reddit-mcp-server",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.7",
|
|
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": {
|
|
7
7
|
"reddit-mcp-server": "dist/bin.js"
|
|
8
8
|
},
|
|
9
|
+
"files": [
|
|
10
|
+
"dist/",
|
|
11
|
+
"README.md",
|
|
12
|
+
"LICENSE",
|
|
13
|
+
"CHANGELOG.md"
|
|
14
|
+
],
|
|
9
15
|
"keywords": [
|
|
10
16
|
"mcp",
|
|
11
17
|
"reddit",
|
|
@@ -1,35 +0,0 @@
|
|
|
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
|
-
"Bash(pnpm build:*)",
|
|
16
|
-
"Bash(npx tsup:*)",
|
|
17
|
-
"Bash(find:*)",
|
|
18
|
-
"Bash(rg:*)",
|
|
19
|
-
"Bash(grep:*)",
|
|
20
|
-
"Bash(npm ls:*)",
|
|
21
|
-
"Bash(git checkout:*)",
|
|
22
|
-
"Bash(pnpm install:*)",
|
|
23
|
-
"Bash(pnpm test:*)",
|
|
24
|
-
"Bash(cp:*)",
|
|
25
|
-
"Bash(mv:*)",
|
|
26
|
-
"Bash(pnpm remove:*)",
|
|
27
|
-
"Bash(npx tsc:*)",
|
|
28
|
-
"Bash(touch:*)",
|
|
29
|
-
"Bash(node:*)",
|
|
30
|
-
"Bash(REDDIT_CLIENT_ID=test REDDIT_CLIENT_SECRET=test node dist/bin.js 2>&1)",
|
|
31
|
-
"Bash(REDDIT_CLIENT_ID=test REDDIT_CLIENT_SECRET=test pnpm start 2>&1)"
|
|
32
|
-
],
|
|
33
|
-
"deny": []
|
|
34
|
-
}
|
|
35
|
-
}
|
package/.env.example
DELETED
package/.prettierignore
DELETED
package/.prettierrc
DELETED
package/CLAUDE.md
DELETED
|
@@ -1,104 +0,0 @@
|
|
|
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
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
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/ROADMAP.md
DELETED
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
# Reddit MCP Server Roadmap
|
|
2
|
-
|
|
3
|
-
## Implemented Features ✅
|
|
4
|
-
- Get subreddit info
|
|
5
|
-
- Get top posts from subreddits
|
|
6
|
-
- Get specific post details
|
|
7
|
-
- Get trending subreddits
|
|
8
|
-
- Get user information
|
|
9
|
-
- Create posts (text/link)
|
|
10
|
-
- Reply to posts
|
|
11
|
-
|
|
12
|
-
## High Priority Features 🔴
|
|
13
|
-
|
|
14
|
-
### 1. Search Functionality
|
|
15
|
-
- **Endpoint**: `/search` and `/r/{subreddit}/search`
|
|
16
|
-
- **Tool Name**: `search_reddit`
|
|
17
|
-
- **Parameters**: query, subreddit (optional), sort, time_filter, limit
|
|
18
|
-
- **Use Case**: Finding specific content, research, monitoring topics
|
|
19
|
-
|
|
20
|
-
### 2. Get Post Comments
|
|
21
|
-
- **Endpoint**: `/r/{subreddit}/comments/{article}`
|
|
22
|
-
- **Tool Name**: `get_post_comments`
|
|
23
|
-
- **Parameters**: post_id, subreddit, sort, limit
|
|
24
|
-
- **Use Case**: Reading full discussions, analyzing conversations
|
|
25
|
-
|
|
26
|
-
### 3. User Activity
|
|
27
|
-
- **Endpoints**: `/user/{username}/submitted`, `/user/{username}/comments`
|
|
28
|
-
- **Tool Names**: `get_user_posts`, `get_user_comments`
|
|
29
|
-
- **Parameters**: username, sort, time_filter, limit
|
|
30
|
-
- **Use Case**: User research, activity analysis
|
|
31
|
-
|
|
32
|
-
## Medium Priority Features 🟡
|
|
33
|
-
|
|
34
|
-
### 4. Voting System
|
|
35
|
-
- **Endpoint**: `/api/vote`
|
|
36
|
-
- **Tool Name**: `vote_on_content`
|
|
37
|
-
- **Parameters**: id, direction (1, 0, -1)
|
|
38
|
-
- **Use Case**: Engaging with content
|
|
39
|
-
|
|
40
|
-
### 5. Save/Unsave Content
|
|
41
|
-
- **Endpoints**: `/api/save`, `/api/unsave`
|
|
42
|
-
- **Tool Names**: `save_content`, `unsave_content`
|
|
43
|
-
- **Parameters**: id
|
|
44
|
-
- **Use Case**: Bookmarking for later
|
|
45
|
-
|
|
46
|
-
### 6. Delete Own Content
|
|
47
|
-
- **Endpoint**: `/api/del`
|
|
48
|
-
- **Tool Name**: `delete_content`
|
|
49
|
-
- **Parameters**: id
|
|
50
|
-
- **Use Case**: Content management
|
|
51
|
-
|
|
52
|
-
## Low Priority Features 🟢
|
|
53
|
-
|
|
54
|
-
### 7. Edit Posts/Comments
|
|
55
|
-
- **Endpoint**: `/api/editusertext`
|
|
56
|
-
- **Tool Name**: `edit_content`
|
|
57
|
-
- **Parameters**: thing_id, text
|
|
58
|
-
- **Use Case**: Fixing typos, updating content
|
|
59
|
-
|
|
60
|
-
### 8. Get Saved Content
|
|
61
|
-
- **Endpoint**: `/user/{username}/saved`
|
|
62
|
-
- **Tool Name**: `get_saved_content`
|
|
63
|
-
- **Parameters**: username, type, limit
|
|
64
|
-
- **Use Case**: Retrieving bookmarked content
|
|
65
|
-
|
|
66
|
-
### 9. Subscribe/Unsubscribe
|
|
67
|
-
- **Endpoints**: `/api/subscribe`
|
|
68
|
-
- **Tool Name**: `manage_subscription`
|
|
69
|
-
- **Parameters**: subreddit, action
|
|
70
|
-
- **Use Case**: Managing subreddit subscriptions
|
|
71
|
-
|
|
72
|
-
## Implementation Notes
|
|
73
|
-
|
|
74
|
-
- All write operations require user authentication (username/password)
|
|
75
|
-
- Rate limiting should be implemented to respect Reddit's API limits
|
|
76
|
-
- Error handling should provide clear messages about authentication requirements
|
|
77
|
-
- Consider implementing caching for frequently accessed data
|
package/eslint.config.js
DELETED
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
const eslint = require('@eslint/js');
|
|
2
|
-
const tseslint = require('@typescript-eslint/eslint-plugin');
|
|
3
|
-
const tsParser = require('@typescript-eslint/parser');
|
|
4
|
-
const prettierConfig = require('eslint-config-prettier');
|
|
5
|
-
const prettierPlugin = require('eslint-plugin-prettier');
|
|
6
|
-
|
|
7
|
-
module.exports = [
|
|
8
|
-
{
|
|
9
|
-
...eslint.configs.recommended,
|
|
10
|
-
languageOptions: {
|
|
11
|
-
globals: {
|
|
12
|
-
console: 'readonly',
|
|
13
|
-
process: 'readonly',
|
|
14
|
-
Buffer: 'readonly',
|
|
15
|
-
__dirname: 'readonly',
|
|
16
|
-
__filename: 'readonly',
|
|
17
|
-
exports: 'writable',
|
|
18
|
-
module: 'writable',
|
|
19
|
-
require: 'readonly',
|
|
20
|
-
global: 'readonly',
|
|
21
|
-
URL: 'readonly',
|
|
22
|
-
fetch: 'readonly',
|
|
23
|
-
},
|
|
24
|
-
},
|
|
25
|
-
},
|
|
26
|
-
prettierConfig,
|
|
27
|
-
{
|
|
28
|
-
files: ['**/*.{ts,tsx}'],
|
|
29
|
-
languageOptions: {
|
|
30
|
-
parser: tsParser,
|
|
31
|
-
parserOptions: {
|
|
32
|
-
ecmaVersion: 2022,
|
|
33
|
-
sourceType: 'module',
|
|
34
|
-
project: './tsconfig.json',
|
|
35
|
-
},
|
|
36
|
-
globals: {
|
|
37
|
-
console: 'readonly',
|
|
38
|
-
process: 'readonly',
|
|
39
|
-
Buffer: 'readonly',
|
|
40
|
-
__dirname: 'readonly',
|
|
41
|
-
__filename: 'readonly',
|
|
42
|
-
exports: 'writable',
|
|
43
|
-
module: 'writable',
|
|
44
|
-
require: 'readonly',
|
|
45
|
-
global: 'readonly',
|
|
46
|
-
URL: 'readonly',
|
|
47
|
-
fetch: 'readonly',
|
|
48
|
-
},
|
|
49
|
-
},
|
|
50
|
-
plugins: {
|
|
51
|
-
'@typescript-eslint': tseslint,
|
|
52
|
-
prettier: prettierPlugin,
|
|
53
|
-
},
|
|
54
|
-
rules: {
|
|
55
|
-
...tseslint.configs.recommended.rules,
|
|
56
|
-
'prettier/prettier': 'error',
|
|
57
|
-
'@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_' }],
|
|
58
|
-
'@typescript-eslint/no-explicit-any': 'warn',
|
|
59
|
-
'@typescript-eslint/explicit-function-return-type': 'off',
|
|
60
|
-
'@typescript-eslint/explicit-module-boundary-types': 'off',
|
|
61
|
-
'@typescript-eslint/no-non-null-assertion': 'warn',
|
|
62
|
-
'@typescript-eslint/no-unsafe-assignment': 'warn',
|
|
63
|
-
'@typescript-eslint/no-unsafe-member-access': 'warn',
|
|
64
|
-
'@typescript-eslint/no-unsafe-argument': 'warn',
|
|
65
|
-
'@typescript-eslint/no-unsafe-return': 'warn',
|
|
66
|
-
'@typescript-eslint/no-unsafe-call': 'warn',
|
|
67
|
-
'@typescript-eslint/restrict-template-expressions': 'warn',
|
|
68
|
-
'@typescript-eslint/prefer-promise-reject-errors': 'warn',
|
|
69
|
-
'no-console': 'off',
|
|
70
|
-
'no-regex-spaces': 'off',
|
|
71
|
-
},
|
|
72
|
-
},
|
|
73
|
-
{
|
|
74
|
-
ignores: ['node_modules/**', 'dist/**', 'build/**', '*.config.js', '*.config.ts'],
|
|
75
|
-
},
|
|
76
|
-
];
|
package/pnpm-workspace.yaml
DELETED
package/smithery.yaml
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
# Smithery configuration file: https://smithery.ai/docs/build/project-config
|
|
2
|
-
|
|
3
|
-
startCommand:
|
|
4
|
-
type: stdio
|
|
5
|
-
commandFunction:
|
|
6
|
-
# A JS function that produces the CLI command based on the given config to start the MCP on stdio.
|
|
7
|
-
|-
|
|
8
|
-
(config) => ({ command: 'node', args: ['build/index.js'], env: { REDDIT_CLIENT_ID: config.redditClientId, REDDIT_CLIENT_SECRET: config.redditClientSecret, REDDIT_USER_AGENT: config.redditUserAgent ?? 'RedditMCPServer/0.1.0', ...(config.redditUsername ? { REDDIT_USERNAME: config.redditUsername } : {}), ...(config.redditPassword ? { REDDIT_PASSWORD: config.redditPassword } : {}) } })
|
|
9
|
-
configSchema:
|
|
10
|
-
# JSON Schema defining the configuration options for the MCP.
|
|
11
|
-
type: object
|
|
12
|
-
required:
|
|
13
|
-
- redditClientId
|
|
14
|
-
- redditClientSecret
|
|
15
|
-
properties:
|
|
16
|
-
redditClientId:
|
|
17
|
-
type: string
|
|
18
|
-
description: Reddit Application Client ID
|
|
19
|
-
redditClientSecret:
|
|
20
|
-
type: string
|
|
21
|
-
description: Reddit Application Client Secret
|
|
22
|
-
redditUserAgent:
|
|
23
|
-
type: string
|
|
24
|
-
default: RedditMCPServer/0.1.0
|
|
25
|
-
description: User-Agent header for Reddit API requests
|
|
26
|
-
redditUsername:
|
|
27
|
-
type: string
|
|
28
|
-
description: Optional Reddit username for authenticated actions
|
|
29
|
-
redditPassword:
|
|
30
|
-
type: string
|
|
31
|
-
description: Optional Reddit password for authenticated actions
|
|
32
|
-
exampleConfig:
|
|
33
|
-
redditClientId: abc123xyz
|
|
34
|
-
redditClientSecret: secretvalue
|
|
35
|
-
redditUserAgent: MyRedditAgent/1.0.0
|
|
36
|
-
redditUsername: my_reddit_user
|
|
37
|
-
redditPassword: supersecret
|