Skip to main content
Glama

search_by_date

List indexed documents within a specified date range to discover recently indexed content or audit documents from a specific period.

Instructions

List indexed documents within a date range.

    Returns file records matching the given date window.  Useful for
    discovering recently indexed content or auditing what was indexed in
    a specific period.

    Args:
        after: Only include documents indexed/modified after this date.
        before: Only include documents indexed/modified before this date.
        source: Restrict to this source name.
        file_type: Restrict to this file type (e.g. ``".pdf"``).
        limit: Maximum records to return.
    

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
afterNo
beforeNo
sourceNo
file_typeNo
limitNo

Implementation Reference

  • The main handler function for the search_by_date MCP tool. Registered via @mcp.tool() decorator, it accepts ISO-8601 date range parameters (after/before), source name, file_type, and limit. It performs access control via check_access(ctx, 'read'), queries metadata_store.list_files(status='indexed'), filters records by date/source/file_type, and returns matched records with metadata.
    @mcp.tool()
    def search_by_date(
        after: Annotated[
            str | None,
            "ISO-8601 date string; return only documents indexed/modified after this date.",
        ] = None,
        before: Annotated[
            str | None,
            "ISO-8601 date string; return only documents indexed/modified before this date.",
        ] = None,
        source: Annotated[
            str | None,
            "Restrict to a specific source name.",
        ] = None,
        file_type: Annotated[
            str | None,
            "Restrict to a specific file type extension, e.g. '.jira' or '.pdf'.",
        ] = None,
        limit: Annotated[int, "Maximum number of records to return (1-500)."] = 50,
    ) -> dict:
        """List indexed documents within a date range.
    
        Returns file records matching the given date window.  Useful for
        discovering recently indexed content or auditing what was indexed in
        a specific period.
    
        Args:
            after: Only include documents indexed/modified after this date.
            before: Only include documents indexed/modified before this date.
            source: Restrict to this source name.
            file_type: Restrict to this file type (e.g. ``".pdf"``).
            limit: Maximum records to return.
        """
        from datetime import UTC, datetime
    
        from memorymesh.server.auth_guard import check_access
    
        if (err := check_access(ctx, "read")) is not None:
            return err
    
        limit = max(1, min(500, limit))
    
        after_ts: float | None = None
        before_ts: float | None = None
    
        if after:
            try:
                after_ts = datetime.fromisoformat(after.replace("Z", "+00:00")).timestamp()
            except ValueError:
                return {
                    "status": "error",
                    "message": f"Invalid 'after' date format: {after!r}",
                }
    
        if before:
            try:
                before_ts = datetime.fromisoformat(before.replace("Z", "+00:00")).timestamp()
            except ValueError:
                return {
                    "status": "error",
                    "message": f"Invalid 'before' date format: {before!r}",
                }
    
        records = ctx.metadata_store.list_files(status="indexed")
    
        filtered = []
        for rec in records:
            if source and rec.source_name != source:
                continue
            if file_type and rec.file_type != file_type:
                continue
            ts = rec.indexed_at or rec.mtime
            if after_ts and ts < after_ts:
                continue
            if before_ts and ts > before_ts:
                continue
            filtered.append(rec)
            if len(filtered) >= limit:
                break
    
        def _iso(ts: float | None) -> str:
            if ts is None:
                return ""
            return datetime.fromtimestamp(ts, tz=UTC).isoformat()
    
        return {
            "status": "ok",
            "count": len(filtered),
            "records": [
                {
                    "path": r.path,
                    "source": r.source_name,
                    "file_type": r.file_type,
                    "n_chunks": r.n_chunks,
                    "indexed_at": _iso(r.indexed_at),
                    "mtime": _iso(r.mtime),
                }
                for r in filtered
            ],
        }
  • Registration call that invokes the register() function from search_by_date.py, passing the FastMCP instance and AppContext to wire the tool into the MCP server.
    search_by_date.register(mcp, ctx)
  • Import of the search_by_date module in build_mcp(), making it available for registration.
    search_by_date,
  • Input schema / type annotations for the search_by_date tool: after, before (optional ISO-8601 strings), source, file_type (optional string filters), and limit (int, clamped 1-500).
        after: Annotated[
            str | None,
            "ISO-8601 date string; return only documents indexed/modified after this date.",
        ] = None,
        before: Annotated[
            str | None,
            "ISO-8601 date string; return only documents indexed/modified before this date.",
        ] = None,
        source: Annotated[
            str | None,
            "Restrict to a specific source name.",
        ] = None,
        file_type: Annotated[
            str | None,
            "Restrict to a specific file type extension, e.g. '.jira' or '.pdf'.",
        ] = None,
        limit: Annotated[int, "Maximum number of records to return (1-500)."] = 50,
    ) -> dict:
        """List indexed documents within a date range.
    
        Returns file records matching the given date window.  Useful for
        discovering recently indexed content or auditing what was indexed in
        a specific period.
    
        Args:
            after: Only include documents indexed/modified after this date.
            before: Only include documents indexed/modified before this date.
            source: Restrict to this source name.
            file_type: Restrict to this file type (e.g. ``".pdf"``).
            limit: Maximum records to return.
  • MetadataStore.list_files() delegates to FileRepository.list_files() to fetch all file records, optionally filtered by source_name and status. Used by the search_by_date tool to retrieve indexed records before filtering by date range.
    def list_files(
        self,
        source_name: str | None = None,
        status: str | None = None,
    ) -> list[FileRecord]:
        """Return all file records matching the optional filters.
    
        Args:
            source_name: Restrict to a specific source.  ``None`` = all sources.
            status: Restrict to a specific status value.  ``None`` = all statuses.
        """
        return self._files.list_files(source_name=source_name, status=status)
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral transparency. It only states the basic operation without disclosing details like result ordering, pagination, date format expectations, or whether the operation is read-only.

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 fairly concise and front-loaded with the main purpose. The parameter documentation is bulleted and readable, though minor redundancy exists (e.g., repeating 'Only include documents').

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

Completeness2/5

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

Despite good parameter coverage, the description omits critical details: no output schema explanation, no mention of date format or inclusiveness, no pagination or limit behavior, and no error cases. For a tool with five params and no annotations, this is insufficient.

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

Parameters5/5

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

The input schema has 0% description coverage, and the tool's description adds meaningful explanations for all five parameters (after, before, source, file_type, limit), including examples and clarifications like indexing/modification semantics.

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 it lists indexed documents within a date range and mentions use cases like discovery and auditing. However, it does not explicitly differentiate from sibling tools like query_timeline, which may also handle date-based retrieval.

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 provides a general context ('useful for discovering recently indexed content or auditing') but does not give explicit guidance on when to use this tool versus alternatives or when not to use it.

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/kilhubprojects/memory-mesh'

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