项目简介
MCP Reddit Server 是一个基于 Model Context Protocol (MCP) 构建的应用后端,旨在为大型语言模型(LLM)客户端提供访问 Reddit 平台内容的工具。通过此服务器,LLM 可以获取 Reddit 上的热门帖子、特定帖子的详细内容(包括评论)以及不同类型的帖子信息。
主要功能点
- 获取热门帖子:可以从指定的 Reddit 子版块抓取最新的热门帖子列表,帮助 LLM 了解社区热点话题。
- 获取帖子详细内容:可以根据帖子ID抓取帖子的完整内容,包括标题、正文、作者以及评论,支持获取多层评论树,方便 LLM 进行深入分析。
- 支持多种帖子类型:能够处理文本、链接和图集等不同类型的 Reddit 帖子。
安装步骤
通过 Smithery 自动安装(推荐)
如果您使用 Claude Desktop 等兼容 Smithery 的 MCP 客户端,可以使用以下命令一键安装 Reddit Content 服务器:
npx -y @smithery/cli install @adhikasp/mcp-reddit --client claude
手动安装
对于不支持 Smithery 的 MCP 客户端,或者需要更灵活的配置,可以手动配置 MCP 服务器信息。您需要将以下 JSON 配置添加到您的 MCP 客户端配置中,通常是在客户端的服务器配置文件中:
{ "reddit": { "command": "uvx", "args": ["--from", "git+https://github.com/adhikasp/mcp-reddit.git", "mcp-reddit"], "env": {} } }
配置参数说明:
- 'reddit': 服务器名称,可以自定义,用于在客户端中标识和调用此服务器。
- 'command': 启动服务器的命令,这里 'uvx' 可能是一个用于执行 Python 脚本的环境或工具。
- 'args': 传递给 'command' 的参数,'--from git+https://github.com/adhikasp/mcp-reddit.git mcp-reddit' 指示从 GitHub 仓库 'https://github.com/adhikasp/mcp-reddit.git' 下载代码并执行 'mcp-reddit'。
- 'env': 环境变量,此处为空,表示使用默认环境变量。
注意: 手动安装方式可能需要您预先安装 Python 环境和相关的依赖库(例如 'fastmcp'、'redditwarp' 等),具体请参考仓库的详细安装文档(如果提供)。
基本使用方法
安装并配置完成后,您可以使用 MCP 客户端向 Reddit Content 服务器发送请求。例如,使用 'mcp-client-cli' 客户端,您可以执行类似以下的命令来查询 Reddit 内容:
llm "fetch latest hot thread in r/victoria3 from reddit"
或者在您的 LLM 应用中,通过 MCP 客户端库调用相应的工具(例如 'fetch_reddit_hot_threads' 或 'fetch_reddit_post_content')来获取 Reddit 数据。具体工具名称和参数请参考代码中的 '@mcp.tool()' 注解部分。
@mcp.tool() async def fetch_reddit_hot_threads(subreddit: str, limit: int = 10) -> str: """ Fetch hot threads from a subreddit ... """ @mcp.tool() async def fetch_reddit_post_content(post_id: str, comment_limit: int = 20, comment_depth: int = 3) -> str: """ Fetch detailed content of a specific post ... """
请根据您的 MCP 客户端的具体使用方式,参考以上工具定义来调用 Reddit Content 服务器的功能。
信息
分类
网页与API