Skip to main content
Glama
raidenrock

USCardForum MCP Server

by raidenrock

search_forum

Search USCardForum for credit card discussions using queries with operators like in:title, @author, category:, #tag, and date filters.

Instructions

Search USCardForum for topics and posts matching a query.

Args:
    query: Search query string. Supports Discourse operators:
        - Basic: "chase sapphire bonus"
        - In title only: "chase sapphire in:title"
        - By author: "@username chase"
        - In category: "category:credit-cards chase"
        - With tag: "#amex bonus"
        - Exact phrase: '"sign up bonus"'
        - Exclude: "chase -sapphire"
        - Time: "after:2024-01-01" or "before:2024-06-01"

    page: Page number for pagination (starts at 1)

    order: Sort order for results. Options:
        - "relevance": Best match (default)
        - "latest": Most recent first
        - "views": Most viewed
        - "likes": Most liked
        - "activity": Recent activity
        - "posts": Most replies

Returns a SearchResult object with:
- posts: List of matching SearchPost objects with excerpts
- topics: List of matching SearchTopic objects
- users: List of matching SearchUser objects
- grouped_search_result: Metadata about result counts

Example queries:
- "Chase Sapphire Reserve order:latest" - Recent CSR discussions
- "AMEX popup in:title" - Topics about AMEX popup in title
- "data point category:credit-cards" - Data points in CC category
- "@expert_user order:likes" - Most liked posts by a user

Pagination: If more results exist, increment page parameter.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesSearch query string. Supports operators: 'in:title', '@username', 'category:name', '#tag', 'after:date', 'before:date'
pageNoPage number for pagination (starts at 1)
orderNoSort order: 'relevance' (default), 'latest', 'views', 'likes', 'activity', or 'posts'

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
postsNoMatching posts
usersNoMatching users
topicsNoMatching topics
grouped_search_resultNoResult metadata

