Skip to main content
Glama

Reddit MCP Tool

test_sync.py•1.82 kB
#!/usr/bin/env python3 """ Simple sync test of Reddit credentials. """ from reddit_mcp.config import RedditConfig from reddit_mcp.reddit_client import RedditClient def main(): """Test Reddit client synchronously.""" try: print("šŸ”§ Testing Reddit API credentials...") # Initialize configuration config = RedditConfig.from_env() print(f"āœ… Configuration loaded") print(f" Client ID: {config.client_id[:8]}...") print(f" User Agent: {config.user_agent}") # Initialize client client = RedditClient(config) print("āœ… Reddit client initialized") # Test a simple API call print("\nšŸ” Testing API call: Getting r/test subreddit info...") subreddit_info = client.get_subreddit_info("test") print(f"āœ… Success! Subreddit: {subreddit_info['name']}") print(f" Subscribers: {subreddit_info['subscribers']:,}") print(f" Description: {subreddit_info['description'][:100]}...") print("\nšŸ” Testing search: Searching for 'hello' in r/test...") posts = client.search_posts("test", "hello", limit=3) print(f"āœ… Success! Found {len(posts)} posts") for i, post in enumerate(posts, 1): print(f" {i}. {post['title'][:50]}... (Score: {post['score']})") print("\nšŸŽ‰ All tests passed! Your Reddit MCP Tool is working correctly!") except Exception as e: print(f"āŒ Error: {str(e)}") print("\nšŸ”§ Troubleshooting tips:") print("1. Check your .env file has correct Reddit API credentials") print("2. Verify your Reddit app is type 'script'") print("3. Make sure your app credentials are copied correctly") 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