count_papers_on_date
Check how many arXiv papers were published in a specific category on a given date to determine appropriate batch sizes for fetching.
Instructions
Count how many papers were published in an arXiv category on a specific date.
Use this before fetch_papers to check the volume of papers for a given day,
so you can decide how many to fetch with fetch_papers(max_results=N).
Args:
category: arXiv category (e.g. "cs.AI", "cs.CL", "stat.ML")
date: Date in YYYY-MM-DD format (e.g. "2026-03-18")Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| category | Yes | ||
| date | Yes |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |
Implementation Reference
- src/arxiv_mcp_server/server.py:80-99 (handler)The MCP tool handler for count_papers_on_date, which registers the tool and calls the helper function.
@mcp.tool() def count_papers_on_date(category: str, date: str) -> str: """Count how many papers were published in an arXiv category on a specific date. Use this before fetch_papers to check the volume of papers for a given day, so you can decide how many to fetch with fetch_papers(max_results=N). Args: category: arXiv category (e.g. "cs.AI", "cs.CL", "stat.ML") date: Date in YYYY-MM-DD format (e.g. "2026-03-18") """ logger.info(f"Counting papers: category={category}, date={date}") count = count_papers(category, date) return json.dumps( { "category": category, "date": date, "count": count, "suggestion": f"Use fetch_papers(category='{category}', num_days=1, max_results={count}) to fetch them all.", }, - src/arxiv_mcp_server/fetch.py:10-38 (helper)The core implementation of the paper counting logic, utilizing the arxiv API client.
def count_papers(category: str, date: str, max_results: int = 500) -> int: """Count papers published on a specific date via the arXiv API. Uses date range in the query to avoid scanning unrelated papers. Args: category: arXiv category (e.g. "cs.AI", "cs.CL") date: Date string in YYYY-MM-DD format max_results: Maximum number of papers to count (default: 500) Returns: Number of papers published on that date (capped at max_results). """ target_date = datetime.fromisoformat(date).date() next_date = target_date + timedelta(days=1) date_str = target_date.strftime("%Y%m%d") next_str = next_date.strftime("%Y%m%d") search = Search( query=f"cat:{category} AND submittedDate:[{date_str}0000 TO {next_str}0000]", sort_by=SortCriterion.SubmittedDate, sort_order=SortOrder.Descending, ) client = Client() count = 0 for _ in client.results(search): count += 1 if count >= max_results: