Skip to main content
Glama

get_latest_news

Retrieve current New York Times news items from the real-time wire feed, with options to filter by section, source, and pagination.

Instructions

Get the latest news items from the NYT news wire (real-time news feed).

Args: limit: Number of items to return (default: 20) offset: Pagination offset (default: 0) source: News source - "nyt" or "inyt" (default: "nyt") section: News section (default: "all"). e.g. "u.s." or "technology". Use the 'nyt://reference/sections' resource for available section names.

Returns: Formatted response with news_items array containing title, abstract, url, section, subsection, published_date, and byline

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
limitNo
offsetNo
sourceNonyt
sectionNoall

Implementation Reference

  • The FastMCP-registered handler for the get_latest_news tool, defining input parameters with type hints and delegating to the get_news_wire helper function.
    @mcp.tool() async def get_latest_news( limit: int = 20, offset: int = 0, source: tools.NewsSource = "nyt", section: str = "all", ) -> dict: """ Get the latest news items from the NYT news wire (real-time news feed). Args: limit: Number of items to return (default: 20) offset: Pagination offset (default: 0) source: News source - "nyt" or "inyt" (default: "nyt") section: News section (default: "all"). e.g. "u.s." or "technology". Use the 'nyt://reference/sections' resource for available section names. Returns: Formatted response with news_items array containing title, abstract, url, section, subsection, published_date, and byline """ return await tools.get_news_wire(limit, offset, source, section)
  • The primary helper function implementing the NYT news wire API call, parameter construction, client usage, and response formatting.
    async def get_news_wire( limit: int = 20, offset: int = 0, source: NewsSource = "nyt", section: str = "all", ) -> dict: """ Get the latest news items from the NYT news wire (real-time news feed). Args: limit: Number of items to return (default: 20) offset: Pagination offset (default: 0) source: News source - "nyt", "inyt", or "all" (default: "nyt") section: News section (e.g., "all", "world", "business") (default: "all"). To see the latest list of sections available, refer to the get_news_sections tool. Returns: Formatted response with news_items array containing title, abstract, url, section, subsection, published_date, and byline """ params = { "limit": limit, "offset": offset, } client = get_client() response = await client.make_nyt_request( f"news/v3/content/{source}/{section}.json", params ) return format_news_items_response(response)
  • Type alias defining valid values for the 'source' parameter, used for input validation via type hints.
    type NewsSource = Literal["nyt", "inyt", "all"]
  • Utility function that transforms the raw NYT news wire API response into a clean, structured format with a news_items array containing key fields.
    def format_news_items_response(response: dict[str, Any]) -> dict[str, Any]: """ Format times wire (news feed) response to extract essential fields. Args: response: Raw NYT times wire API response Returns: Formatted response with news_items array and num_results """ if "results" in response: return { "news_items": [ { "title": item.get("title", ""), "abstract": item.get("abstract", ""), "url": item.get("url", ""), "section": item.get("section", ""), "subsection": item.get("subsection", ""), "published_date": item.get("published_date", ""), "byline": item.get("byline", ""), } for item in response["results"] ], "num_results": len(response["results"]), } return response

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/jeffmm/nytimes-mcp'

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