Skip to main content
Glama
qinyuanpei

Weibo MCP Server

get_comments

Retrieve comments from a specific Weibo post using its unique identifier. Supports pagination to access all available responses.

Instructions

Get comments for a specific Weibo post.
    
Returns:
    list[dict]: List of dictionaries containing comments

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
feed_idYesThe unique identifier of the Weibo post
pageNoPage number for pagination, defaults to 1

Implementation Reference

  • MCP tool handler and registration for 'get_comments'. Defines input schema via Annotated Fields and delegates execution to WeiboCrawler.get_comments.
    @mcp.tool()
    async def get_comments(
        ctx: Context, 
        feed_id: Annotated[int, Field(description="The unique identifier of the Weibo post")], 
        page: Annotated[int, Field(description="Page number for pagination, defaults to 1", default=1)] = 1
        ) -> list[dict]:
        """
        Get comments for a specific Weibo post.
            
        Returns:
            list[dict]: List of dictionaries containing comments
        """
        return await crawler.get_comments(feed_id, page)
  • Core implementation of the get_comments functionality in WeiboCrawler. Performs HTTP GET to Weibo comments API, parses JSON response, and converts comments using helper.
    async def get_comments(self, feed_id: str, page: int = 1) -> list[CommentItem]:
        """
        Get comments for a specific Weibo post.
    
        Args:
            feed_id (str): The ID of the Weibo post
            page (int): The page number for pagination, defaults to 1
    
        Returns:
            list[CommentItem]: List of comments for the specified Weibo post
        """
        try:
            async with httpx.AsyncClient() as client:
                url = COMMENTS_URL.format(feed_id=feed_id, page=page)
                response = await client.get(url, headers=DEFAULT_HEADERS)
                data = response.json()
                comments = data.get('data', {}).get('data', [])
                return [self._to_comment_item(comment) for comment in comments]
        except httpx.HTTPError:
            self.logger.error(f"Unable to fetch comments for feed_id '{feed_id}'", exc_info=True)
            return []
  • Pydantic BaseModel defining the structure of individual comment items returned by the tool.
    class CommentItem(BaseModel):
        """
        Data model for a single comment on a Weibo post.
        
        Attributes:
            id (int): Unique identifier for the comment
            text (str): Content of the comment
            created_at (str): Timestamp when the comment was created
            user (UserProfile): User information associated with the comment
            like_count (int): Number of likes on the comment
            reply_count (int): Number of replies to the comment
        """
        id: int = Field()
        text: str = Field()
        created_at: str = Field()
        source: str = Field()
        user: UserProfile = Field()
        reply_id: Union[int, None] = Field(default=None)
        reply_text: str = Field(default="")
  • Supporting utility function that transforms raw dictionary from Weibo API into a structured CommentItem model.
    def _to_comment_item(self, item: dict) -> CommentItem:
        """
        Convert raw comment data to CommentItem object.
    
        Args:
            item (dict): Raw comment data from Weibo API
    
        Returns:
            CommentItem: Formatted comment information
        """
        return CommentItem(
            id = item.get('id'),
            text = item.get('text'),
            created_at = item.get('created_at'),
            user = self._to_user_profile(item.get('user', {})),
            source=item.get('source', ''),
            reply_id = item.get('reply_id', None),
            reply_text = item.get('reply_text', ''),
        )
  • Constant URL template used to construct the API endpoint for retrieving post comments.
    # URL template for fetching comments of a specific Weibo post
    # {feed_id}: The ID of the Weibo post
    # {page}: The page number for pagination
    COMMENTS_URL = 'https://m.weibo.cn/api/comments/show?id={feed_id}&page={page}'
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It mentions that the tool 'Returns: list[dict]: List of dictionaries containing comments,' which gives some output context, but it doesn't cover critical aspects like pagination behavior (implied by the 'page' parameter), rate limits, authentication needs, or error handling. For a tool with no annotations, this is insufficient.

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 concise and well-structured, with two sentences that directly state the purpose and return value. There's no unnecessary information, and it's front-loaded with the main action. However, it could be slightly improved by integrating the return information more seamlessly, but it's still efficient.

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

Completeness3/5

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

Given the tool's moderate complexity (2 parameters, no annotations, no output schema), the description is partially complete. It covers the basic purpose and return format, but lacks details on behavioral traits like pagination, error cases, or how it differs from siblings. Without an output schema, more explanation of the return structure would be helpful, but it's minimally adequate.

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

Parameters3/5

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

Schema description coverage is 100%, with clear descriptions for both parameters ('feed_id' as the Weibo post identifier and 'page' for pagination). The description adds no additional parameter semantics beyond what the schema provides, such as format details or usage examples. Given the high schema coverage, a baseline score of 3 is appropriate as the schema does the heavy lifting.

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

Purpose4/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 comments for a specific Weibo post.' It specifies the verb ('Get') and resource ('comments for a Weibo post'), making it easy to understand. However, it doesn't explicitly differentiate from sibling tools like 'get_feeds' or 'search_content', which might also retrieve post-related data, so it doesn't reach the highest score.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention sibling tools like 'get_feeds' (which might retrieve posts) or 'search_content' (which might include comments), nor does it specify prerequisites or exclusions. This lack of contextual usage information leaves the agent without clear direction.

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/qinyuanpei/mcp-server-weibo'

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