Skip to main content
Glama

Reddit MCP Tool

test_basic.py•2.16 kB
#!/usr/bin/env python3 """ Most basic Reddit API test possible. """ import os import praw from dotenv import load_dotenv def main(): load_dotenv() print("šŸ”§ Ultra Basic Reddit Test") print("=" * 30) try: reddit = praw.Reddit( client_id=os.getenv("REDDIT_CLIENT_ID"), client_secret=os.getenv("REDDIT_CLIENT_SECRET"), user_agent=os.getenv("REDDIT_USER_AGENT"), ) print("āœ… Reddit instance created") print(f"šŸ“Š Read-only: {reddit.read_only}") # Test 1: Just get a subreddit object (no API call yet) print("\nšŸ” Test 1: Creating subreddit object...") sub = reddit.subreddit("python") print(f"āœ… Subreddit object created: {sub}") # Test 2: Access the name (minimal API call) print("\nšŸ” Test 2: Getting subreddit name...") try: name = sub.display_name print(f"āœ… Name: {name}") except Exception as e: print(f"āŒ Name failed: {e}") return # Test 3: Try to get one post (most basic content access) print("\nšŸ” Test 3: Getting one hot post...") try: posts = list(sub.hot(limit=1)) if posts: post = posts[0] print(f"āœ… Got post: {post.title[:50]}...") print(f" Score: {post.score}") print(f" Author: {post.author}") print("šŸŽ‰ SUCCESS! Your Reddit MCP Tool should work!") else: print("āš ļø No posts found") except Exception as e: print(f"āŒ Posts failed: {e}") print("\n🚨 This is the exact same error your MCP tool will have") # Test 4: Check Reddit API limits/status print(f"\nšŸ“ˆ Reddit API Status:") print(f" Read-only mode: {reddit.read_only}") # print(f" Auth: {reddit._core._authorized}") # This property doesn't exist in PRAW 7.x except Exception as e: print(f"āŒ Critical error: {e}") if __name__ == "__main__": main()

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/GeLi2001/reddit-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server