Skip to main content
Glama

list_posts

Retrieve all posts for a specific Beehiiv publication using the publication ID. This tool integrates with the Beehiiv API v2 to provide access to post data for analysis or management purposes.

Instructions

List all posts for a given publication. Args: publication_id: e.g. 'pub_00000000-0000-0000-0000-000000000000'

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
publication_idYes

Implementation Reference

  • The handler function for the 'list_posts' tool. It uses the beehiiv_request helper to fetch the latest 5 confirmed posts from the specified publication and formats them as a string list of ID: title.
    @mcp.tool() async def list_posts(publication_id: str) -> str: """ List all posts for a given publication. Args: publication_id: e.g. 'pub_00000000-0000-0000-0000-000000000000' """ params = { "order_by": "publish_date", "direction": "desc", "limit": 5, "status": "confirmed" } path = f"/publications/{publication_id}/posts" data = await beehiiv_request("GET", path, params=params) if not data or "data" not in data: return f"API error: {data.get('error', 'Unknown error')}" return "\n".join(f"{p['id']}: {p['title']}" for p in data["data"])
  • Shared helper function that performs authenticated HTTP requests to the Beehiiv API v2, handling errors and used by the list_posts handler.
    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)}

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