Skip to main content
Glama
GNews MCP Server

GNews MCP Server

GNews MCP Server

A remote Model Context Protocol (MCP) server that gives AI applications access to the GNews API for searching news and fetching trending headlines. It runs as a FastAPI app over HTTP, with OAuth2 bearer-token authentication enforced by middleware.

Features

  • search_news — search news articles by keyword, with filtering and sorting.

  • get_top_headlines — trending articles by category.

  • OAuth2 bearer-token auth (via ScaleKit) on every request, plus a public OAuth protected-resource metadata endpoint for client discovery. See docs/ARCHITECTURE.md for how the pieces fit together.

Related MCP server: Gemini News Summarizer MCP Server

Requirements

  • Python 3.11+

  • A free GNews API key

  • ScaleKit credentials for OAuth (see .env.example)

Setup

# 1. Install dependencies
pip install -r requirements.txt
# or: uv sync
 
# 2. Configure environment
cp .env.example .env
# then fill in GNEWS_API_KEY and the SCALEKIT_* values in .env

Running

python main.py
# or: uv run main.py

The server starts on the port from PORT (default 10000) and exposes:

  • The MCP endpoint(s) over HTTP at /

  • A public discovery endpoint at /.well-known/oauth-protected-resource/mcp

Run locally without auth (for trying it out)

The server requires OAuth by default. If you just want to explore the tools locally and don't have ScaleKit set up, you can disable the auth middleware with an environment flag (local use only — never in a deployed server):

DISABLE_AUTH=1 python main.py

With DISABLE_AUTH=1, no ScaleKit configuration is needed; only GNEWS_API_KEY is required for the tools to return data. You'll see a warning printed on startup so it's obvious auth is off.

Authentication

Every request except the /.well-known/* endpoints must include a valid token:

Authorization: Bearer <access_token>

AuthMiddleware (see auth.py) validates the token's issuer and audience with ScaleKit, and requires the gnews:read scope for tools/call requests. Invalid or missing tokens get a 401 response with a WWW-Authenticate header pointing at the resource metadata URL.

Tools

search_news

Search for news articles by keyword.

Parameter

Type

Default

Notes

q

string

— (required)

Keywords; supports AND / OR / NOT and "exact phrases"

lang

string

none

2-letter language code

country

string

none

2-letter country code

max_articles

int

10

1–100

search_in

string

none

fields to search: title, description, content

nullable

string

none

allow nulls for: description, content, image

date_from

string

none

ISO-8601 lower bound

date_to

string

none

ISO-8601 upper bound

sortby

enum

publishedAt

publishedAt or relevance

page

int

1

pagination

get_top_headlines

Trending articles by category.

Parameter

Type

Default

Notes

category

enum

general

general, world, nation, business, technology, entertainment, sports, science, health

lang

string

none

2-letter language code

country

string

none

2-letter country code

max_articles

int

10

1–100

nullable

string

none

allow nulls for: description, content, image

date_from

string

none

ISO-8601 lower bound

date_to

string

none

ISO-8601 upper bound

q

string

none

extra keywords to filter headlines

page

int

1

pagination

Both tools return a structured result:

{
  "success": true,
  "query": "search terms",
  "totalArticles": 150,
  "articles": [
    {
      "title": "Article Title",
      "description": "…",
      "content": "…",
      "url": "https://example.com/article",
      "image": "https://example.com/image.jpg",
      "publishedAt": "2024-01-01T12:00:00Z",
      "source": { "name": "Source Name", "url": "https://source.com" }
    }
  ],
  "parameters_used": { }
}

On failure, success is false and an error message is included.

Query syntax

The GNews API supports logical operators and phrases:

  • AND / OR / NOT — e.g. Apple AND iPhone, Apple OR Microsoft, Apple NOT iPhone

  • "exact phrase" — e.g. "Apple iPhone 15"

  • grouping — e.g. (Apple AND iPhone) OR Microsoft

Supported languages

Arabic (ar), Chinese (zh), Dutch (nl), English (en), French (fr), German (de), Greek (el), Hindi (hi), Italian (it), Japanese (ja), Malayalam (ml), Marathi (mr), Norwegian (no), Portuguese (pt), Romanian (ro), Russian (ru), Spanish (es), Swedish (sv), Tamil (ta), Telugu (te), Ukrainian (uk)

Supported countries

au, br, ca, cn, eg, fr, de, gr, hk, in, ie, it, jp, nl, no, pk, pe, ph, pt, ro, ru, sg, es, se, ch, tw, ua, gb, us

Development

python test_server.py   # smoke test: env + tools registered (no network needed)
python examples.py      # live GNews API calls (needs a real GNEWS_API_KEY)
make help               # see all Make targets

Rate limits

GNews' free plan allows 100 requests/day; paid plans allow more. The server surfaces GNews rate-limit errors in its structured error responses.

Deployment

Because this is a remote MCP server, it needs a public HTTPS URL so clients can reach it and complete OAuth discovery. Two common ways:

Expose a local server with ngrok (temporary)

Good for development and demos — run the server on your machine and tunnel a public URL to it.

# one-time: register your ngrok authtoken
ngrok config add-authtoken <your-token>
 
# terminal 1 — run the server (default port 10000)
python main.py
 
# terminal 2 — expose it
ngrok http 10000

ngrok prints a public URL like https://<id>.ngrok-free.app. Your discovery endpoint is then https://<id>.ngrok-free.app/.well-known/oauth-protected-resource/mcp.

Important: the OAuth flow advertises URLs, so the ScaleKit values that embed a base URL — SCALEKIT_RESOURCE_METADATA_URL and the URLs inside METADATA_JSON_RESPONSE — must use the ngrok URL, not localhost. The free ngrok URL changes on every restart, so update those values each time (or use a reserved ngrok domain).

Deploy on Render (persistent)

  1. Push this repo to GitHub.

  2. On Render: New → Web Service, connect the repo.

  3. Runtime: Python 3.11.

  4. Build command: pip install -r requirements.txt

  5. Start command: uvicorn main:app --host 0.0.0.0 --port $PORT (Render provides $PORT; the app already binds 0.0.0.0.)

  6. Environment variables: add everything from .env.example (GNEWS_API_KEY, all SCALEKIT_*, METADATA_JSON_RESPONSE). Never commit a real .env.

  7. Deploy. Your MCP endpoint and the /.well-known/... discovery URL are then served over HTTPS at your *.onrender.com domain. Important: as with ngrok, point the ScaleKit/metadata URLs at your Render domain, not localhost, or OAuth discovery won't line up.

The app runs on Uvicorn (ASGI). The python main.py entry point already starts Uvicorn; the explicit uvicorn main:app ... command above is the equivalent form platforms expect as a start command.

License

MIT — see LICENSE.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • -
      license
      Not graded
      quality
      Not graded
      maintenance
      A remote MCP server that enables searching for news articles on specific topics through the Tavily API without requiring authentication.
      -
    • -
      license
      Not graded
      quality
      Not graded
      maintenance
      An MCP server that enables a Gemini-based chatbot to fetch and summarize current news headlines from GNews API when users ask about trending topics.
      -
    • F
      license
      Not graded
      quality
      D
      maintenance
      MCP server providing access to the GNews API for fetching news articles and headlines. Supports search and top headlines with advanced filtering by language, country, category, and date.
      1
      -
    • A
      license
      Not graded
      quality
      B
      maintenance
      A Model Context Protocol (MCP) server that provides real-time news intelligence using NewsAPI.ai. This server enables LLMs to search articles, track events, and analyze news through natural conversation.
      153 npm
      3
      MIT