Reddit数据接口服务

通过统一的API接口访问Reddit数据,支持TOON格式以节省90%以上的令牌使用。

  • by Jing-yilin
  • TypeScript
  • 本地部署
  • 更新于
在 GitHub 查看 Jing-yilin/reddit-mcp

使用说明

Reddit MCP服务器

用于Reddit API的MCP服务器-通过统一的API接口访问Reddit数据,采用TOON格式,可节省90%以上的代币。

特性

  • 从任何子版块获取热门/新/热门帖子
  • 获取详细的帖子内容,包括评论树
  • 按查询搜索Reddit帖子
  • 获取用户资料信息和活动
  • 获取subreddit信息
  • 以TOON格式返回数据以提高令牌效率
  • 企业环境的代理支持

安装

npm install @yilin-jing/reddit-mcp

或者直接运行:

npx @yilin-jing/reddit-mcp

配置

克劳德桌面版

添加到您的Claude桌面配置(~/Library/Application Support/Claude/claude_desktop_config.json):

{
  "mcpServers": {
    "reddit": {
      "command": "npx",
      "args": ["-y", "@yilin-jing/reddit-mcp"],
      "env": {}
    }
  }
}

环境变量(可选)

  • PROXY_URL -HTTP/HTTPS代理URL
  • HTTP_PROXY -替代代理设置
  • HTTPS_PROXY -替代代理设置

可用工具

工具 说明
get_subreddit_hot 从subreddit获取热门帖子
get_subreddit_new 从subreddit获取新帖子
get_subreddit_top 从subreddit获取热门帖子(带时间过滤器)
get_post_content 使用评论树获取帖子详细信息
search_posts 按查询搜索Reddit帖子
get_user_info 获取Reddit用户资料信息
get_user_posts 获取用户提交的帖子
get_user_comments 获取用户的评论
get_subreddit_info 获取subreddit信息

使用示例

从Subreddit获取热门帖子

Tool: get_subreddit_hot
Args: { "subreddit": "programming", "limit": 10 }

获取本周热门帖子

Tool: get_subreddit_top
Args: { "subreddit": "askreddit", "time": "week", "limit": 20 }

获取带有评论的帖子内容

Tool: get_post_content
Args: { "post_id": "abc123", "comment_limit": 30, "comment_depth": 5 }

搜索文章

Tool: search_posts
Args: { "query": "typescript tutorial", "subreddit": "programming", "sort": "top", "time": "month" }

获取用户信息

Tool: get_user_info
Args: { "username": "spez" }

输出格式

所有响应均以TOON格式返回,以实现最大的令牌效率。清理后的帖子数据示例:

id:"abc123"
title:"Example Post Title"
subreddit:"programming"
author:"username"
score:1234
upvoteRatio:0.95
comments:56
created:"2024-01-15T10:30:00.000Z"
url:"https://example.com"
permalink:"https://reddit.com/r/programming/comments/abc123/example_post/"

发展

# Install dependencies
npm install

# Build
npm run build

# Run in development
npm run dev

# Run tests
npm test

许可证

麻省理工学院