get_page_content
Extract clean article text from Grokipedia pages, removing citations and metadata to provide focused content for research and analysis.
Instructions
Get only the article content without citations or metadata.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| slug | Yes | Unique slug identifier of the page to retrieve content from | |
| max_length | No | Maximum length of content to return (default: 10000) |
Implementation Reference
- grokipedia_mcp/server.py:216-267 (handler)The core handler function that implements the get_page_content tool logic. It retrieves the full content of a specified Grokipedia page by slug, handles truncation if necessary, and returns both text and structured content via CallToolResult.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 only the article content without citations or metadata.""" 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, )
- grokipedia_mcp/server.py:209-215 (registration)The @mcp.tool decorator registers the get_page_content function as an MCP tool with appropriate annotations indicating it is read-only, non-destructive, and idempotent.@mcp.tool( annotations=ToolAnnotations( readOnlyHint=True, destructiveHint=False, idempotentHint=True ) )
- grokipedia_mcp/server.py:217-219 (schema)Pydantic-based input schema definitions using Annotated types and Field for the tool parameters: slug (required string), max_length (optional int with constraints), and ctx (internal context).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,
- grokipedia_mcp/server.py:187-188 (helper)Reference to the get_page_content tool in the get_page handler's warning message when content is truncated.f"Use get_page_content tool for full content access." )