universal-mcp-applications 0.1.25__py3-none-any.whl → 0.1.32__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -44,9 +44,7 @@ class RedditApp(APIApplication):
44
44
  "User-Agent": "agentr-reddit-app/0.1 by AgentR",
45
45
  }
46
46
 
47
- def get_subreddit_posts(
48
- self, subreddit: str, limit: int = 5, timeframe: str = "day"
49
- ) -> dict[str, Any]:
47
+ def get_subreddit_posts(self, subreddit: str, limit: int = 5, timeframe: str = "day") -> dict[str, Any]:
50
48
  """
51
49
  Fetches a specified number of top-rated posts from a particular subreddit, allowing results to be filtered by a specific timeframe (e.g., 'day', 'week'). This is a simplified version compared to `get_subreddit_top_posts`, which uses more complex pagination parameters instead of a direct time filter.
52
50
 
@@ -56,7 +54,7 @@ class RedditApp(APIApplication):
56
54
  timeframe: The time period for top posts. Valid options: 'hour', 'day', 'week', 'month', 'year', 'all' (default: 'day')
57
55
 
58
56
  Returns:
59
- A formatted string containing a numbered list of top posts, including titles, authors, scores, and URLs, or an error message if the request fails
57
+ A dictionary containing a list of top posts with their details, or an error message if the request fails.
60
58
 
61
59
  Raises:
62
60
  RequestException: When the HTTP request to the Reddit API fails
@@ -69,34 +67,29 @@ class RedditApp(APIApplication):
69
67
  if timeframe not in valid_timeframes:
70
68
  return f"Error: Invalid timeframe '{timeframe}'. Please use one of: {', '.join(valid_timeframes)}"
71
69
  if not 1 <= limit <= 100:
72
- return (
73
- f"Error: Invalid limit '{limit}'. Please use a value between 1 and 100."
74
- )
70
+ return f"Error: Invalid limit '{limit}'. Please use a value between 1 and 100."
75
71
  url = f"{self.base_api_url}/r/{subreddit}/top"
76
72
  params = {"limit": limit, "t": timeframe}
77
- logger.info(
78
- f"Requesting top {limit} posts from r/{subreddit} for timeframe '{timeframe}'"
79
- )
73
+ logger.info(f"Requesting top {limit} posts from r/{subreddit} for timeframe '{timeframe}'")
80
74
  response = self._get(url, params=params)
81
75
  return self._handle_response(response)
82
76
 
83
- def search_subreddits(
84
- self, query: str, limit: int = 5, sort: str = "relevance"
85
- ) -> str:
77
+ def search_subreddits(self, query: str, limit: int = 5, sort: str = "relevance") -> dict[str, Any]:
86
78
  """
87
- Searches for subreddits by name and description using a query string, with results sortable by relevance or activity. Unlike the broader `search_reddit` function, this method exclusively discovers subreddits, not posts, comments, or users.
79
+ Finds subreddits based on a query string, searching their names and descriptions.
80
+ Results can be sorted by relevance or activity. This function is for discovering communities and does not search for posts or users, unlike the more general `search_reddit` function.
88
81
 
89
82
  Args:
90
- query: The text to search for in subreddit names and descriptions
91
- limit: The maximum number of subreddits to return, between 1 and 100 (default: 5)
92
- sort: The order of results, either 'relevance' or 'activity' (default: 'relevance')
83
+ query: The search query for subreddit names and descriptions.
84
+ limit: The maximum number of subreddits to return (1-100, default is 5).
85
+ sort: The sorting order for results. Can be 'relevance' or 'activity' (default is 'relevance').
93
86
 
94
87
  Returns:
95
- A formatted string containing a list of matching subreddits with their names, subscriber counts, and descriptions, or an error message if the search fails or parameters are invalid
88
+ A dictionary containing a list of matching subreddits, including their names, subscriber counts, and descriptions. Returns an error message on failure.
96
89
 
97
90
  Raises:
98
- RequestException: When the HTTP request to Reddit's API fails
99
- JSONDecodeError: When the API response contains invalid JSON
91
+ RequestException: If the API request to Reddit fails.
92
+ JSONDecodeError: If the API response is not valid JSON.
100
93
 
101
94
  Tags:
102
95
  search, important, reddit, api, query, format, list, validation
@@ -105,18 +98,14 @@ class RedditApp(APIApplication):
105
98
  if sort not in valid_sorts:
106
99
  return f"Error: Invalid sort option '{sort}'. Please use one of: {', '.join(valid_sorts)}"
107
100
  if not 1 <= limit <= 100:
108
- return (
109
- f"Error: Invalid limit '{limit}'. Please use a value between 1 and 100."
110
- )
101
+ return f"Error: Invalid limit '{limit}'. Please use a value between 1 and 100."
111
102
  url = f"{self.base_api_url}/subreddits/search"
112
103
  params = {
113
104
  "q": query,
114
105
  "limit": limit,
115
106
  "sort": sort,
116
107
  }
117
- logger.info(
118
- f"Searching for subreddits matching '{query}' (limit: {limit}, sort: {sort})"
119
- )
108
+ logger.info(f"Searching for subreddits matching '{query}' (limit: {limit}, sort: {sort})")
120
109
  response = self._get(url, params=params)
121
110
  return self._handle_response(response)
122
111
 
@@ -193,16 +182,10 @@ class RedditApp(APIApplication):
193
182
  logger.info(f"Submitting a new post to r/{subreddit}")
194
183
  response = self._post(url_api, data=data)
195
184
  response_json = response.json()
196
- if (
197
- response_json
198
- and "json" in response_json
199
- and "errors" in response_json["json"]
200
- ):
185
+ if response_json and "json" in response_json and "errors" in response_json["json"]:
201
186
  errors = response_json["json"]["errors"]
