get_archive
Retrieve New York Times articles from a specific month and year. Access archived content by specifying date parameters to get the full API response.
Instructions
Get New York Times articles from a specific month and year archive.
Args: year: Year (default: current year) month: Month 1-12 (default: current month)
Returns: Full NYT archive API response (unformatted)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| year | No | ||
| month | No |
Implementation Reference
- src/nytimes_mcp/tools.py:149-168 (handler)Core handler function that executes the get_archive tool logic: determines year/month, fetches data from NYT archive API endpoint using shared NytClient, returns raw response.async def get_archive(year: int | None = None, month: int | None = None) -> dict: """ Get New York Times articles from a specific month and year archive. Args: year: Year (default: current year) month: Month 1-12 (default: current month) Returns: Full NYT archive API response (unformatted) """ now = datetime.now() year = year or now.year month = month or now.month client = get_client() response = await client.make_nyt_request(f"archive/v1/{year}/{month}.json", {}) # Return raw response (no formatting for archive) return response
- src/nytimes_mcp/server.py:79-91 (registration)MCP registration of the get_archive tool using FastMCP @mcp.tool() decorator. Defines input schema via type hints/docstring and delegates execution to internal tools.get_archive.@mcp.tool() async def get_archive(year: int | None = None, month: int | None = None) -> dict: """ Get New York Times articles from a specific month and year archive. Args: year: Year (default: current year) month: Month 1-12 (default: current month) Returns: Full NYT archive API response (unformatted) """ return await tools.get_archive(year, month)