Labsco
enisze logo

Reddit

β˜… 1

from enisze

Interact with Reddit by posting comments and searching for posts.

πŸ”₯πŸ”₯πŸ”₯βœ“ VerifiedAccount requiredAdvanced setup

Reddit MCP Server

This MCP server allows Clients to interact with Reddit using OAuth2 authentication, enabling read-only access to search for posts within subreddits.

Features

  • Search posts: Search for posts within specific subreddits with various sorting options (relevance, hot, top, new, comments)
  • OAuth2 authentication: Secure authentication using Reddit's OAuth2 client credentials flow
  • Read-only access: Safe, read-only access to Reddit data without requiring user credentials

Environment Variables

  • REDDIT_CLIENT_ID: Your Reddit app's client ID
  • REDDIT_CLIENT_SECRET: Your Reddit app's client secret
  • REDDIT_USER_AGENT: User agent string (optional, defaults to "reddit-mcp-server/1.0.0")

Development

If you want to contribute or run from source:

  1. Clone the repository:
git clone <repository-url>
cd reddit-mcp
  1. Install dependencies:
npm install
  1. Build:
npm run build
  1. Run:
npm start
  1. Test:
# Run unit tests (no API credentials needed)
npm test

# Run API integration tests (requires Reddit credentials)
npm run test:api

Running Evaluations

To test the functionality of the Reddit MCP server:

npm run eval

This will run a series of evaluations to ensure all tools are working correctly.

Docker Support

You can also run this MCP server using Docker:

# Build the Docker image
docker build -t reddit-mcp .

# Run the container with environment variables
docker run -e REDDIT_CLIENT_ID=your_client_id \
           -e REDDIT_CLIENT_SECRET=your_client_secret \
           reddit-mcp

API Documentation

search_posts

Searches for posts in a Reddit subreddit using OAuth2 authentication.

Parameters:

  • query (string, required): Search query
  • subreddit (string, required): The subreddit name (without r/ prefix)
  • count (number, optional): Number of posts to return (1-100, default: 25)
  • sort (string, optional): Sort order - 'relevance', 'hot', 'top', 'new', 'comments' (default: 'relevance')

Testing

The project includes comprehensive tests to verify functionality:

Unit Tests

Run basic functionality tests without requiring Reddit API credentials:

npm test

These tests verify:

  • Response formatting
  • Type definitions
  • Data structure handling
  • Error handling logic

API Integration Tests

Test actual Reddit API functionality (requires credentials):

npm run test:api

Set up your credentials in .env first (copy from .env.example).

These tests verify:

  • OAuth2 authentication flow
  • Search functionality
  • API response handling
  • Error handling for various scenarios

See TEST.md for detailed testing instructions.

License

MIT