Skip to main content
Glama
TheOneTrueNiz

Grokipedia MCP Server

get_page_content

Read-onlyIdempotent

Retrieve complete article content from Grokipedia for comprehensive research and reading. Use this tool to access full articles with title and raw markdown content for detailed information gathering.

Instructions

Get full article content from Grokipedia (larger than get_page preview).

Use for: reading complete articles, comprehensive research, when you need all content. Returns: title, full content (up to max_length), content_length. Tips: Set max_length higher for very long articles. Returns raw markdown.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
slugYesUnique slug identifier of the page to retrieve content from
max_lengthNoMaximum length of content to return (default: 10000)

Implementation Reference

  • The get_page_content tool is registered using @mcp.tool and implemented as an async function in server.py. It fetches full article content from the Grokipedia API and supports content truncation and length limiting.
    @mcp.tool(
        annotations=ToolAnnotations(
            readOnlyHint=True,
            destructiveHint=False,
            idempotentHint=True
        )
    )
    async def get_page_content(
        slug: Annotated[str, Field(description="Unique slug identifier of the page to retrieve content from")],
        max_length: Annotated[int, Field(description="Maximum length of content to return (default: 10000)", ge=100)] = 10000,
        ctx: Context[ServerSession, AppContext] | None = None,
    ) -> CallToolResult:
        """Get full article content from Grokipedia (larger than get_page preview).
    
        Use for: reading complete articles, comprehensive research, when you need all content.
        Returns: title, full content (up to max_length), content_length.
        Tips: Set max_length higher for very long articles. Returns raw markdown.
        """
        if ctx is None:
            raise ValueError("Context is required")
    
        await ctx.debug(f"Fetching content for: '{slug}'")
    
        try:
            client = ctx.request_context.lifespan_context.client
            result = await client.get_page(slug=slug, include_content=True)
    
            if not result.found or result.page is None:
                await ctx.warning(f"Page not found: '{slug}'")
                raise ValueError(f"Page not found: {slug}")
    
            page = result.page
            content = page.content or ""
            content_len = len(content)
            is_truncated = content_len > max_length
            
            if is_truncated:
                content = content[:max_length]
                await ctx.warning(
                    f"Content truncated from {content_len} to {max_length} chars. "
                    f"Use max_length parameter to adjust."
                )
            
            await ctx.info(f"Retrieved content for: '{page.title}' ({content_len} chars)")
            
            text_output = f"# {page.title}\n\n{content}"
            if is_truncated:
                text_output += f"\n\n... (truncated at {max_length} of {content_len} chars)"
            
            structured = {
                "slug": page.slug,
                "title": page.title,
                "content": content,
                "content_length": len(content),
            }
            
            if is_truncated:
                structured["_truncated"] = True
                structured["_original_length"] = content_len
            
            return CallToolResult(
                content=[TextContent(type="text", text=text_output)],
                structuredContent=structured,
            )
    
        except GrokipediaNotFoundError as e:
            await ctx.error(f"Page not found: {e}")
            raise ValueError(f"Page not found: {slug}") from e
        except GrokipediaBadRequestError as e:
            await ctx.error(f"Bad request: {e}")
            raise ValueError(f"Invalid page slug: {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

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