Skip to main content
Glama
rhettlong

USCardForum MCP Server

by rhettlong

get_topic_info

Retrieve topic metadata like post count and title to plan pagination before reading content from USCardForum discussions.

Instructions

Get metadata about a specific topic without fetching all posts.

Args:
    topic_id: The numeric topic ID (from URLs like /t/slug/12345)

Use this FIRST before reading a topic to:
- Check how many posts it contains (for pagination planning)
- Get the topic title and timestamps
- Decide whether to fetch all posts or paginate

Returns a TopicInfo object with:
- topic_id: The topic ID
- title: Full topic title
- post_count: Total number of posts
- highest_post_number: Last post number (may differ from count if posts deleted)
- last_posted_at: When the last reply was made

Strategy for large topics:
- <50 posts: Safe to fetch all at once
- 50-200 posts: Consider using max_posts parameter
- >200 posts: Fetch in batches or summarize key posts

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
topic_idYesThe numeric topic ID (from URLs like /t/slug/12345)

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
titleNoTopic title
topic_idYesTopic identifier
post_countNoTotal number of posts
last_posted_atNoLast activity time
highest_post_numberNoHighest post number

Implementation Reference

  • MCP tool handler for get_topic_info. Defines input schema (topic_id: int with description) and delegates execution to the DiscourseClient.get_topic_info method.
    @mcp.tool()
    def get_topic_info(
        topic_id: Annotated[
            int,
            Field(description="The numeric topic ID (from URLs like /t/slug/12345)"),
        ],
    ) -> TopicInfo:
        """
        Get metadata about a specific topic without fetching all posts.
    
        Args:
            topic_id: The numeric topic ID (from URLs like /t/slug/12345)
    
        Use this FIRST before reading a topic to:
        - Check how many posts it contains (for pagination planning)
        - Get the topic title and timestamps
        - Decide whether to fetch all posts or paginate
    
        Returns a TopicInfo object with:
        - topic_id: The topic ID
        - title: Full topic title
        - post_count: Total number of posts
        - highest_post_number: Last post number (may differ from count if posts deleted)
        - last_posted_at: When the last reply was made
    
        Strategy for large topics:
        - <50 posts: Safe to fetch all at once
        - 50-200 posts: Consider using max_posts parameter
        - >200 posts: Fetch in batches or summarize key posts
        """
        return get_client().get_topic_info(topic_id)
  • Imports the get_topic_info tool (line 27) as part of all MCP tools, registering it for exposure in the FastMCP server entrypoint. Included in __all__.
    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,
    )
    
    __all__ = [
        "MCP_HOST",
        "MCP_PORT",
        "MCP_TRANSPORT",
        "NITAN_TOKEN",
        "SERVER_INSTRUCTIONS",
        "get_client",
        "main",
        "mcp",
        "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",
        "resource_categories",
        "resource_hot_topics",
        "resource_new_topics",
        "search_forum",
        "subscribe_topic",
        "research_topic",
    ]
  • Core implementation in TopicsAPI: Performs HTTP GET to /t/{topic_id}.json, parses JSON response, constructs and returns TopicInfo model instance.
    def get_topic_info(self, topic_id: int) -> TopicInfo:
        """Fetch topic metadata.
    
        Args:
            topic_id: Topic ID
    
        Returns:
            Topic info with post count, title, timestamps
        """
        payload = self._get(f"/t/{int(topic_id)}.json")
        return TopicInfo(
            topic_id=topic_id,
            title=payload.get("title"),
            post_count=payload.get("posts_count", 0),
            highest_post_number=payload.get("highest_post_number", 0),
            last_posted_at=payload.get("last_posted_at"),
        )
  • DiscourseClient wrapper method that delegates to the underlying TopicsAPI.get_topic_info.
    def get_topic_info(self, topic_id: int) -> TopicInfo:
        """Fetch topic metadata.
    
        Args:
            topic_id: Topic ID
    
        Returns:
            Topic info with post count, title, timestamps
        """
        return self._topics.get_topic_info(topic_id)
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It effectively describes the tool's behavior: it's a read-only metadata fetch (implied by 'get'), returns a structured TopicInfo object, and includes strategic advice for handling large topics (e.g., safe thresholds, batching). However, it doesn't mention potential errors, rate limits, or authentication needs, leaving minor gaps.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is well-structured and appropriately sized, with clear sections for purpose, args, usage, returns, and strategy. Most sentences earn their place, but the strategy section could be slightly more concise. Overall, it's front-loaded with key information and avoids unnecessary repetition.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (single parameter, read-only metadata fetch), the description is complete. It covers purpose, usage, parameters, and behavioral context, and since an output schema exists (as indicated by context signals), it doesn't need to detail return values—though it still does for clarity. This addresses all necessary aspects without redundancy.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema description coverage is 100%, so the schema already documents the topic_id parameter. The description adds value by explaining the parameter's semantics: it's numeric and derived from URLs like '/t/slug/12345', which clarifies the format beyond the schema's basic type. This extra context justifies a score above the baseline of 3.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: 'Get metadata about a specific topic without fetching all posts.' It specifies the verb ('get metadata'), resource ('specific topic'), and distinguishes it from sibling tools like get_all_topic_posts and get_topic_posts by emphasizing it doesn't fetch posts.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides explicit guidance on when to use this tool: 'Use this FIRST before reading a topic' for checking post count, title, timestamps, and deciding whether to fetch all posts or paginate. It also distinguishes it from alternatives by noting it's for metadata only, not fetching posts.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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

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