Skip to main content
Glama
TheOneTrueNiz

Grokipedia MCP Server

search

Read-onlyIdempotent

Find AI-curated articles in Grokipedia's knowledge base for research and information discovery. Returns titles, snippets, and relevance scores to help locate specific content.

Instructions

Search Grokipedia (AI-curated knowledge base) for articles.

Use for: finding Grok-generated articles, discovering AI-synthesized knowledge, research. Returns: title, slug (for get_page), snippet, relevance score, view count. Tips: Use the slug from results with get_page/get_page_content for full articles.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesSearch query string to find matching articles
limitNoMaximum number of results to return (default: 12, max: 50)
offsetNoPagination offset for results (default: 0)
sort_byNoSort results by 'relevance' or 'views' (default: relevance)relevance
min_viewsNoFilter to articles with at least this many views (optional)

Implementation Reference

  • The 'search' tool is defined and registered using the @mcp.tool decorator. It implements search functionality by calling the Grokipedia API client.
    @mcp.tool(
        annotations=ToolAnnotations(
            readOnlyHint=True,
            destructiveHint=False,
            idempotentHint=True
        ), 
    )
    async def search(
        query: Annotated[str, Field(description="Search query string to find matching articles")],
        limit: Annotated[int, Field(description="Maximum number of results to return (default: 12, max: 50)", ge=1, le=50)] = 12,
        offset: Annotated[int, Field(description="Pagination offset for results (default: 0)", ge=0)] = 0,
        sort_by: Annotated[str, Field(description="Sort results by 'relevance' or 'views' (default: relevance)")] = "relevance",
        min_views: Annotated[int | None, Field(description="Filter to articles with at least this many views (optional)", ge=0)] = None,
        ctx: Context[ServerSession, AppContext] | None = None,
    ) -> CallToolResult:
        """Search Grokipedia (AI-curated knowledge base) for articles.
    
        Use for: finding Grok-generated articles, discovering AI-synthesized knowledge, research.
        Returns: title, slug (for get_page), snippet, relevance score, view count.
        Tips: Use the slug from results with get_page/get_page_content for full articles.
        """
        if ctx is None:
            raise ValueError("Context is required")
    
        await ctx.debug(f"Searching for: '{query}' (limit={limit}, offset={offset}, sort_by={sort_by})")
    
        try:
            client = ctx.request_context.lifespan_context.client
            result = await client.search(query=query, limit=limit * 2, offset=offset)
            
            results = result.results
            
            if min_views is not None:
                results = [r for r in results if r.view_count >= min_views]
                await ctx.debug(f"Filtered to {len(results)} results with min_views >= {min_views}")
            
            if sort_by == "views":
                results = sorted(results, key=lambda x: x.view_count, reverse=True)
                await ctx.debug("Sorted results by view count")
            
            results = results[:limit]
    
            await ctx.info(f"Found {len(results)} results for query: '{query}'")
            
            text_lines = [f"Found {len(results)} results for '{query}'"]
            if sort_by == "views":
                text_lines[0] += " (sorted by views)"
            if min_views:
                text_lines[0] += f" (min views: {min_views})"
            text_lines.append("")
            
            for i, item in enumerate(results, 1):
                text_lines.append(f"{i}. {item.title}")
                text_lines.append(f"   Slug: {item.slug}")
                text_lines.append(f"   Snippet: {item.snippet}")
                text_lines.append(f"   Relevance: {item.relevance_score:.3f}")
                text_lines.append(f"   Views: {item.view_count}")
                text_lines.append("")
            
            return CallToolResult(
                content=[TextContent(type="text", text="\n".join(text_lines))],
                structuredContent={"results": [r.model_dump() for r in results]},
            )
    
        except GrokipediaBadRequestError as e:
            await ctx.error(f"Bad request: {e}")
            raise ValueError(f"Invalid search parameters: {e}") from e
        except GrokipediaNetworkError as e:
            await ctx.error(f"Network error: {e}")
            raise RuntimeError(f"Failed to connect to Grokipedia API: {e}") from e
        except GrokipediaAPIError as e:
            await ctx.error(f"API error: {e}")
            raise RuntimeError(f"Grokipedia API error: {e}") from e
Behavior4/5

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

Annotations already declare read-only, idempotent, non-destructive traits. The description adds valuable behavioral context by documenting return fields ('title, slug, snippet, relevance score, view count') and data relationships (slug is specifically 'for get_page'), compensating for the missing output schema.

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?

Excellent structure with clear visual scanning cues ('Use for:', 'Returns:', 'Tips:'). Every sentence earns its place—no redundancy with structured fields. Front-loaded with the core action.

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?

Comprehensive given the tool complexity. Despite no output schema, the description documents return values. Combined with 100% input schema coverage and strong annotations, the description provides sufficient context for correct invocation and result handling.

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?

With 100% schema description coverage, the baseline is appropriately 3. The description does not add parameter-specific semantics beyond what's in the schema (e.g., no syntax examples or query formatting tips), but references 'relevance' and 'view count' which map to sort_by options.

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 opens with a specific verb ('Search') and clear resource ('Grokipedia'), distinguishing it from sibling 'get_page' tools that retrieve specific content. The parenthetical '(AI-curated knowledge base)' adds essential context about the data source.

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?

Explicitly lists use cases ('finding Grok-generated articles, discovering AI-synthesized knowledge, research') and provides a specific workflow tip linking to siblings ('Use the slug from results with get_page/get_page_content'). This clearly establishes when to use search vs. retrieval tools.

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/TheOneTrueNiz/mcp-grokipedia-tool'

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