使用说明
Reddit MCP服务器
模型上下文协议(MCP)服务器,提供对Reddit的API的访问,用于检索帖子、评论、用户信息和搜索功能。
特性
- 子涡流操作:使用各种排序选项从任何子版块获取帖子
- 岗位操作:检索特定帖子及其评论
- 用户操作:获取用户信息、帖子和评论
- 搜索:搜索帖子和子版块
- 认证:支持多种Reddit API身份验证方法
可用工具
get_subreddit_posts
从特定的subreddit获取帖子。
参数:
subreddit(必填):子版块的名称(不带r/前缀)sort(可选):排序顺序-hot,new,top,rising(默认值:hot)limit(可选):要检索的帖子数量,1-100(默认值:25)
get_post
获取特定Reddit帖子的详细信息。
参数:
postId(必填):Reddit帖子ID
get_post_comments
从Reddit帖子中获取评论。
参数:
postId(必填):Reddit帖子IDsort(可选):排序顺序-best,top,new,controversial,old(默认值:best)
get_subreddit_info
获取有关subreddit的信息。
参数:
subreddit(必填):子版块的名称(不带r/前缀)
get_user_info
获取Reddit用户的信息。
参数:
username(必填):Reddit用户名(不带u/前缀)
get_user_posts
获取用户提交的帖子。
参数:
username(必填):Reddit用户名(不带u/前缀)sort(可选):排序顺序-hot,new,top(默认值:new)limit(可选):要检索的帖子数量,1-100(默认值:25)
get_user_comments
获取用户的评论。
参数:
username(必填):Reddit用户名(不带u/前缀)sort(可选):排序顺序-hot,new,top(默认值:new)limit(可选):要检索的评论数,1-100(默认值:25)
search_posts
搜索Reddit帖子。
参数:
query(必填):搜索查询subreddit(可选):将搜索限制在特定的子版块sort(可选):排序顺序-relevance,hot,top,new,comments(默认值:relevance)limit(可选):要检索的结果数,1-100(默认值:25)
search_subreddits
搜索子版块。
参数:
query(必填):搜索子版块名称/描述limit(可选):要检索的结果数,1-100(默认值:25)
设置
1.Reddit API应用程序
- 首选https://www.reddit.com/prefs/apps
- 点击“创建应用程序”或“创建另一个应用程序”
- 选择应用程序类型:
- 脚本 个人使用
- Web 应用 用于服务器应用程序
- 注意你的 客户端ID (在应用程序名称下)和 客户端密钥
2.环境配置
复制 .env.example 向 .env 并配置:
cp .env.example .env
编辑 .env 使用您的Reddit API证书:
REDDIT_CLIENT_ID=your_client_id_here
REDDIT_CLIENT_SECRET=your_client_secret_here
REDDIT_USER_AGENT=reddit-mcp-server/1.0.0 by your_username
# Choose one authentication method:
REDDIT_USERNAME=your_username
REDDIT_PASSWORD=your_password
3.安装
npm install
4.建造
npm run build
5.使用克劳德代码
添加到您的Claude Code MCP配置中:
{
"mcpServers": {
"reddit": {
"command": "node",
"args": ["/path/to/reddit-mcp/dist/index.js"],
"env": {
"REDDIT_CLIENT_ID": "your_client_id",
"REDDIT_CLIENT_SECRET": "your_client_secret",
"REDDIT_USER_AGENT": "reddit-mcp-server/1.0.0 by your_username",
"REDDIT_USERNAME": "your_username",
"REDDIT_PASSWORD": "your_password"
}
}
}
}
身份验证方法
1.用户名/密码(建议个人使用)
REDDIT_USERNAME=your_username
REDDIT_PASSWORD=your_password
2.刷新令牌(建议用于生产)
REDDIT_REFRESH_TOKEN=your_refresh_token
3.访问令牌(仅用于测试-1小时后过期)
REDDIT_ACCESS_TOKEN=your_access_token
4.客户端凭据(只读访问)
将用户名/密码留空以使用客户端凭据流。
速率限制
Reddit API有费率限制:
- 免费套餐:每个OAuth客户端每分钟100个请求
- 请求的平均时间为10分钟
- 商业用途需要Reddit的许可
重要提示
- 用户代理:必须具有独特性和描述性
- 商业用途:需要Reddit的许可
- 数据保留:必须删除已从Reddit删除的用户内容
- 速率限制:内置身份验证令牌管理
发展
在开发模式下运行:
npm run dev
构建:
npm run build
清理构建工件:
npm run clean
数据类型
Reddit帖子
interface RedditPost {
id: string;
title: string;
author: string;
subreddit: string;
url: string;
selftext: string;
created_utc: number;
score: number;
num_comments: number;
permalink: string;
is_self: boolean;
domain: string;
thumbnail?: string;
}
Reddit评论
interface RedditComment {
id: string;
author: string;
body: string;
created_utc: number;
score: number;
permalink: string;
parent_id: string;
subreddit: string;
}
RedditSubreddit
interface RedditSubreddit {
display_name: string;
title: string;
description: string;
subscribers: number;
created_utc: number;
public_description: string;
url: string;
over18: boolean;
}
Reddit用户
interface RedditUser {
name: string;
id: string;
created_utc: number;
comment_karma: number;
link_karma: number;
is_verified: boolean;
has_verified_email: boolean;
}
许可证
麻省理工学院