reddit_mcp
A Model Context Protocol server for reading public Reddit data and posting authenticated replies, enabling AI agents to interact with Reddit content.
README
Reddit MCP Server
A Model Context Protocol (MCP) server for querying Reddit data and posting content. Built for AI agents and LLM-powered applications.
Overview
The Reddit MCP Server enables LLM applications to:
- Read public Reddit data (posts, comments, user profiles) via efficient JSON parsing
- Write authenticated content (post replies) using Playwright browser automation
- Search subreddits with filtering, sorting, and pagination
- Validate input to prevent injection attacks
Perfect for AI research tools, content analysis systems, and bot development.
Quick Start
1. Installation
# Clone the repository
git clone https://github.com/ajaaysrinivaas/reddit_mcp.git
cd reddit_mcp
# Install dependencies
pip install -e .
Requirements: Python 3.12+
2. Start the Server
# Default stdio transport (recommended for MCP clients)
reddit-mcp-server
# Alternative transports
reddit-mcp-server --transport http # HTTP server
reddit-mcp-server --transport sse # Server-Sent Events
3. Use in Your Application
See API Documentation for complete tool reference.
Example: Query a subreddit
# Via MCP client
result = await client.call_tool("get_subreddit_posts", {
"subreddit": "Python",
"category": "hot",
"limit": 10
})
Features
🔍 Read Tools (Public API)
search_subreddit— Full-text search within communitiesget_subreddit_posts— Fetch trending, new, rising, or top postsget_post_thread— Retrieve post + comments (threaded view)get_user_profile— User karma, account age, public infoget_user_activity— Recent posts & comments from a user
✍️ Write Tools (Authenticated)
post_reply— Reply to threads or comments (requires authentication)
⚡ Technical Highlights
- Efficient JSON parsing — Strips verbose Reddit API responses down to LLM-relevant fields
- Input validation — Regex-based protection against injection attacks
- Multiple transports — stdio, HTTP, SSE, and streamable-HTTP support
- Zero external dependencies for reads — Uses only
aiohttpfor API calls - Browser automation — Playwright for authenticated write operations
Installation Options
Option A: Development Install (Editable)
pip install -e .
Changes to source code immediately reflected without reinstalling.
Option B: Standard Install
pip install .
Option C: With Development Dependencies
pip install -e ".[dev]" # If dev extras defined in pyproject.toml
Configuration
Environment Variables
Create a .env file (see .env.example if available):
# Optional: Reddit authentication (for write tools)
REDDIT_USERNAME=your_username
REDDIT_PASSWORD=your_password
# Optional: Browser automation settings
BROWSER_HEADLESS=true
BROWSER_TIMEOUT=30000
MCP Client Configuration
Add to your MCP client config (e.g., Claude Desktop, VS Code):
{
"mcpServers": {
"reddit": {
"command": "reddit-mcp-server",
"args": ["--transport", "stdio"]
}
}
}
Architecture
reddit_mcp_server/
├── server.py # FastMCP server initialization & lifecycle
├── cli_main.py # Command-line entry point
├── http_client.py # Shared aiohttp session for Reddit API
├── drivers/
│ └── browser.py # Playwright browser automation for auth write ops
└── tools/
├── read_tools.py # Public API read operations
└── write_tools.py # Authenticated write operations
API Documentation
For complete parameter descriptions, response schemas, and examples, see API.md.
Quick Reference
| Tool | Parameters | Returns |
|---|---|---|
search_subreddit |
subreddit, query, sort, time_filter, limit | Array of posts |
get_subreddit_posts |
subreddit, category, limit | Array of posts |
get_post_thread |
post_id, comment_limit, sort | { post, comments } |
get_user_profile |
username | User profile object |
get_user_activity |
username, activity_type, limit | Array of posts/comments |
post_reply |
url_or_id, content | Reply object |
Known Limitations
⚠️ Current Gaps
-
Authentication
- Login flow via CLI not yet implemented
- Write tools require manually maintaining browser session with cookies
- See #Future Work for planned auth flow
-
Error Handling
- Limited retry logic for API failures
- No built-in rate limit backoff (429 responses)
- Timeouts could be more descriptive
-
Testing
- Minimal unit test coverage
- No integration tests with live Reddit API
- Mock fixtures needed
-
Performance
- No client-side rate limiting
- May hit Reddit's API throttling at scale
Development
Project Structure
reddit_mcp_server/— Main packageserver.py— FastMCP server setuptools/— Tool implementationsdrivers/— Browser automation
tests/— Test suite (in progress)API.md— Full API documentationpyproject.toml— Project metadata and dependencies
Running Locally
# Install in editable mode
pip install -e .
# Start server
reddit-mcp-server --transport stdio
# In another terminal, test with curl (HTTP transport):
curl -X POST http://localhost:5000/tools/get_subreddit_posts \
-H "Content-Type: application/json" \
-d '{"subreddit": "python", "limit": 5}'
Contributing
We welcome contributions! To get started:
- Fork the repository
- Create a feature branch (
git checkout -b feature/my-feature) - Make your changes and test thoroughly
- Submit a pull request with a clear description
Areas for contribution:
- Test coverage (unit and integration)
- Authentication flow implementation
- Rate limiting and retry logic
- Documentation improvements
Troubleshooting
Server won't start
# Verify Python version
python --version # Should be 3.12+
# Check if dependencies installed
pip list | grep fastmcp
# Reinstall if needed
pip install -e . --force-reinstall
Tools not appearing in MCP client
- Ensure
.vscode/mcp.jsonhas correct path (see Configuration) - Restart your MCP client after changes
- Check server logs for startup errors
Write tools failing
- Verify browser automation tools installed:
python -m playwright install - Check
.envcredentials are correct - Ensure authenticated session is active
License
MIT License — see LICENSE file for details.
Resources
Support
- Issues: GitHub Issues
- Questions: Open a discussion or check existing issues
- Feedback: PRs and suggestions welcome!
-
Session Persistence — Browser state not persisted
- Browser sessions are ephemeral; login doesn't persist across server restarts
- Need to save/load browser cookies from disk
-
Comprehensive Validation — Limited input validation
- Only subreddit/username validated; comment IDs, URLs not fully validated
- Could add stricter type checking
Development
Running Tests
python -m pytest test_server.py
Building the Package
uv build
# or
python -m build
License
MIT
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。