Skip to main content
Glama

get_page

Read-onlyIdempotent

Retrieve complete page information including metadata, content preview, and citations summary using a unique slug identifier.

Instructions

Get complete page information including metadata, content preview, and citations summary.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
slugYesUnique slug identifier of the page to retrieve
max_content_lengthNoMaximum length of content to return (default: 5000)

Implementation Reference

  • The `get_page` tool handler: fetches a page by slug from Grokipedia API, returns metadata, content preview (truncated to max_content_length), citations summary. If page not found, searches for similar pages and suggests alternatives.
    async def get_page(
        slug: Annotated[str, Field(description="Unique slug identifier of the page to retrieve")],
        max_content_length: Annotated[int, Field(description="Maximum length of content to return (default: 5000)", ge=100)] = 5000,
        ctx: Context[ServerSession, AppContext] | None = None,
    ) -> CallToolResult:
        """Get complete page information including metadata, content preview, and citations summary."""
        if ctx is None:
            raise ValueError("Context is required")
    
        await ctx.debug(f"Fetching page: '{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}', searching for alternatives")
                search_result = await client.search(query=slug, limit=5)
                if search_result.results:
                    suggestions = [f"{r.title} ({r.slug})" for r in search_result.results[:3]]
                    await ctx.info(f"Found {len(search_result.results)} similar pages")
                    raise ValueError(
                        f"Page not found: {slug}. Did you mean one of these? {', '.join(suggestions)}"
                    )
                raise ValueError(f"Page not found: {slug}")
    
            await ctx.info(f"Retrieved page: '{result.page.title}' ({slug})")
            
            page = result.page
            content_len = len(page.content) if page.content else 0
            is_truncated = content_len > max_content_length
            
            text_parts = [
                f"# {page.title}",
                "",
                f"**Slug:** {page.slug}",
            ]
            
            if page.description:
                text_parts.extend(["", f"**Description:** {page.description}", ""])
            
            if page.content:
                preview_length = min(1000, max_content_length)
                text_parts.extend(["", "## Content Preview", "", page.content[:preview_length]])
                if content_len > preview_length:
                    text_parts.append(f"\n... (showing first {preview_length} of {content_len} chars)")
            
            if page.citations:
                text_parts.extend(["", f"## Citations ({len(page.citations)} total)", ""])
                for i, citation in enumerate(page.citations[:5], 1):
                    text_parts.append(f"{i}. {citation.title}: {citation.url}")
                if len(page.citations) > 5:
                    text_parts.append(f"... and {len(page.citations) - 5} more")
            
            page_dict = page.model_dump()
            if is_truncated:
                page_dict["content"] = page.content[:max_content_length]
                page_dict["_content_truncated"] = True
                page_dict["_original_length"] = content_len
                await ctx.warning(
                    f"Content truncated from {content_len} to {max_content_length} chars. "
                    f"Use get_page_content tool for full content access."
                )
            
            return CallToolResult(
                content=[TextContent(type="text", text="\n".join(text_parts))],
                structuredContent=page_dict,
            )
    
        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
  • The `get_page` tool is registered with FastMCP via the @mcp.tool decorator, with annotations marking it as read-only, non-destructive, and idempotent.
    @mcp.tool(
        annotations=ToolAnnotations(
            readOnlyHint=True,
            destructiveHint=False,
            idempotentHint=True
        )
    )
  • Input schema for get_page: slug (string, required), max_content_length (int, default 5000, ge=100), ctx (optional Context). Returns CallToolResult.
    async def get_page(
        slug: Annotated[str, Field(description="Unique slug identifier of the page to retrieve")],
        max_content_length: Annotated[int, Field(description="Maximum length of content to return (default: 5000)", ge=100)] = 5000,
        ctx: Context[ServerSession, AppContext] | None = None,
    ) -> CallToolResult:
  • Helper call: invokes client.get_page(slug=slug, include_content=True) to fetch page data from the Grokipedia API.
    return CallToolResult(
        content=[TextContent(type="text", text="\n".join(text_parts))],
        structuredContent=page_dict,
Behavior3/5

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

Annotations already provide readOnlyHint, destructiveHint, and idempotentHint. The description adds context about the return content but does not disclose any additional behavioral traits beyond what annotations cover.

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?

Single sentence with front-loaded verb and resource. Every word adds value with no redundancy.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a simple read tool with two parameters and no output schema, the description adequately explains what is returned. It covers the essential aspects needed for an agent to use it correctly.

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?

Schema description coverage is 100%, so the baseline is 3. The description adds minor context (e.g., 'content preview') but does not significantly enhance understanding beyond the schema.

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 verb 'Get' and the resource 'page information', and lists what is included (metadata, content preview, citations summary). This distinguishes it from sibling tools like get_page_citations and get_page_content.

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

Usage Guidelines2/5

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

No guidance on when to use this tool versus alternatives. For example, it does not mention that get_page_citations should be used if only citations are needed.

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

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