Reviewed-on: https://git.home.ms/jarianc/reddit-cli/pulls/1
Reddit CLI
A command-line interface for browsing Reddit posts with search capabilities, interactive post viewing, and AI-powered summarization.
Features
- Search Functionality: Search for Reddit posts by keyword/terms
- Results Display: Table view showing:
- Post number
- Subreddit name
- Post creation date
- Post title (main column)
- Post Navigation: Click on post number to view full post details
- Comments Viewer: Cycle through comments using 'c' key
- AI Integration: Get AI-generated summaries using Ollama API
- Pagination: Navigate between pages of results ('n' key)
- MCP Server: REST API endpoints for Reddit querying with resilience and retry logic
Project Structure
reddit-cli/
├── src/
│ ├── __init__.py
│ ├── main.py # Main application entrypoint
│ ├── mcp_server.py # MCP server implementation with REST endpoints
│ └── ai_client.py # Ollama AI integration
├── tests/
│ └── test_cli.py # Unit tests
├── setup.sh # Setup script for environment
├── run.sh # Run script to execute the application
├── requirements.txt # Project dependencies
└── README.md # This file
Installation
- Clone this repository:
git clone <repository-url>
cd reddit-cli
- Create and activate virtual environment:
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
- Install dependencies:
pip install -r requirements.txt
Usage
Running the CLI Interface
Run the CLI interface with a search query:
python -m src.main "python programming"
Or run without arguments to enter interactive mode:
python -m src.main
Running the MCP Server
Start the MCP server:
python src/mcp_server.py
The server will be available at http://localhost:5000
MCP Server Endpoints
Search Posts
GET /search?q={query}&limit={limit}&after={after}
Get Post Details
GET /posts/{post_id}
Get Post Comments
GET /posts/{post_id}/comments?limit={limit}
Get AI Summary
GET /posts/{post_id}/summary
Get Trending Posts
GET /trending?limit={limit}&after={after}
Health Check
GET /health
OpenAPI Specification
GET /openapi.json
Keyboard Controls
n- Go to next page of resultsc- Cycle through comments when viewing a posts- Get AI-generated summary for current postqor Ctrl+C - Quit the application- Number keys - Select specific post by number
Configuration
The application uses environment variables for configuration:
OLLAMA_BASE_URL- Ollama server address (default: http://192.168.8.223:11434)OLLAMA_MODEL- AI model to use (default: gpt-oss:20b)PORT- MCP server port (default: 5000)
Requirements
- Python 3.7+
- requests
- rich
- pyyaml
- flask
- flask-cors
- pytest
- pytest-cov
Testing
Run tests with:
python -m pytest tests/
Or run basic functionality checks:
python test_cli.py
Run MCP server tests:
python test_mcp_server.py
Contributing
- Fork the repository
- Create a feature branch
- Commit your changes
- Push to the branch
- Create a Pull Request
License
This project is licensed under the MIT License.
Description
Terminal Reddit client with search, interactive post viewing, and AI-powered post summarization.
Languages
Python
95.2%
Shell
3.8%
Dockerfile
1%