w

wllcnm

@wllcnm/mcp-reddit
0 Stars 295 次浏览 wllcnm 更新于 2026-08-23

MCP 服务配置

复制以下 JSON 到 OPClaw 或其他 MCP 客户端的配置文件中即可使用

{
  "mcpServers": {
    "reddit": {
      "args": [
        "run",
        "-i",
        "--rm",
        "-e",
        "REDDIT_CLIENT_ID=你的client_id",
        "-e",
        "REDDIT_CLIENT_SECRET=你的client_secret",
        "-e",
        "REDDIT_USER_AGENT=你的user_agent",
        "ghcr.io/nangeplus/mcp-reddit:latest"
      ],
      "command": "docker"
    }
  }
}

服务介绍

MCP Reddit Server

English | 中文说明

1. Project Introduction

This is a Reddit server based on the MCP (Model Context Protocol) protocol, specifically designed for interacting with large language models like Claude. Through this service, you can have AI assistants help you browse and analyze content on Reddit.

1.1 Main Features

  • Search for posts in specific subreddits
  • Get detailed information and comments of posts
  • Browse popular posts in subreddits

1.2 Project Structure

nangeAGICode/reddit_chat_claude/
├── .github/
│ └── workflows/
│ └── docker.yml # GitHub Actions workflow configuration
├── src/
│ ├── init.py
│ └── server.py # Core code of the MCP server
├── .gitignore # Git ignore file configuration
├── Dockerfile # Docker build file
├── LICENSE # MIT license
├── README.md # Project documentation
└── requirements.txt # Python dependency list

2. Installation and Configuration

2.1 Prerequisites

  • Docker (required)
  • Python 3.12+ (for local development)
  • Reddit API credentials (required)

2.2 Obtaining Reddit API Credentials

  1. Visit https://www.reddit.com/prefs/apps
  2. Click "create another app..."
  3. Select "script"
  4. Fill in the necessary information
  5. Obtain client_id and client_secret

2.3 Environment Variable Configuration

You need to set the following environment variables:

bash
REDDIT_CLIENT_ID=your_client_id
REDDIT_CLIENT_SECRET=your_client_secret
REDDIT_USER_AGENT=your_user_agent

2.4 Docker Installation

For Mac users:

  1. Visit the Docker official website: https://www.docker.com/products/docker-desktop

  2. Click "Download for Mac"

  3. Choose the version corresponding to your Mac chip (Apple Silicon or Intel)

  4. Download and install the .dmg file

  5. Verify the installation:
    bash

Check Docker version

docker --version

Run a test container

docker run hello-world

  1. Ensure that the Docker service is running:
    bash

Check Docker service status

docker ps

3. Usage

3.1 Using in Claude Desktop Client

Add the following configuration to your claude_desktop_config.json:

json
{
"mcpServers": {
"reddit": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"-e", "REDDIT_CLIENT_ID=your_client_id",
"-e", "REDDIT_CLIENT_SECRET=your_client_secret",
"-e", "REDDIT_USER_AGENT=your_user_agent",
"ghcr.io/nangeplus/mcp-reddit:latest"
]
}
}
}

3.2 Available Tools

  1. search_subreddit: Search for posts in a specific subreddit

    • Parameters:
      • subreddit: Subreddit name
      • query: Search keyword
      • limit: Maximum number of results to return (default: 5)
  2. get_post_details: Get detailed information about a specific post

    • Parameters:
      • post_id: Reddit post ID
      • comment_limit: Maximum number of comments to fetch (default: 10)
  3. get_subreddit_hot: Get popular posts in a subreddit

    • Parameters:
      • subreddit: Subreddit name
      • limit: Maximum number of posts to return (default: 5)

3.3 Usage Examples

In Claude, you can use the tools as follows:

json
{
"tool": "get_subreddit_hot",
"arguments": {
"subreddit": "Python",
"limit": 3
}
}

Example Conversation:

User: Help me check the top 3 hottest posts in the Python subreddit.

Claude: Sure, I'll help you check. I will use the get_subreddit_hot tool:

json
{
"tool": "get_subreddit_hot",
"arguments": {
"subreddit": "Python",
"limit": 3
}
}

[Claude will return the post information]

User: Help me check the details and comments of the first post.

Claude: I will use the get_post_details tool:

json
{
"tool": "get_post_details",
"arguments": {
"post_id": "returned_post_id"
}
}

4. Local Development

4.1 Clone the Repository

bash
git clone https://github.com/nangeplus/mcp-reddit.git
cd mcp-reddit

4.2 Install Dependencies

bash
pip install -r requirements.txt

4.3 Run the Server

bash
python src/server.py

4.4 Docker Build

bash
docker build -t mcp-reddit .
docker run -i --rm
-e REDDIT_CLIENT_ID=your_client_id
-e REDDIT_CLIENT_SECRET=your_client_secret
-e REDDIT_USER_AGENT=your_user_agent
mcp-reddit## 5. Precautions

  1. Security

    • Please keep your Reddit API credentials secure.
    • Do not share your configuration files in public places.
    • It is recommended to use environment variables instead of hardcoding the credentials.
  2. Usage Limitations

    • The Reddit API has call frequency limitations.
    • The default limit for returned comments is 10.
    • The default limit for search results is 5.
  3. Troubleshooting

    • Check if the API credentials are correct.
    • Ensure that the network connection is stable.
    • Review the log output for detailed error information.

6. Contribution Guidelines

  1. Fork the project
  2. Create a feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

7. License

This project is licensed under the MIT License - see the LICENSE file for details


相关 MCP 服务