get_user_followers
Fetch the list of users following a specific USCardForum member to identify influential community contributors and analyze follower relationships.
Instructions
Fetch the list of users following a specific user.
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 followers
A high follower count often indicates an influential
or helpful community member.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| username | Yes | The user's handle | |
| page | No | Page number for pagination |
Implementation Reference
- The primary MCP tool handler for 'get_user_followers'. Decorated with @mcp.tool(), defines input schema using Pydantic Annotated and Field, includes comprehensive docstring, and implements logic by delegating to the DiscourseClient instance.@mcp.tool() def get_user_followers( 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 following a specific user. 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 followers A high follower count often indicates an influential or helpful community member. """ return get_client().get_user_followers(username, page=page)
- Input/output schema defined via function signature: username (str, required), page (int|None, optional), returns FollowList. Uses Pydantic Field for descriptions and validation.@mcp.tool() def get_user_followers( 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 following a specific user. 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 followers A high follower count often indicates an influential or helpful community member. """ return get_client().get_user_followers(username, page=page)
- src/uscardforum/api/users.py:248-284 (helper)Core API helper implementation in UsersAPI that performs the HTTP GET request to the Discourse /u/{username}/follow/followers.json endpoint, parses the JSON response, constructs FollowUser objects, and returns FollowList.def get_user_followers( self, username: str, page: int | None = None, ) -> FollowList: """Fetch users following a user. Args: username: User handle page: Optional page number Returns: List of follower 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/followers.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/server_tools/__init__.py:37-47 (registration)Import statement in server_tools/__init__.py that exposes get_user_followers from users.py, making it available for import and MCP registration.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)Main server.py imports all server_tools functions including get_user_followers to ensure they are loaded and registered as MCP tools when the server starts.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, )