Skip to main content
Glama
GodisinHisHeaven

USCardForum MCP Server

get_all_topic_posts

Fetch all posts from a USCardForum topic with automatic pagination, allowing control over post ranges and limits for efficient data retrieval.

Instructions

Fetch all posts from a topic with automatic pagination.

Args:
    topic_id: The numeric topic ID
    include_raw: Include markdown source (default: False)
    start_post_number: First post to fetch (default: 1)
    end_post_number: Last post to fetch (optional, fetches to end if not set)
    max_posts: Maximum number of posts to return (optional safety limit)

This automatically handles pagination to fetch multiple batches.

IMPORTANT: For topics with many posts (>100), use max_posts to limit
the response size. You can always fetch more with start_post_number.

Use cases:
- Fetch entire small topic: get_all_topic_posts(topic_id=123)
- Fetch first 50 posts: get_all_topic_posts(topic_id=123, max_posts=50)
- Fetch posts 51-100: get_all_topic_posts(topic_id=123, start_post_number=51, max_posts=50)
- Fetch specific range: get_all_topic_posts(topic_id=123, start=10, end=30)

Returns the same Post structure as get_topic_posts but for all matching posts.

Pro tip: Use get_topic_info first to check post_count before deciding
whether to fetch all or paginate manually.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
topic_idYesThe numeric topic ID
include_rawNoInclude markdown source (default: False)
start_post_numberNoFirst post to fetch (default: 1)
end_post_numberNoLast post to fetch (optional, fetches to end if not set)
max_postsNoMaximum number of posts to return (optional safety limit)

Implementation Reference

  • The primary MCP tool handler for 'get_all_topic_posts'. Decorated with @mcp.tool(), defines input schema via Annotated[Field], comprehensive docstring, and delegates execution to the DiscourseClient.get_all_topic_posts method.
    @mcp.tool()
    def get_all_topic_posts(
        topic_id: Annotated[
            int,
            Field(description="The numeric topic ID"),
        ],
        include_raw: Annotated[
            bool,
            Field(default=False, description="Include markdown source (default: False)"),
        ] = False,
        start_post_number: Annotated[
            int,
            Field(default=1, description="First post to fetch (default: 1)"),
        ] = 1,
        end_post_number: Annotated[
            int | None,
            Field(default=None, description="Last post to fetch (optional, fetches to end if not set)"),
        ] = None,
        max_posts: Annotated[
            int | None,
            Field(default=None, description="Maximum number of posts to return (optional safety limit)"),
        ] = None,
    ) -> list[Post]:
        """
        Fetch all posts from a topic with automatic pagination.
    
        Args:
            topic_id: The numeric topic ID
            include_raw: Include markdown source (default: False)
            start_post_number: First post to fetch (default: 1)
            end_post_number: Last post to fetch (optional, fetches to end if not set)
            max_posts: Maximum number of posts to return (optional safety limit)
    
        This automatically handles pagination to fetch multiple batches.
    
        IMPORTANT: For topics with many posts (>100), use max_posts to limit
        the response size. You can always fetch more with start_post_number.
    
        Use cases:
        - Fetch entire small topic: get_all_topic_posts(topic_id=123)
        - Fetch first 50 posts: get_all_topic_posts(topic_id=123, max_posts=50)
        - Fetch posts 51-100: get_all_topic_posts(topic_id=123, start_post_number=51, max_posts=50)
        - Fetch specific range: get_all_topic_posts(topic_id=123, start=10, end=30)
    
        Returns the same Post structure as get_topic_posts but for all matching posts.
    
        Pro tip: Use get_topic_info first to check post_count before deciding
        whether to fetch all or paginate manually.
        """
        return get_client().get_all_topic_posts(
            topic_id,
            include_raw=include_raw,
            start_post_number=start_post_number,
            end_post_number=end_post_number,
            max_posts=max_posts,
        )
  • Pydantic model defining the structure of each Post object returned by the tool (output schema: list[Post]). Includes fields like post_number, username, cooked/raw content, timestamps, and engagement metrics.
    class Post(BaseModel):
        """A single post within a topic."""
    
        id: int = Field(..., description="Unique post identifier")
        post_number: int = Field(..., description="Position in topic (1-indexed)")
        username: str = Field(..., description="Author's username")
        cooked: str | None = Field(None, description="HTML-rendered content")
        raw: str | None = Field(None, description="Raw markdown source")
        created_at: datetime | None = Field(None, description="When posted")
        updated_at: datetime | None = Field(None, description="Last edit time")
        like_count: int = Field(0, description="Number of likes")
        reply_count: int = Field(0, description="Number of direct replies")
        reply_to_post_number: int | None = Field(
            None, description="Post number this replies to"
        )
    
        class Config:
            extra = "ignore"
  • Imports the get_all_topic_posts tool function (line 20) along with all other MCP tools into the main server entrypoint module. This ensures the tool is loaded and registered automatically via its @mcp.tool() decorator when the MCP 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,
    )
  • Re-exports the get_all_topic_posts tool from the topics submodule, facilitating its import in the server.py entrypoint.
    from .topics import get_topic_info, get_topic_posts, get_all_topic_posts

Latest Blog Posts

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/GodisinHisHeaven/uscardforum-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server