Skip to main content
Glama

get_top_headlines

Fetch top headlines by specific country and category using a unified API tool. Streamline news aggregation and stay informed with targeted updates.

Instructions

Get top headlines by country and category

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
categoryNo
countryNo

Implementation Reference

  • The handler function for the get_top_headlines tool. It checks for the API key configuration and delegates to the NewsApiClient's topHeadlines method with parsed arguments.
    async get_top_headlines(args: Record<string, unknown>) { if (!cfg.newsApiKey) throw new Error("NEWS_API_KEY is not configured"); const country = args.country ? String(args.country) : undefined; const category = args.category ? String(args.category) : undefined; return client.topHeadlines(country, category); },
  • Local registration of the get_top_headlines tool within the News API module, defining name, description, and input schema.
    { name: "get_top_headlines", description: "Get top headlines by country and category", inputSchema: { type: "object", properties: { country: { type: "string" }, category: { type: "string" }, }, }, },
  • Central registration invocation that includes the get_top_headlines tool via the News API registration.
    registerNewsApi(),
  • Supporting method in NewsApiClient that performs the actual API request to fetch top headlines, invoked by the tool handler.
    topHeadlines(country?: string, category?: string) { return this.request("/v2/top-headlines", { headers: { Authorization: `Bearer ${this.apiKey}` }, query: { country, category }, }); }

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/TaylorChen/muti-mcps'

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