About mcp-newsapi
mcp-newsapi is a read-only MCP server that gives AI assistants access to NewsAPI.ai news articles, events, trends, and account usage, with safeguards for metered token spending.
Key features
- 01Search and retrieve articles
- 02Search and retrieve events
- 03Autosuggest concepts and filters
- 04View trending concepts
- 05Check token usage and limits
Use cases
- 01Find recent coverage of an entity
- 02Review articles grouped around an event
- 03Resolve names to precise entity URIs
- 04Monitor remaining API token budget
MCP support
Exposes 10 read-only tools to MCP clients for searching NewsAPI.ai articles and events, resolving concepts and filters, retrieving trends, and checking account usage. Session token budgets and local safeguards help control metered searches.
Configuration
Local server config is the same for every client. Copy it into your client’s MCP config file.
npx -y @nubiia/mcp-newsapiNEWSAPI_AI_API_KEYSecretYour NewsAPI.ai API key (newsapi.ai → Dashboard).NEWSAPI_AI_MAX_TOKENS_PER_SESSIONSecretMax NewsAPI.ai tokens this server may spend per session (process lifetime). Defaults to 200.Local servers need a runtime on your machine (e.g. Node.js 18+). Config file locations differ by client; see your client’s docs.
Tools
10Saved tool list · updated 1w ago
| Parameter | Type | Required | Description |
|---|---|---|---|
| lang | any | No | 3-letter ISO 639-3 language codes, e.g. "spa" or ["eng", "spa"]. OR-ed. Accepts a single string or an array of strings. |
| page | integer | No | Result page, starting at 1 (default 1). |
| count | integer | No | Articles per page, 1-100 (default 10). Keep small to save context. |
| keyword | string | No | Free-text keyword or phrase, for topics and general terms (e.g. "inflation", "wildfire"). Do NOT use it for companies, people, places or organisations: common words double as names (e.g. "Telefónica" also matches the ordinary Spanish adjective "telefónica") and produce irrelevant results. For those entities call suggest_concepts first and pass the returned URI in concept_uris. |
| sort_by | enum | No | Sort order (default date). "rel" ranks by relevance to the query.date | rel | sourceImportance | cosSim |
| body_len | integer | No | Max body characters per article, 0-5000 (default 300; 0 = no body). |
| date_end | string | No | Latest date, YYYY-MM-DD (inclusive); must be >= date_start. With allow_archive the date_start → date_end (default today) span may be at most 1 year. |
| sort_asc | boolean | No | Ascending order (default false). |
| data_types | any | No | Content types to include (default: all). Accepts a single string or an array of strings. |
| date_start | string | No | Earliest date, YYYY-MM-DD (inclusive). Must be within the last 31 days unless allow_archive=true, which makes date_start mandatory. |
| keyword_loc | enum | No | Where to look for the keyword (default: the API default, body).body | title | body,title |
| source_uris | any | No | News source URIs, e.g. "bbc.co.uk" (use suggest_sources). OR-ed. Accepts a single string or an array of strings. |
| concept_uris | any | No | Concept URIs for entities: companies, people, places, organisations. PREFERRED over keyword for any named entity: first call suggest_concepts (free) to resolve the name, then pass the returned `uri` here. Multiple values are OR-ed and far more precise than keyword, which avoids homonym noise. Accepts a single string or an array of strings. |
| allow_archive | boolean | No | Default false: search only the last 31 days (cheapest). Set true to reach the historical archive, which costs extra tokens per year queried; requires date_start and a range of at most 1 year. |
| category_uris | any | No | Category URIs, e.g. "news/Business" (use suggest_categories). OR-ed. Accepts a single string or an array of strings. |
| location_uris | any | No | Location URIs where the news happened (use suggest_locations). OR-ed. Accepts a single string or an array of strings. |
| max_sentiment | number | No | Maximum sentiment, -1 to 1 (English articles only). |
| min_sentiment | number | No | Minimum sentiment, -1 to 1 (English articles only). |
| ignore_keyword | string | No | Exclude articles mentioning this. |
| ignore_source_uris | any | No | Exclude these news sources. Accepts a single string or an array of strings. |
| include_duplicates | boolean | No | Include duplicate/syndicated articles (default false). |
| keyword_search_mode | enum | No | How to match the keyword: simple (any word), exact, or phrase.simple | exact | phrase |
Details
From the project READMEMCP NewsAPI.ai
A Model Context Protocol (MCP) server for NewsAPI.ai (the Event Registry news intelligence API). It lets AI assistants like Claude search news articles and events (clusters of articles about the same happening), resolve names to entity URIs, see what is trending, and keep an eye on the account's token budget.
Built and maintained by Nubiia — automatización e integraciones con IA para negocios (MCP, Holded, Pipedrive y más). ¿Quieres algo así para tu empresa? Escríbenos en nubiia.es.
⚠️ NewsAPI.ai is metered in tokens
Every search spends tokens from your plan, and a free plan has a small budget. This server is built to be frugal:
- Result counts default to 10 (articles/events) and article bodies to 300 characters, so a call is cheap in tokens and in your assistant's context window.
- Searches are limited to the last 31 days unless you pass
allow_archive: true(historical data costs extra tokens per year touched).allow_archiverequiresdate_startand thedate_start→date_end(default: today) range may span at most 1 year. Adate_start/date_endolder than 31 days withoutallow_archiveis rejected with an explanation instead of silently returning nothing. - A search with no filter at all is rejected locally, before it can spend anything.
- A session token budget (default 200 tokens, see below) stops runaway loops before they reach the API.
- The
suggest_*tools andget_usageare free — use them to resolve entities to URIs before searching. get_usageshows the remaining budget.
Costs measured against a live account (31-day window):
| Tool | Tokens per call |
|---|---|
search_articles, get_article | 1 |
search_events, get_event (info) | 5 |
get_event (include_articles) | 1 |
get_trending_concepts | 10 |
suggest_*, get_usage | 0 |
Plans and pricing change — see newsapi.ai/pricing and
docs/api-notes.md.
Features
Ten read-only tools:
- Articles (2):
search_articles,get_article - Events (2):
search_events,get_event - Autosuggest (4):
suggest_concepts,suggest_categories,suggest_sources,suggest_locations - Trends (1):
get_trending_concepts - Account (1):
get_usage
Total: 10 tools, all marked readOnlyHint: true — nothing in this server writes to
NewsAPI.ai or anywhere else.
What's deliberately out of scope for v1
Topic pages and saved searches, the analytics service (text categorization, sentiment
of arbitrary text), story clustering, article mentions, aggregation result types
(conceptAggr, timeAggr, …) and multi-tenant configuration.
Installation
Prerequisites
- Node.js 22.14 or higher
- A NewsAPI.ai account and API key, from newsapi.ai → Dashboard
Install from npm
npm install -g @nubiia/mcp-newsapi
Install from source
git clone https://github.com/nubiia-dev/mcp-newsapi.git
cd mcp-newsapi
npm install
npm run build
Configuration
Environment Variables
| Variable | Required | Description |
|---|---|---|
NEWSAPI_AI_API_KEY | Yes | Your NewsAPI.ai API key (Dashboard). Secret — never commit it. |
NEWSAPI_AI_MAX_TOKENS_PER_SESSION | No | Max NewsAPI.ai tokens this server may spend per session (until the server process restarts). Default 200. |
export NEWSAPI_AI_API_KEY=your_newsapi_ai_key
export NEWSAPI_AI_MAX_TOKENS_PER_SESSION=200 # optional
Session token budget
The budget is per server process: each MCP client/server instance you start has its own counter, so two clients configured with 200 can together spend 400. It resets on restart.
Every call is charged its measured token cost (see the table above) before it is
sent. When a call would exceed the remaining budget, the tool returns an error stating the
remaining and total budget and how to raise it — and no request is sent to NewsAPI.ai.
Free tools (suggest_*, get_usage) are never blocked. get_usage also reports the
session budget (maxTokens, spentTokens, remainingTokens) next to your account
balance. Calls the API rejects outright (4xx) are refunded; calls that fail after being
accepted (including HTTP 200 {"error"} bodies) stay charged, because the API bills them.
An invalid value (e.g. abc, -5) falls back to 200 with a warning on stderr; 0
disables all paid calls.
Claude Desktop Configuration
Add to your Claude Desktop config file:
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Windows: %APPDATA%\Claude\claude_desktop_config.json
{
"mcpServers": {
"newsapi": {
"command": "npx",
"args": ["-y", "@nubiia/mcp-newsapi@latest"],
"env": {
"NEWSAPI_AI_API_KEY": "your_newsapi_ai_key",
"NEWSAPI_AI_MAX_TOKENS_PER_SESSION": "200"
}
}
}
}
Or if installed from source:
{
"mcpServers": {
"newsapi": {
"command": "node",
"args": ["/path/to/mcp-newsapi/dist/index.js"],
"env": {
"NEWSAPI_AI_API_KEY": "your_newsapi_ai_key"
}
}
}
}
Claude Code Configuration
claude mcp add newsapi --env NEWSAPI_AI_API_KEY=your_newsapi_ai_key -- npx -y @nubiia/mcp-newsapi@latest
Troubleshooting
sh: mcp-newsapi: command not foundwhen launching from inside this repo. If you start Claude Code (or another MCP client) from the cloned repository directory,npx @nubiia/mcp-newsapiresolves the localpackage.jsoninstead of the published package, and themcp-newsapibinary is not on thePATH. Pin the registry version with@latest(as in the examples above), or launch the client from another directory.
Tools
List parameters (lang, concept_uris, category_uris, source_uris, location_uris,
ignore_source_uris, data_types, types, concept_types) accept either a single string
or an array of strings: "lang": "spa" and "lang": ["spa"] are equivalent.
The recommended flow: suggest_* (free) → search_* → get_*.
suggest_concepts · read-only · free
Resolve a name ("Telefónica", "Pedro Sánchez") to a concept URI. Pass the uri as
concept_uris to a search — far more precise than a keyword.
{ "prefix": "Telefónica", "types": ["org"], "count": 3 }
Searching for a company, person, place or organisation? Resolve it with
suggest_conceptsfirst and pass the returneduriasconcept_uris.keywordis for free terms and topics and is noisy with common words: for examplekeyword: "Telefónica"in Spanish also matches the ordinary adjective "telefónica".
suggest_categories, suggest_sources, suggest_locations · read-only · free
Same idea for categories (news/Business), publications (bbc.co.uk) and places.
search_articles · read-only · 1 token
At least one of keyword, concept_uris, category_uris, source_uris,
location_uris is required. Defaults: 10 results, newest first, duplicates skipped,
last 31 days, 300-character bodies. Paginate with page; the response carries total
and pages.
{
"concept_uris": ["http://en.wikipedia.org/wiki/Telefónica"],
"lang": ["spa"],
"date_start": "2026-10-01",
"count": 5
}
Dates must be real YYYY-MM-DD dates, date_end must not precede date_start, and the
archive rules above apply (allow_archive needs date_start, max 1 year).
Other options: keyword_loc, keyword_search_mode, ignore_keyword,
ignore_source_uris, data_types (news/pr/blog), sort_by
(date/rel/sourceImportance/cosSim), min_sentiment/max_sentiment,
body_len, include_duplicates, allow_archive.
get_article · read-only · 1 token
One article by article_uri, with a longer body (body_len, default 3000).
search_events · read-only · 5 tokens
Events: clusters of articles about the same happening, with title, short summary, date,
location, key concepts and article count. The right granularity for "what is happening
with X". sort_by: "size" surfaces the biggest stories; min_articles_in_event filters
noise.
get_event · read-only · 5 tokens (1 with include_articles)
One event by event_uri, or — with include_articles: true — the articles covering it.
get_trending_concepts · read-only · 10 tokens
People, organisations and places trending right now (last 2 days vs last 2 weeks) in
news, social, pr or blog (blog trends may be unavailable on some plans, and the failed call is still billed). The priciest tool: call it sparingly.
get_usage · read-only · free
availableTokens, usedTokens, remainingTokens. Check it before a batch of searches.
Rate limiting
A local guard stops runaway agent loops before they drain the token budget:
| Tool(s) | Limit |
|---|---|
search_articles, search_events, get_article, get_event | 30 req/min |
get_trending_concepts | 20 req/min |
suggest_*, get_usage | 120 req/min |
| Everything else (default) | 60 req/min |
The API itself allows at most 5 simultaneous requests. 429/502/503/504 responses
and connection-refused/DNS errors are retried with backoff; ambiguous failures (timeouts,
connection resets) are not, because a metered request may already have been billed.
Each attempt times out after 30 seconds.
Error messages
A 401/403 response includes an explanation, not just "Unauthorized": the key may be
wrong/revoked, or the account may be out of tokens (get_usage tells you which).
The API key is sent in the request body, never in a URL, and is redacted from every error
message (HTTP, network and JSON-parse errors alike).
Development
npm install
npm run build
npm test # runs entirely against mocks — no network, no API key
npm run test:coverage
npm run lint
See CONTRIBUTING.md for the full workflow and
docs/api-notes.md for API behaviour verified against a live account.
License
Related
@nubiia/mcp-holded— MCP server for the Holded invoicing/accounting API.@nubiia/mcp-signaturit— MCP server for the Signaturit e-signature API.
Comments
New to MCP?
From what the protocol is to installing your first server, these answers cover most first questions.
An open protocol that defines how AI applications connect to external tools and data in a uniform way. Clients talk to the model; MCP servers provide tools, resources and prompt templates. They exchange standard messages, so one server can be reused by many clients.