Skip to main content
Glama
philipithomas

Contraption Company MCP

Official

list_posts

Retrieve blog posts with pagination, sorting by newest or oldest, and control the number of posts displayed per page.

Instructions

List blog posts with pagination.

Args: sort_by: Sort order - 'newest' or 'oldest' (default: 'newest') page: Page number (default: 1) limit: Number of posts per page, max 10 (default: 10)

Returns: List of post summaries with metadata

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
sort_byNonewest
pageNo
limitNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • MCP tool handler and registration for 'list_posts'. Validates inputs, fetches posts from ChromaService, resolves URLs, serializes, and returns paginated results.
    @mcp.tool()
    async def list_posts(
        sort_by: str = "newest",
        page: int = 1,
        limit: int = 10,
    ) -> dict[str, Any]:
        """
        List blog posts with pagination.
    
        Args:
            sort_by: Sort order - 'newest' or 'oldest' (default: 'newest')
            page: Page number (default: 1)
            limit: Number of posts per page, max 10 (default: 10)
    
        Returns:
            List of post summaries with metadata
        """
        if limit > settings.max_posts_per_page:
            limit = settings.max_posts_per_page
    
        if page < 1:
            page = 1
    
        offset = (page - 1) * limit
    
        chroma_service = await get_chroma_service()
        posts = await chroma_service.list_posts(
            limit=limit,
            offset=offset,
            sort_by=sort_by,
        )
    
        serialized_posts: list[dict[str, Any]] = []
        for post in posts:
            resolved_url = _canonical_post_url(post)
            if not resolved_url:
                logger.debug("Skipping post without canonical URL: %s", post.id)
                continue
    
            serialized_posts.append(
                {
                    "id": resolved_url,
                    "title": post.title,
                    "excerpt": post.excerpt,
                    "url": resolved_url,
                    "published_at": post.published_at.isoformat() if post.published_at else None,
                    "updated_at": post.updated_at.isoformat() if post.updated_at else None,
                    "tags": post.tags,
                    "authors": post.authors,
                }
            )
    
        return {
            "posts": serialized_posts,
            "pagination": {
                "page": page,
                "limit": limit,
                "sort_by": sort_by,
            },
        }
  • Helper method in ChromaService that retrieves all post chunks from the database, deduplicates by post slug, sorts by date, applies pagination, and returns PostSummary objects.
    async def list_posts(
        self,
        limit: int = 10,
        offset: int = 0,
        sort_by: str = "newest",
    ) -> list[PostSummary]:
        # Chroma Cloud has a limit of 300 items per request
        all_results = self.collection.get(limit=300)
    
        if not all_results["ids"]:
            return []
    
        posts_map: dict[str, dict[str, Any]] = {}
    
        for i, metadata in enumerate(all_results["metadatas"] or []):
            slug = str(metadata.get("post_slug", ""))
            if slug and slug not in posts_map:
                posts_map[slug] = {
                    "id": metadata.get("post_id", ""),
                    "slug": slug,
                    "title": metadata.get("post_title", ""),
                    "url": metadata.get("post_url", ""),
                    "excerpt": (
                        all_results["documents"][i][:200] if all_results["documents"] else None
                    ),
                    "published_at": metadata.get("published_at"),
                    "updated_at": metadata.get("updated_at"),
                    "tags": str(metadata.get("tags", "")).split(",")
                    if metadata.get("tags")
                    else [],
                    "authors": str(metadata.get("authors", "")).split(",")
                    if metadata.get("authors")
                    else [],
                }
    
        posts = list(posts_map.values())
    
        if sort_by == "newest":
            posts.sort(key=lambda x: x.get("published_at", ""), reverse=True)
        elif sort_by == "oldest":
            posts.sort(key=lambda x: x.get("published_at", ""))
    
        paginated_posts = posts[offset : offset + limit]
    
        return [
            PostSummary(
                id=p["id"],
                slug=p["slug"],
                title=p["title"],
                excerpt=p["excerpt"],
                url=p["url"],
                published_at=datetime.fromisoformat(p["published_at"])
                if p.get("published_at")
                else None,
                updated_at=datetime.fromisoformat(p["updated_at"]) if p.get("updated_at") else None,
                tags=p["tags"],
                authors=p["authors"],
            )
            for p in paginated_posts
        ]
Behavior3/5

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

With no annotations provided, the description carries the full burden. It mentions pagination and max limit (10), which are useful behavioral traits. However, it doesn't cover aspects like rate limits, authentication needs, or error handling, leaving gaps for a tool with no annotation support.

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 well-structured and front-loaded with the core purpose. The Args and Returns sections are organized efficiently, with no wasted sentences—each part earns its place.

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?

Given the tool's moderate complexity (3 parameters, no annotations, but with an output schema), the description is fairly complete. It covers parameters well and mentions return values, though it could benefit from more behavioral context like error cases or performance hints.

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 provides clear semantics for all three parameters (sort_by, page, limit), including defaults and constraints (e.g., max 10 for limit), adding significant value beyond the bare schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb ('List') and resource ('blog posts'), and mentions pagination which adds specificity. However, it doesn't explicitly differentiate from sibling tools like 'fetch' or 'search', which might have overlapping functionality.

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 is provided on when to use this tool versus the sibling tools 'fetch' or 'search'. The description implies usage for listing posts with pagination but doesn't specify alternatives or exclusions.

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/philipithomas/ghost-mcp'

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