Skip to main content
Glama
rhettlong

USCardForum MCP Server

by rhettlong

search_forum

Search USCardForum for credit card discussions using queries with operators like in:title, @username, category:name, and sort by relevance, latest, views, or activity.

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'

Implementation Reference

  • The core handler function for the 'search_forum' tool, decorated with @mcp.tool(). It defines input parameters with descriptions (schema) and implements the logic by calling the client's search method.
    @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 for SearchResult, defining the output schema of the tool, along with component models (SearchPost, SearchTopic, etc.) defined earlier in the file.
    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,
            )
  • Imports the search_forum function into the server_tools package __init__.py for exposure and registration in the MCP server.
    from .topics import get_hot_topics, get_new_topics, get_top_topics
    from .search import search_forum
    from .categories import get_categories
  • Lists 'search_forum' in the __all__ export of the main server module, ensuring it's registered as an available MCP tool.
    "search_forum",

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