内容
# Reddit 探索器 MCP
一个 [MCP](https://modelcontextprotocol.io) 服务器,通过 [PRAW](https://praw.readthedocs.io/) 为 AI 代理提供对 Reddit 的读取 **和** 写入访问权限。可以使用 `uvx` 在本地运行 — 无需克隆。
## 功能
**读取(在只读模式下有效):**
- `search_reddit` — 跨整个 Reddit 或单个子版块的全文本搜索(支持 `flair:`、`author:`、`self:` 语法)
- `get_subreddit_posts` — 热门 / 最新 / 置顶 / 有争议 / 正在崛起的帖子列表,可选的标记筛选
- `get_subreddit_flairs` — 列出可用的帖子标记
- `get_subreddit_info` — 元数据、规则、版主
- `get_submission` / `get_post_comments` — 完整的帖子详情和线程评论树
- `get_redditor_info` — 用户资料 + 可选的近期活动
- `get_front_page` / `get_popular` / `get_all` — 首页 / 热门 / 全部列表
- `search_subreddits` / `get_default_subreddits`
**写入(需要身份验证凭证):**
- `submit_post` — 提交文本或链接帖子
- `submit_comment` — 评论帖子或回复评论
- `vote` — 点赞 / 点踩 / 清除
- `save_post` — 保存 / 取消保存
- `get_authenticated_user`
## 快速开始
1. 在 <https://www.reddit.com/prefs/apps> 上创建一个 Reddit 应用(类型:**脚本**)。
2. 在环境变量或 `.env` 文件中设置凭证(参见 `.env.example`):
```bash
REDDIT_CLIENT_ID=...
REDDIT_CLIENT_SECRET=...
REDDIT_USER_AGENT=reddit-explorer-mcp/0.1 by <你的用户名>
# 可选,用于写入访问:
REDDIT_USERNAME=...
REDDIT_PASSWORD=...
```
3. 使用 `uvx` 运行(stdio 传输,本地 MCP 客户端的默认设置):
```bash
uvx reddit-explorer-mcp
```
或运行 HTTP 服务器:
```bash
uvx reddit-explorer-mcp --transport http --host 0.0.0.0 --port 8000
```
## 客户端配置
### Claude Desktop / Claude Code (`stdio`)
```json
{
"mcpServers": {
"reddit": {
"command": "uvx",
"args": ["reddit-explorer-mcp"],
"env": {
"REDDIT_CLIENT_ID": "...",
"REDDIT_CLIENT_SECRET": "...",
"REDDIT_USER_AGENT": "reddit-explorer-mcp/0.1 by <你的用户名>"
}
}
}
}
```
### HTTP 传输
```json
{
"mcpServers": {
"reddit": {
"url": "http://localhost:8000/mcp"
}
}
}
```
## 开发
```bash
uv sync
uv run reddit-mcp --help
uv run pytest
```
## 许可证
MIT