get_user_reactions
Fetch a user's post reactions to identify their interests and values within the USCardForum community.
Instructions
Fetch a user's post reactions (likes, etc.).
Args:
username: The user's handle
offset: Pagination offset (optional)
Returns a UserReactions object with reaction data.
Use to see what content a user has reacted to,
which can indicate their interests and values.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| username | Yes | The user's handle | |
| offset | No | Pagination offset |
Implementation Reference
- The core MCP tool handler for 'get_user_reactions'. Decorated with @mcp.tool(), includes input schema via Pydantic Field annotations, detailed docstring, and implementation delegating to DiscourseClient.get_user_reactions via get_client() helper.@mcp.tool() def get_user_reactions( username: Annotated[ str, Field(description="The user's handle"), ], offset: Annotated[ int | None, Field(default=None, description="Pagination offset"), ] = None, ) -> UserReactions: """ Fetch a user's post reactions (likes, etc.). Args: username: The user's handle offset: Pagination offset (optional) Returns a UserReactions object with reaction data. Use to see what content a user has reacted to, which can indicate their interests and values. """ return get_client().get_user_reactions(username, offset=offset)
- src/uscardforum/server_tools/__init__.py:37-47 (registration)Re-exports the get_user_reactions tool (and other user tools) from server_tools.users, making it available when importing from server_tools package. This facilitates collection of all tools in server.py.from .users import ( get_user_summary, get_user_topics, get_user_replies, get_user_actions, get_user_badges, get_user_following, get_user_followers, get_user_reactions, list_users_with_badge, )
- src/uscardforum/server.py:15-45 (registration)Explicitly imports all MCP tools including get_user_reactions from server_tools package into the main server entrypoint. These imports trigger side-effect registration via @mcp.tool() decorators on the global mcp instance.from uscardforum.server_tools import ( analyze_user, bookmark_post, compare_cards, find_data_points, get_all_topic_posts, get_categories, get_current_session, get_hot_topics, get_new_topics, get_notifications, get_top_topics, get_topic_info, get_topic_posts, get_user_actions, get_user_badges, get_user_followers, get_user_following, get_user_reactions, get_user_replies, get_user_summary, get_user_topics, list_users_with_badge, login, research_topic, resource_categories, resource_hot_topics, resource_new_topics, search_forum, subscribe_topic, )
- Shared helper function get_client() used by the tool handler to obtain the DiscourseClient instance, handling singleton creation and optional auto-login.def get_client() -> DiscourseClient: """Get or create the Discourse client instance.""" global _client, _login_attempted if _client is None: base_url = os.environ.get("USCARDFORUM_URL", "https://www.uscardforum.com") timeout = float(os.environ.get("USCARDFORUM_TIMEOUT", "15.0")) _client = DiscourseClient(base_url=base_url, timeout_seconds=timeout) # Auto-login if credentials are provided if not _login_attempted: _login_attempted = True username = os.environ.get("NITAN_USERNAME") password = os.environ.get("NITAN_PASSWORD") if username and password: try: result = _client.login(username, password) if result.success: print(f"[uscardforum] Auto-login successful as '{result.username}'") elif result.requires_2fa: print( "[uscardforum] Auto-login failed: 2FA required. Use login() tool with second_factor_token." ) else: print( f"[uscardforum] Auto-login failed: {result.error or 'Unknown error'}" ) except Exception as e: # pragma: no cover - logging side effect print(f"[uscardforum] Auto-login error: {e}") return _client