Skip to main content
Glama
lethain

Library MCP

by lethain

get_by_date_range

Retrieve posts published between specific dates from your local markdown knowledge base using ISO date format inputs.

Instructions

Get posts published within a date range.

Args: start_date: the start date in ISO format (YYYY-MM-DD) end_date: the end date in ISO format (YYYY-MM-DD) limit: the maximum number of posts to return

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
start_dateYes
end_dateYes
limitNo

Implementation Reference

  • main.py:522-544 (handler)
    The main MCP tool handler function for 'get_by_date_range'. It is registered via @mcp.tool() decorator, includes input schema in docstring and type hints, parses date strings to datetimes, calls the content manager helper, and formats the output.
    @mcp.tool()
    async def get_by_date_range(start_date: str, end_date: str, limit: int = 50) -> str:
        """Get posts published within a date range.
        
        Args:
            start_date: the start date in ISO format (YYYY-MM-DD)
            end_date: the end date in ISO format (YYYY-MM-DD)
            limit: the maximum number of posts to return
        """
        if content_manager is None:
            return "Content has not been loaded. Please ensure the server is properly initialized."
        
        try:
            # Parse dates with time set to beginning/end of day
            # Always create naive datetimes for consistent comparison
            start = datetime.fromisoformat(f"{start_date}T00:00:00")
            end = datetime.fromisoformat(f"{end_date}T23:59:59")
        except ValueError as e:
            return f"Error parsing dates: {e}. Please use ISO format (YYYY-MM-DD)."
        
        posts = content_manager.get_by_date_range(start, end, limit)
        return format_content_for_output(posts)
  • Supporting method in HugoContentManager class that implements the core logic for filtering content files within the specified date range, handling timezone normalization, sorting by date descending, and limiting results.
    def get_by_date_range(self, start_date: datetime, end_date: datetime, limit: int = 50) -> List[ContentFile]:
        """Find all posts within a date range"""
        matches = []
        
        debug_print(f"Searching for posts between {start_date} and {end_date}")
        for _, content_file in self.path_to_content.items():
            post_date = content_file.date
            if post_date:
                # Make date naive for comparison if it has timezone info
                if hasattr(post_date, 'tzinfo') and post_date.tzinfo is not None:
                    post_date = post_date.replace(tzinfo=None)
                
                # Make start and end dates naive for comparison
                start_naive = start_date
                if hasattr(start_naive, 'tzinfo') and start_naive.tzinfo is not None:
                    start_naive = start_naive.replace(tzinfo=None)
                    
                end_naive = end_date
                if hasattr(end_naive, 'tzinfo') and end_naive.tzinfo is not None:
                    end_naive = end_naive.replace(tzinfo=None)
                
                if start_naive <= post_date <= end_naive:
                    matches.append(content_file)
        
        debug_print(f"Found {len(matches)} posts within date range")
        
        # Sort by date (most recent first)
        def get_sort_key(content_file):
            date = content_file.date
            if date is None:
                return datetime.min
            # Make date naive if it has timezone info
            if hasattr(date, 'tzinfo') and date.tzinfo is not None:
                date = date.replace(tzinfo=None)
            return date
            
        matches.sort(key=get_sort_key, reverse=True)
        
        return matches[:limit]
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 of behavioral disclosure. It mentions the tool 'Get[s] posts' but doesn't specify whether this is a read-only operation, requires authentication, has rate limits, or describes the return format (e.g., pagination, error handling). For a tool with zero annotation coverage, this leaves significant behavioral gaps.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is appropriately sized and front-loaded, with the purpose stated clearly in the first sentence. The parameter explanations are concise and directly relevant, with no wasted words. However, the structure could be slightly improved by integrating parameter details more seamlessly rather than as a separate 'Args:' section.

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 (3 parameters, no output schema, no annotations), the description is minimally adequate. It covers the basic purpose and parameter semantics but lacks behavioral details (e.g., safety, performance) and output information. Without annotations or an output schema, it should do more to be fully complete for an AI agent.

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?

The description adds meaningful semantics beyond the input schema, which has 0% description coverage. It explains that 'start_date' and 'end_date' are in ISO format (YYYY-MM-DD) and defines 'limit' as 'the maximum number of posts to return,' clarifying purpose and format. This compensates well for the low schema coverage, though it doesn't cover all potential nuances like date inclusivity.

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 tool's purpose: 'Get posts published within a date range.' This specifies the verb ('Get'), resource ('posts'), and scope ('within a date range'). However, it doesn't explicitly differentiate from sibling tools like 'get_by_tag' or 'search_tags', which might also retrieve posts but with different filters.

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?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention sibling tools like 'get_by_tag' or 'search_tags' for filtering by other criteria, nor does it specify prerequisites or exclusions. Usage is implied by the date-range focus but not explicitly stated.

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/lethain/library-mcp'

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