Skip to main content

MCP Reddit Server - A Model Control Protocol server for Reddit integration

Project description

MCP Reddit Server

English | 中文说明

中文说明

1. 项目介绍

这是一个基于MCP(Model Context Protocol)协议的Reddit服务器,专门设计用于与Claude等大语言模型进行交互。通过这个服务,你可以让AI助手帮助你浏览和分析Reddit上的内容。

1.1 主要功能

  • 搜索特定subreddit中的帖子
  • 获取帖子详细信息和评论
  • 浏览subreddit中的热门帖子

1.2 项目结构

nangeAGICode/reddit_chat_claude/
├── .github/
│   └── workflows/
│       └── docker.yml # GitHub Actions工作流配置
├── src/
│   ├── init.py
│   └── server.py # MCP服务器核心代码
├── .gitignore # Git忽略文件配置
├── Dockerfile # Docker构建文件
├── LICENSE # MIT许可证
├── README.md # 项目说明文档
└── requirements.txt # Python依赖包列表

2. 安装和配置

2.1 前提条件

  • Docker(必须)
  • Python 3.12+(用于本地开发)
  • Reddit API凭证(必需)

2.2 获取Reddit API凭证

  1. 访问 https://www.reddit.com/prefs/apps
  2. 点击"create another app..."
  3. 选择"script"
  4. 填写必要信息
  5. 获取client_id和client_secret

2.3 环境变量配置

需要设置以下环境变量:

REDDIT_CLIENT_ID=你的client_id
REDDIT_CLIENT_SECRET=你的client_secret
REDDIT_USER_AGENT=你的user_agent

2.4 Docker安装

MAC用户: 1.访问 Docker 官网:https://www.docker.com/products/docker-desktop 2.点击 "Download for Mac" 3.选择对应你的 Mac 芯片的版本(Apple Silicon 或 Intel) 4.下载并安装 .dmg 文件

5.验证安装:

# 检查 Docker 版本
docker --version

# 运行测试容器
docker run hello-world

6.确保 Docker 服务正在运行:

# 检查 Docker 服务状态
docker ps

3. 使用方法

3.1 在Claude桌面客户端中使用

在你的claude_desktop_config.json中添加以下配置:

{
  "mcpServers": {
    "reddit": {
      "command": "docker",
      "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"
      ]
    }
  }
}

3.2 可用工具

  1. search_subreddit: 搜索特定subreddit中的帖子

    • 参数:
      • subreddit: subreddit名称
      • query: 搜索关键词
      • limit: 最大返回结果数(默认:5)
  2. get_post_details: 获取特定帖子的详细信息

    • 参数:
      • post_id: Reddit帖子ID
      • comment_limit: 获取评论的最大数量(默认:10)
  3. get_subreddit_hot: 获取subreddit中的热门帖子

    • 参数:
      • subreddit: subreddit名称
      • limit: 返回帖子的最大数量(默认:5)

3.3 使用示例

在Claude中,你可以这样使用工具:

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

示例对话:

用户:帮我查看Python subreddit中最热门的3个帖子。

Claude:好的,我来帮你查看。我将使用get_subreddit_hot工具:

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

[Claude会返回帖子信息]

用户:帮我查看第一个帖子的详细内容和评论。

Claude:我将使用get_post_details工具:

{
  "tool": "get_post_details",
  "arguments": {
    "post_id": "返回的帖子ID"
  }
}

4. 本地开发

4.1 克隆仓库

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

4.2 安装依赖

pip install -r requirements.txt

4.3 运行服务器

python src/server.py

4.4 Docker构建

docker build -t mcp-reddit .
docker run -i --rm \
  -e REDDIT_CLIENT_ID=你的client_id \
  -e REDDIT_CLIENT_SECRET=你的client_secret \
  -e REDDIT_USER_AGENT=你的user_agent \
  mcp-reddit

5. 注意事项

  1. 安全性

    • 请妥善保管你的Reddit API凭证
    • 不要在公共场合分享你的配置文件
    • 建议使用环境变量而不是硬编码凭证
  2. 使用限制

    • Reddit API有调用频率限制
    • 默认返回的评论数量限制为10条
    • 搜索结果默认限制为5条
  3. 故障排除

    • 检查API凭证是否正确
    • 确保网络连接正常
    • 查看日志输出了解详细错误信息

6. 贡献指南

  1. Fork 项目
  2. 创建特性分支 (git checkout -b feature/AmazingFeature)
  3. 提交更改 (git commit -m 'Add some AmazingFeature')
  4. 推送到分支 (git push origin feature/AmazingFeature)
  5. 开启 Pull Request

7. 许可证

本项目采用 MIT 许可证 - 查看 LICENSE 文件了解详情


Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

iflow_mcp_mcp_reddit-0.1.0.tar.gz (7.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

iflow_mcp_mcp_reddit-0.1.0-py3-none-any.whl (6.3 kB view details)

Uploaded Python 3

File details

Details for the file iflow_mcp_mcp_reddit-0.1.0.tar.gz.

File metadata

  • Download URL: iflow_mcp_mcp_reddit-0.1.0.tar.gz
  • Upload date:
  • Size: 7.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.10 {"installer":{"name":"uv","version":"0.9.10"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for iflow_mcp_mcp_reddit-0.1.0.tar.gz
Algorithm Hash digest
SHA256 6fdc589998a7fcab94b309ae02907ebd83b8240c80528688e798e6e2b389748c
MD5 d777dc33a084cbf17b165d5c6b48eee0
BLAKE2b-256 38abeac501ef201107ba18c7c7eb62f58abd4eb59e8bc741401490e1a16b3ecc

See more details on using hashes here.

File details

Details for the file iflow_mcp_mcp_reddit-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: iflow_mcp_mcp_reddit-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 6.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.10 {"installer":{"name":"uv","version":"0.9.10"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for iflow_mcp_mcp_reddit-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9b33d4040407b7b078b80187a90fc40eb475cbcee1e53085257670f4146c848b
MD5 b89866c8ae2ddc0982f0a966c13d2338
BLAKE2b-256 d372c1cca1c2dc6f27f56ced0eae13f7726cf6af8965e0ae99f21df67d478904

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page