Implementation Reference

  • Core handler function for the 'search_forum' MCP tool. Decorated with @mcp.tool(), defines input parameters with Pydantic Field descriptions, and delegates to the client's search method returning SearchResult.
    @mcp.tool()
    def search_forum(
        query: Annotated[
            str,
            Field(
                description="Search query string. Supports operators: 'in:title', '@username', 'category:name', '#tag', 'after:date', 'before:date'"
            ),
        ],
        page: Annotated[
            int | None,
            Field(default=None, description="Page number for pagination (starts at 1)"),
        ] = None,
        order: Annotated[
            str | None,
            Field(
                default=None,
                description="Sort order: 'relevance' (default), 'latest', 'views', 'likes', 'activity', or 'posts'",
            ),
        ] = None,
    ) -> SearchResult:
        """
        Search USCardForum for topics and posts matching a query.
    
        Args:
            query: Search query string. Supports Discourse operators:
                - Basic: "chase sapphire bonus"
                - In title only: "chase sapphire in:title"
                - By author: "@username chase"
                - In category: "category:credit-cards chase"
                - With tag: "#amex bonus"
                - Exact phrase: '"sign up bonus"'
                - Exclude: "chase -sapphire"
                - Time: "after:2024-01-01" or "before:2024-06-01"
    
            page: Page number for pagination (starts at 1)
    
            order: Sort order for results. Options:
                - "relevance": Best match (default)
                - "latest": Most recent first
                - "views": Most viewed
                - "likes": Most liked
                - "activity": Recent activity
                - "posts": Most replies
    
        Returns a SearchResult object with:
        - posts: List of matching SearchPost objects with excerpts
        - topics: List of matching SearchTopic objects
        - users: List of matching SearchUser objects
        - grouped_search_result: Metadata about result counts
    
        Example queries:
        - "Chase Sapphire Reserve order:latest" - Recent CSR discussions
        - "AMEX popup in:title" - Topics about AMEX popup in title
        - "data point category:credit-cards" - Data points in CC category
        - "@expert_user order:likes" - Most liked posts by a user
    
        Pagination: If more results exist, increment page parameter.
        """
        return get_client().search(query, page=page, order=order)
  • Pydantic BaseModel definitions for the SearchResult output type returned by search_forum, including supporting models SearchPost, SearchTopic, SearchUser, and GroupedSearchResult. Includes a factory method to parse from API responses.
    """Domain models for search results."""
    
    from __future__ import annotations
    
    from datetime import datetime
    from typing import Any
    
    from pydantic import BaseModel, Field
    
    
    class SearchPost(BaseModel):
        """A post in search results."""
    
        id: int = Field(..., description="Post ID")
        topic_id: int = Field(..., description="Parent topic ID")
        post_number: int = Field(..., description="Position in topic")
        username: str | None = Field(None, description="Author username")
        blurb: str | None = Field(None, description="Content excerpt with highlights")
        created_at: datetime | None = Field(None, description="When posted")
        like_count: int = Field(0, description="Number of likes")
    
        class Config:
            extra = "ignore"
    
    
    class SearchTopic(BaseModel):
        """A topic in search results."""
    
        id: int = Field(..., description="Topic ID")
        title: str = Field(..., description="Topic title")
        posts_count: int = Field(0, description="Number of posts")
        views: int = Field(0, description="View count")
        like_count: int = Field(0, description="Total likes")
        category_id: int | None = Field(None, description="Category ID")
        category_name: str | None = Field(None, description="Category name")
        created_at: datetime | None = Field(None, description="Creation time")
    
        class Config:
            extra = "ignore"
    
    
    class SearchUser(BaseModel):
        """A user in search results."""
    
        id: int = Field(..., description="User ID")
        username: str = Field(..., description="Username")
        name: str | None = Field(None, description="Display name")
        avatar_template: str | None = Field(None, description="Avatar URL")
    
        class Config:
            extra = "ignore"
    
    
    class GroupedSearchResult(BaseModel):
        """Metadata about search result counts."""
    
        post_ids: list[int] = Field(default_factory=list, description="Matching post IDs")
        topic_ids: list[int] = Field(default_factory=list, description="Matching topic IDs")
        user_ids: list[int] = Field(default_factory=list, description="Matching user IDs")
        more_posts: bool | None = Field(None, description="More posts available")
        more_topics: bool | None = Field(None, description="More topics available")
    
        class Config:
            extra = "ignore"
    
    
    class SearchResult(BaseModel):
        """Complete search results."""
    
        posts: list[SearchPost] = Field(default_factory=list, description="Matching posts")
        topics: list[SearchTopic] = Field(
            default_factory=list, description="Matching topics"
        )
        users: list[SearchUser] = Field(default_factory=list, description="Matching users")
        grouped_search_result: GroupedSearchResult | None = Field(
            None, description="Result metadata"
        )
    
        class Config:
            extra = "ignore"
    
        @classmethod
        def from_api_response(cls, data: dict[str, Any]) -> SearchResult:
            """Parse from raw API response."""
            posts = [SearchPost(**p) for p in data.get("posts", [])]
            topics = [SearchTopic(**t) for t in data.get("topics", [])]
            users = [SearchUser(**u) for u in data.get("users", [])]
    
            grouped = None
            if "grouped_search_result" in data:
                grouped = GroupedSearchResult(**data["grouped_search_result"])
    
            return cls(
                posts=posts,
                topics=topics,
                users=users,
                grouped_search_result=grouped,
            )
  • Import of the search_forum tool function into the server_tools package __init__, enabling automatic @mcp.tool() registration when the package is imported.
    from .search import search_forum
  • Explicit inclusion of search_forum in the __all__ export list of the main server module, ensuring it's available for MCP server setup.
    "search_forum",
  • Listing of search_forum in the server_tools __all__ list, exporting the tool for use in the MCP server.
    "search_forum",
Behavior5/5

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

With no annotations provided, the description carries the full burden and excels by disclosing key behavioral traits: it explains the search functionality, pagination behavior (increment page parameter if more results exist), and the structure of the return object. It also details query operators and sort options, which are critical for effective tool use.

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

Conciseness5/5

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

The description is well-structured and front-loaded, starting with the core purpose, followed by detailed parameter explanations, return value description, and practical examples. Every sentence adds value, such as the operator examples and pagination note, with no redundant or unnecessary information.

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 (search with operators and pagination), no annotations, and the presence of an output schema, the description is highly complete. It covers purpose, usage, parameters, return values, and behavioral aspects like pagination, leaving no gaps for an AI agent to understand and invoke the tool correctly.

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

Parameters5/5

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

Despite 100% schema description coverage, the description adds significant value beyond the schema by providing detailed examples of query operators (e.g., 'in:title', '@username') and sort order options with practical use cases. It clarifies parameter interactions, such as how 'page' works with pagination, enhancing understanding beyond the basic schema definitions.

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 with a specific verb ('Search') and resource ('USCardForum for topics and posts'), distinguishing it from sibling tools like 'get_hot_topics' or 'get_new_topics' which retrieve predefined lists rather than performing custom searches. It explicitly mentions what is being searched (topics and posts) and matches the tool name directly.

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

Usage Guidelines4/5

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

The description provides clear context for when to use this tool (searching with a query) and includes example queries that illustrate common use cases. However, it does not explicitly state when not to use it or name specific alternatives among sibling tools, such as using 'get_topic_info' for detailed topic information instead of search results.

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

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