get_user_following
Retrieve a user's following list to discover community influencers, find related experts, and map social connections within USCardForum's credit card discussion platform.
Instructions
Fetch the list of users that a user follows.
Args:
username: The user's handle
page: Page number for pagination (optional)
Returns a FollowList object with:
- users: List of FollowUser objects
- total_count: Total users being followed
Use to:
- Discover influential users in the community
- Find related experts
- Map social connections
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| username | Yes | The user's handle | |
| page | No | Page number for pagination |
Implementation Reference
- The MCP tool handler for 'get_user_following'. Decorated with @mcp.tool(), defines input parameters with descriptions and return type FollowList. Implements the tool logic by calling the DiscourseClient's get_user_following method.@mcp.tool() def get_user_following( username: Annotated[ str, Field(description="The user's handle"), ], page: Annotated[ int | None, Field(default=None, description="Page number for pagination"), ] = None, ) -> FollowList: """ Fetch the list of users that a user follows. Args: username: The user's handle page: Page number for pagination (optional) Returns a FollowList object with: - users: List of FollowUser objects - total_count: Total users being followed Use to: - Discover influential users in the community - Find related experts - Map social connections """ return get_client().get_user_following(username, page=page)
- src/uscardforum/server_tools/__init__.py:37-45 (registration)Registration/exposure of the get_user_following tool from server_tools.users module, making it importable by the main 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,
- src/uscardforum/server.py:15-45 (registration)Imports all MCP tools including get_user_following (line 32) from server_tools, which triggers auto-registration via @mcp.tool() decorators in the main MCP server entrypoint.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, )
- src/uscardforum/api/users.py:211-247 (helper)Underlying API implementation in UsersAPI that performs the HTTP GET to the Discourse /u/{username}/follow/following.json endpoint, parses the response, and constructs the FollowList model.def get_user_following( self, username: str, page: int | None = None, ) -> FollowList: """Fetch users that a user follows. Args: username: User handle page: Optional page number Returns: List of followed users """ params_list: list[tuple[str, Any]] = [] if page is not None: params_list.append(("page", int(page))) payload = self._get( f"/u/{username}/follow/following.json", params=params_list, ) users = [] for u in payload.get("users", []): users.append(FollowUser( id=u.get("id", 0), username=u.get("username", ""), name=u.get("name"), avatar_template=u.get("avatar_template"), )) return FollowList( users=users, total_count=payload.get("total_count", len(users)), )
- src/uscardforum/client.py:408-422 (helper)DiscourseClient wrapper method that delegates to the internal UsersAPI.get_user_following, providing a unified client interface used by the MCP tool handler.def get_user_following( self, username: str, page: int | None = None, ) -> FollowList: """Fetch users that a user follows. Args: username: User handle page: Optional page number Returns: List of followed users """ return self._users.get_user_following(username, page=page)