Skip to main content
Glama

get_post_content

Extract a post's content, including title, subtitle, and HTML template, as JSON for easy reuse. Specify the post and publication IDs to retrieve structured data via the Beehiiv API.

Instructions

Retrieve a post's content as JSON to use as a template.

Args:
    publication_id: ID of the publication
    post_id: ID of the post

Returns:
    dict: JSON object containing post title, subtitle, and HTML content template

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
post_idYes
publication_idYes

Implementation Reference

  • The main handler function for the 'get_post_content' tool. It fetches the post content from the Beehiiv API using the provided publication_id and post_id, extracts title, subtitle, content_structure, and HTML template from the free web content, and returns them as a dictionary. Uses the beehiiv_request helper.
    @mcp.tool()
    async def get_post_content(publication_id: str, post_id: str) -> dict:
        """
        Retrieve a post's content as JSON to use as a template.
    
        Args:
            publication_id: ID of the publication
            post_id: ID of the post
        
        Returns:
            dict: JSON object containing post title, subtitle, and HTML content template
        """
        path = f"/publications/{publication_id}/posts/{post_id}"
        params = {
            "expand[]": "free_web_content"
        }
        
        data = await beehiiv_request("GET", path, params=params)
        
        if not data or "data" not in data:
            return {"error": "Failed to fetch the post."}
        
        post = data["data"]
        content = post.get("content", {})
        free_content = content.get("free", {})
        
        return {
            "title": post.get("title"),
            "subtitle": post.get("subtitle"),
            "content_structure": post.get("content_structure"),
            "html_template": free_content.get("web")
        }
  • The @mcp.tool() decorator registers the get_post_content function as an MCP tool.
    @mcp.tool()
  • Helper function used by get_post_content to make authenticated API requests to Beehiiv.
    async def beehiiv_request(
        method: str,
        path: str,
        params: Optional[dict[str, Any]] = None,
        json_body: Optional[dict[str, Any]] = None
    ) -> Optional[dict[str, Any]]:
        """
        Helper to call the beehiiv API v2.
    
        Args:
            method: HTTP method (GET, POST, etc.)
            path:   API path (e.g. '/publications')
            params: Query parameters
            json_body: Request JSON body
        """
        headers = {
            "Authorization": f"Bearer {BEEHIIV_API_KEY}",
            "Content-Type": "application/json"
        }
        url = f"{BASE_URL}{path}"
        async with httpx.AsyncClient() as client:
            try:
                response = await client.request(
                    method, url,
                    headers=headers,
                    params=params,
                    json=json_body,
                    timeout=30.0
                )
                response.raise_for_status()
                return response.json()
            except httpx.HTTPError as e:
                return {"error": str(e)}
Behavior2/5

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

No annotations are provided, so the description carries the full burden. It mentions the tool retrieves content as JSON for template use, which implies a read-only operation, but doesn't disclose behavioral traits such as authentication needs, rate limits, error handling, or whether the retrieval is cached. For a tool with zero annotation coverage, this is a significant gap in transparency.

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?

The description is appropriately sized and front-loaded: the first sentence states the core purpose, followed by structured sections for 'Args' and 'Returns'. Every sentence earns its place by providing essential information without redundancy, making it highly efficient and well-structured.

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

Completeness3/5

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

Given the tool's moderate complexity (2 parameters, no annotations, no output schema), the description is partially complete. It covers purpose, parameters, and return value, but lacks behavioral details (e.g., auth, errors) and doesn't fully explain the JSON structure beyond mentioning title, subtitle, and HTML content. Without an output schema, more detail on the return format would be beneficial for completeness.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, so the description must compensate. It adds meaning by explaining that 'publication_id' and 'post_id' are IDs for the publication and post, respectively, and clarifies their purpose in retrieving content. However, it doesn't provide details on format (e.g., string patterns) or examples, leaving some ambiguity. With 0% schema coverage and 2 parameters, this is above baseline but not fully comprehensive.

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 specific action ('Retrieve a post's content as JSON') and resource ('post'), distinguishing it from siblings like 'get_post' (likely metadata) and 'create_new_post' (creation). It explicitly mentions the output format ('JSON') and purpose ('to use as a template'), making the purpose highly specific and differentiated.

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

Usage Guidelines3/5

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

The description implies usage by specifying the output format ('JSON') and purpose ('as a template'), suggesting it's for template creation rather than general post retrieval. However, it doesn't explicitly state when to use this tool versus alternatives like 'get_post' or 'list_posts', nor does it mention any prerequisites or exclusions, leaving some ambiguity.

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

Related 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/reymerekar7/beehiiv-mcp-server'

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