get_archive
Retrieve New York Times articles from monthly archives by specifying year and month parameters to access historical content.
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 implements the get_archive tool logic by fetching the NYT archive API response for the specified year and month using the shared NytClient.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 tool registration for get_archive using FastMCP's @mcp.tool() decorator. This wrapper function defines the tool schema via type hints and docstring, and delegates execution to the core handler in tools.py.@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)