202
187
  if errors:
203
- error_message = ", ".join(
204
- [f"{code}: {message}" for code, message in errors]
205
- )
188
+ error_message = ", ".join([f"{code}: {message}" for code, message in errors])
206
189
  return f"Reddit API error: {error_message}"
207
190
  return response_json
208
191
 
@@ -317,7 +300,7 @@ class RedditApp(APIApplication):
317
300
  Retrieves the full profile information for the currently authenticated user by making a GET request to the `/api/v1/me` Reddit API endpoint. This differs from `get_user_profile`, which requires a username, and `get_current_user_karma`, which specifically fetches karma data.
318
301
 
319
302
  Returns:
320
- Any: API response data.
303
+ A dictionary containing the authenticated user's profile information.
321
304
 
322
305
  Tags:
323
306
  users
@@ -333,7 +316,7 @@ class RedditApp(APIApplication):
333
316
  Fetches the karma breakdown for the authenticated user from the Reddit API. This function specifically targets the `/api/v1/me/karma` endpoint, returning karma statistics per subreddit, which is more specific than `get_current_user_info` that retrieves general profile information.
334
317
 
335
318
  Returns:
336
- Any: API response data.
319
+ A dictionary containing the authenticated user's karma breakdown by subreddit.
337
320
 
338
321
  Tags:
339
322
  account
@@ -349,10 +332,10 @@ class RedditApp(APIApplication):
349
332
  Fetches a specific Reddit post's details and its complete comment tree using the post's unique ID. This function returns the entire discussion, including the original post and all associated comments, providing broader context than `get_comment_by_id` which only retrieves a single comment.
350
333
 
351
334
  Args:
352
- post_id (string): The Reddit post ID ( e.g. '1m734tx' for https://www.reddit.com/r/mcp/comments/1m734tx/comment/n4occ77/)
335
+ post_id (str): The Reddit post ID ( e.g. '1m734tx' for https://www.reddit.com/r/mcp/comments/1m734tx/comment/n4occ77/)
353
336
 
354
337
  Returns:
355
- Any: API response data containing post details and comments.
338
+ A dictionary containing the post details and its comment tree.
356
339
 
357
340
  Tags:
358
341
  listings, comments, posts, important
@@ -384,7 +367,7 @@ class RedditApp(APIApplication):
384
367
  sr_detail: Optional. Expand subreddit details.
385
368
 
386
369
  Returns:
387
- Any: API response data containing a list of controversial posts.
370
+ A dictionary containing a listing of controversial posts.
388
371
 
389
372
  Tags:
390
373
  listings, posts, controversial, read-only
@@ -429,7 +412,7 @@ class RedditApp(APIApplication):
429
412
  sr_detail: Optional. Expand subreddit details.
430
413
 
431
414
  Returns:
432
- Any: API response data containing a list of hot posts.
415
+ A dictionary containing a listing of hot posts.
433
416
 
434
417
  Tags:
435
418
  listings, posts, hot, read-only
@@ -473,7 +456,7 @@ class RedditApp(APIApplication):
473
456
  sr_detail: Optional. Expand subreddit details.
474
457
 
475
458
  Returns:
476
- Any: API response data containing a list of new posts.
459
+ A dictionary containing a listing of new posts.
477
460
 
478
461
  Tags:
479
462
  listings, posts, new, read-only
@@ -520,7 +503,7 @@ class RedditApp(APIApplication):
520
503
  sr_detail: Optional. Expand subreddit details.
521
504
 
522
505
  Returns:
523
- Any: API response data containing a list of hot posts from the subreddit.
506
+ A dictionary containing a listing of hot posts from the specified subreddit.
524
507
 
525
508
  Tags:
526
509
  listings, posts, subreddit, hot, read-only
@@ -568,7 +551,7 @@ class RedditApp(APIApplication):
568
551
  sr_detail: Optional. Expand subreddit details.
569
552
 
570
553
  Returns:
571
- Any: API response data containing a list of new posts from the subreddit.
554
+ A dictionary containing a listing of new posts from the specified subreddit.
572
555
 
573
556
  Tags:
574
557
  listings, posts, subreddit, new, read-only
@@ -615,7 +598,7 @@ class RedditApp(APIApplication):
615
598
  sr_detail: Optional. Expand subreddit details.
616
599
 
617
600
  Returns:
618
- Any: API response data containing a list of top posts from the subreddit.
601
+ A dictionary containing a listing of top posts from the specified subreddit.
619
602
 
620
603
  Tags:
621
604
  listings, posts, subreddit, top, read-only
@@ -660,7 +643,7 @@ class RedditApp(APIApplication):
660
643
  sr_detail: Optional. Expand subreddit details.
661
644
 
662
645
  Returns:
663
- Any: API response data containing a list of rising posts.
646
+ A dictionary containing a listing of rising posts.
664
647
 
665
648
  Tags:
666
649
  listings, posts, rising, read-only
@@ -703,7 +686,7 @@ class RedditApp(APIApplication):
703
686
  sr_detail: Optional. Expand subreddit details.
704
687
 
705
688
  Returns:
706
- Any: API response data containing a list of top posts.
689
+ A dictionary containing a listing of top posts.
707
690
 
708
691
  Tags:
709
692
  listings, posts, top, read-only
@@ -760,7 +743,7 @@ class RedditApp(APIApplication):
760
743
  type: Optional. A comma-separated list of result types ('sr', 'link', 'user').
761
744
 
762
745
  Returns:
763
- Any: API response data containing search results.
746
+ A dictionary containing the search results.
764
747
 
765
748
  Tags:
766
749
  search, reddit, posts, comments, users, read-only