Files
Agent-Reach/agent_reach/channels/reddit.py
T
Pnant 5d046ecb61 fix(reddit): switch to Exa-only for search and read, remove proxy dependency
Reddit blocks nearly all non-browser access at IP level (including ISP proxies).
Switch Reddit channel to use Exa exclusively:
- Search: web_search_exa with includeDomains: ["reddit.com"]
- Read: crawling_exa for full post + comments
- check() now verifies Exa availability instead of probing Reddit API
- tier changed from 1 (needs config) to 0 (zero config)
- Removed reddit_proxy from config, CLI, and setup guide
- Updated all docs (README, README_en, install.md, SKILL.md, references)
- Fixed xreach→bird references in references/social.md

Fixes #218, Fixes #222, Fixes #221

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-31 14:21:31 +08:00

43 lines
1.3 KiB
Python

# -*- coding: utf-8 -*-
"""Reddit — search and read via Exa (no direct Reddit API needed)."""
import shutil
import subprocess
from .base import Channel
def _exa_available() -> bool:
"""Return True if mcporter is installed and Exa MCP is configured."""
mcporter = shutil.which("mcporter")
if not mcporter:
return False
try:
r = subprocess.run(
[mcporter, "config", "list"], capture_output=True,
encoding="utf-8", errors="replace", timeout=5
)
return "exa" in r.stdout.lower()
except Exception:
return False
class RedditChannel(Channel):
name = "reddit"
description = "Reddit 帖子和评论(通过 Exa 搜索和阅读)"
backends = ["Exa via mcporter"]
tier = 0
def can_handle(self, url: str) -> bool:
from urllib.parse import urlparse
d = urlparse(url).netloc.lower()
return "reddit.com" in d or "redd.it" in d
def check(self, config=None):
if _exa_available():
return "ok", "通过 Exa 搜索和阅读 Reddit 内容(免费,无需代理)"
return "off", (
"需要 mcporter + Exa MCP。安装:\n"
" npm install -g mcporter\n"
" mcporter config add exa https://mcp.exa.ai/mcp"
)