一个全面的模型上下文协议(MCP)服务器,用于与Reddit集成。此服务器使AI代理能够通过标准化接口以编程方式与Reddit进行交互。
此MCP服务器提供了6个强大的工具来与Reddit进行交互:
REDDIT_CLIENT_ID - 您的Reddit应用客户端IDREDDIT_CLIENT_SECRET - 您的Reddit应用客户端密钥REDDIT_USERNAME - 您的Reddit用户名REDDIT_PASSWORD - 您的Reddit密码REDDIT_USER_AGENT - 用户代理字符串(可选,默认为 "mcp-reddit-agent/0.1")Linux/macOS:
# 克隆仓库
git clone https://github.com/KrishnaRandad2023/mcp-reddit
cd mcp-reddit
# 构建Docker镜像
make build
# 设置环境变量
export REDDIT_CLIENT_ID="your_client_id"
export REDDIT_CLIENT_SECRET="your_client_secret"
export REDDIT_USERNAME="your_username"
export REDDIT_PASSWORD="your_password"
# 测试服务器
make test
Windows (PowerShell/Batch):
# 克隆仓库
git clone https://github.com/<my-org>/reddit-mcp
cd reddit-mcp
# 构建Docker镜像
.\build.ps1 build
# 或使用简单的批处理文件: .\build-win.bat build
# 设置环境变量
$env:REDDIT_CLIENT_ID = "your_client_id"
$env:REDDIT_CLIENT_SECRET = "your_client_secret"
$env:REDDIT_USERNAME = "your_username"
$env:REDDIT_PASSWORD = "your_password"
# 测试服务器
.\build.ps1 test
# 或: .\build-win.bat test
# 创建服务器实例
task create -- --category social https://github.com/<my-org>/reddit-mcp \
-e REDDIT_CLIENT_ID=your_client_id \
-e REDDIT_USERNAME=your_username \
-e REDDIT_USER_AGENT="mcp-reddit-agent/0.1" \
-e REDDIT_CLIENT_SECRET=your_client_secret \
-e REDDIT_PASSWORD=your_password
# 构建工具
task build -- --tools reddit-mcp
# 导入目录
task catalog -- reddit-mcp
docker mcp catalog import $PWD/catalogs/reddit-mcp/catalog.yaml
docker run --rm -i \
-e REDDIT_CLIENT_ID="your_client_id" \
-e REDDIT_CLIENT_SECRET="your_client_secret" \
-e REDDIT_USERNAME="your_username" \
-e REDDIT_PASSWORD="your_password" \
-e REDDIT_USER_AGENT="mcp-reddit-agent/0.1" \
mcp/reddit-mcp:latest
从子版块获取热门帖子。
参数:
subreddit (字符串,必需) - 子版块名称limit (整数,可选) - 要获取的帖子数量(1-100,默认值:10)示例:
{
"subreddit": "technology",
"limit": 5
}
获取特定Reddit帖子的评论。
参数:
post_id (字符串,必需) - Reddit帖子ID(不带't3_'前缀)示例:
{
"post_id": "abc123"
}
在子版块中搜索帖子。
参数:
subreddit (字符串,必需) - 子版块名称query (字符串,必需) - 搜索查询limit (整数,可选) - 结果数量(1-100,默认值:110)示例:
{
"subreddit": "programming",
"query": "python tutorial",
"limit": 10
}
在Reddit帖子上发布评论。
参数:
post_id (字符串,必需) - Reddit帖子ID(不带't3_'前缀)comment_text (字符串,必需) - 要发布的评论文本示例:
{
"post_id": "abc123",
"comment_text": "Great post! Thanks for sharing."
}
获取关于子版块的详细信息。
参数:
subreddit (字符串,必需) - 子版块名称示例:
{
"subreddit": "MachineLearning"
}
在子版块中创建新帖子。
参数:
subreddit (字符串,必需) - 子版块名称title (字符串,必需) - 帖子标题content (字符串,可选) - 文本帖子的内容url (字符串,可选) - 链接帖子的URL注意: 必须提供content或url中的一个。
示例(文本帖子):
{
"subreddit": "test",
"title": "My Test Post",
"content": "This is a test post created via MCP."
}
示例(链接帖子):
{
"subreddit": "technology",
"title": "Interesting Article",
"url": "https://example.com/article"
}
# 克隆仓库
git clone https://github.com/<my-org>/reddit-mcp
cd reddit-mcp
# 安装依赖
pip install -r requirements.txt
# 本地运行(需要环境变量)
python src/server.py
Linux/macOS (Makefile):
make help # 显示帮助
make build # 构建Docker镜像
make test # 运行测试
make catalog # 生成MCP目录
make publish # 准备提交到注册表
make clean # 清理Docker镜像
Windows (PowerShell/Batch):
.\build.ps1 help # 显示帮助
.\build.ps1 build # 构建Docker镜像
.\build.ps1 test # 运行测试
.\build.ps1 catalog # 生成MCP目录
.\build.ps1 publish # 准备提交到注册表
.\build.ps1 clean # 清理Docker镜像
# 或使用简单的批处理文件:
.\build-win.bat build # 构建Docker镜像
.\build-win.bat test # 运行测试
.\build-win.bat catalog # 生成MCP目录
.\build-win.bat clean # 清理Docker镜像
reddit-mcp/
├── src/
│ └── server.py # 主MCP服务器实现
├── catalogs/
│ └── reddit-mcp/
│ └── catalog.yaml # MCP目录定义
├── Dockerfile # Docker容器定义
├── requirements.txt # Python依赖
├── server.json # MCP服务器元数据
├── tools.json # 工具定义
├── Makefile # 构建自动化
├── *.sh # 自动化脚本
└── README.md # 此文件
| 变量 | 必需 | 秘密 | 描述 |
|---|---|---|---|
REDDIT_CLIENT_ID | ✅ | ❌ | Reddit应用客户端ID |
REDDIT_CLIENT_SECRET | ✅ | ✅ | Reddit应用客户端密钥 |
REDDIT_USERNAME | ✅ | ❌ | 您的Reddit用户名 |
REDDIT_PASSWORD | ✅ | ✅ | 您的Reddit密码 |
REDDIT_USER_AGENT | ❌ | ❌ | 用户代理字符串(默认值:"mcp-reddit-agent/0.1") |
{
"mcpServers": {
"reddit": {
"command": "docker",
"args": [
"run",
"--rm",
"-i",
"-e",
"REDDIT_CLIENT_ID=your_client_id",
"-e",
"REDDIT_CLIENT_SECRET=your_client_secret",
"-e",
"REDDIT_USERNAME=your_username",
"-e",
"REDDIT_PASSWORD=your_password",
"-e",
"REDDIT_USER_AGENT=mcp-reddit-agent/0.1",
"mcp/reddit-mcp:latest"
]
}
}
}
获取最新帖子:
"获取r/technology的前5篇热门帖子"
搜索并评论:
"在r/programming中搜索Python教程,并对最顶部的结果发表评论"
子版块分析:
"获取r/MachineLearning的信息,并显示最近关于transformers的帖子"
此服务器已准备好提交到官方Docker MCP注册表:
本地构建和测试:
Linux/macOS:
make build
make test
Windows:
.\build.ps1 build
.\build.ps1 test
推送到Docker Hub:
docker tag mcp/reddit-mcp:latest your-dockerhub-username/reddit-mcp:latest
docker push your-dockerhub-username/reddit-mcp:latest
更新server.json中的仓库详情
提交到MCP注册表:
# 使用mcp-publisher CLI
mcp-publisher init
mcp-publisher login github
mcp-publisher publish
此服务器满足所有Docker MCP注册表的要求:
io.modelcontextprotocol.server.name="reddit-mcp"io.github.my-org/reddit-mcpmcp/reddit-mcpgit checkout -b feature/amazing-feature)git commit -m '添加惊人的特性')git push origin feature/amazing-feature)此项目根据MIT许可证发布 - 查看LICENSE文件了解详情。
准备提交到MCP注册表 🚀
此服务器完全配置好,可以按照所有贡献指南提交到官方Docker MCP注册表。