Mcp Newsapi

io.github.nubiia-dev由 GitHub 账号 nubiia-dev 发布v1.0.2更新于 Oct 30, 2026

NewsAPI.ai (Event Registry): 10 read-only MCP tools for news articles, events, autosuggest, trends

概览

AI 生成的概览

面向 NewsAPI.ai(Event Registry)的只读 MCP 服务器,让助手搜索新闻文章与事件、把名称解析为 URI,并查看热门话题。

可以做什么
  • 按关键词、概念、分类、来源或地点搜索并阅读新闻文章,支持分页和更长的正文
  • 搜索并阅读新闻事件(同一事件的多篇报道聚合),含摘要、日期、地点和报道数量
  • 把人物、机构、地点、分类和媒体名称解析为 URI,使检索更精确
  • 查看当前在新闻、社交、公关或博客中热度上升的人物、机构和地点
  • 查询账户的 token 余额和本次会话的预算
适用场景
适合需要了解某公司、人物、地点或话题近期新闻动态的场合,也适合希望把新闻检索限制在可控预算内的研究或监测任务。所有工具均为只读,适合调研而非发布内容。
运行要求
通过 npx 在本机以 stdio 进程运行,需要 Node.js 22.14 或更高版本。需要 NewsAPI.ai 账户和 API 密钥,通过环境变量 NEWSAPI_AI_API_KEY 提供;可选变量 NEWSAPI_AI_MAX_TOKENS_PER_SESSION 限制每个进程的花费(默认 200)。需要能访问 NewsAPI.ai 接口的网络。
安装前请注意
每次检索都会消耗 NewsAPI.ai 套餐中的付费 token:文章类调用 1 个、事件类 5 个、趋势 10 个,查询历史档案还需额外 token。会话预算按进程计算并在重启后重置,多个客户端可各自消耗额度;已被接口接受但随后失败的调用仍会计费。NEWSAPI_AI_API_KEY 属机密,切勿提交到代码库。

安装

在 SourceWeft 中

  1. 打开 控制台中的 Mcp Newsapi,将其添加到工作区。
  2. 为需要使用其工具的对话启用该服务。

Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。

其他 MCP 客户端

参照 仓库 中的启动说明。

README

MCP NewsAPI.ai

[CI] [npm version] [License: MIT] [by Nubiia]

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_archive requires date_start and the date_start → date_end (default: today) range may span at most 1 year. A date_start/date_end older than 31 days without allow_archive is 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 and get_usage are free — use them to resolve entities to URIs before searching.
  • get_usage shows the remaining budget.

Costs measured against a live account (31-day window):

ToolTokens per call
search_articles, get_article1
search_events, get_event (info)5
get_event (include_articles)1
get_trending_concepts10
suggest_*, get_usage0

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

bash
npm install -g @nubiia/mcp-newsapi

Install from source

bash
git clone https://github.com/nubiia-dev/mcp-newsapi.gitcd mcp-newsapinpm installnpm run build

Configuration

Environment Variables

VariableRequiredDescription
NEWSAPI_AI_API_KEYYesYour NewsAPI.ai API key (Dashboard). Secret — never commit it.
NEWSAPI_AI_MAX_TOKENS_PER_SESSIONNoMax NewsAPI.ai tokens this server may spend per session (until the server process restarts). Default 200.
bash
export NEWSAPI_AI_API_KEY=your_newsapi_ai_keyexport 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

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:

json
{  "mcpServers": {    "newsapi": {      "command": "node",      "args": ["/path/to/mcp-newsapi/dist/index.js"],      "env": {        "NEWSAPI_AI_API_KEY": "your_newsapi_ai_key"      }    }  }}

Claude Code Configuration

bash
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 found when launching from inside this repo. If you start Claude Code (or another MCP client) from the cloned repository directory, npx @nubiia/mcp-newsapi resolves the local package.json instead of the published package, and the mcp-newsapi binary is not on the PATH. 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.

json
{ "prefix": "Telefónica", "types": ["org"], "count": 3 }

Searching for a company, person, place or organisation? Resolve it with suggest_concepts first and pass the returned uri as concept_uris. keyword is for free terms and topics and is noisy with common words: for example keyword: "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.

json
{  "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_event30 req/min
get_trending_concepts20 req/min
suggest_*, get_usage120 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

bash
npm installnpm run buildnpm test              # runs entirely against mocks — no network, no API keynpm run test:coveragenpm run lint

See CONTRIBUTING.md for the full workflow and docs/api-notes.md for API behaviour verified against a live account.

License

MIT

Related

来源:README.md,提交 f505b8a

工具

10

search_articles

Search news articles (NewsAPI.ai / Event Registry). Cost: 1 token per call (measured live) when limited to the last 31 days (the default); querying the historical archive (allow_archive=true) costs extra tokens per year touched. At least one of keyword / concept_uris / category_uris / source_uris / location_uris is required. Prefer concept_uris (from suggest_concepts, which is free) over free-text keyword for any company, person, place or organisation: keyword is for free terms/topics and is noisy with common words (e.g. "Telefónica" also matches the Spanish adjective "telefónica"), so resolve entities with suggest_concepts first and pass concept_uris. Results are compact: title, truncated body (body_len, default 300 chars), url, source, date, sentiment. Defaults to 10 results, newest first, duplicates skipped. Paginate with `page`; check `total` and `pages` in the response.

输入参数langpagecountkeywordsort_bybody_lendate_endsort_ascdata_typesdate_startkeyword_locsource_uris另有 10 个

get_article

Get one article by its URI (the `uri` returned by search_articles), with a longer body (body_len, default 3000 chars). Cost: 1 token per call. Use after search_articles when you need to read the article rather than just its headline.

输入参数body_lenarticle_uri必填

search_events

Search news EVENTS: clusters of articles about the same real-world happening, with a title, summary, date, location, key concepts and article count. Best for "what is happening with X" — one event replaces dozens of near-duplicate articles. Cost: 5 tokens (measured live) per call within the last 31 days (default); allow_archive=true costs extra per year touched. At least one of keyword / concept_uris / category_uris / source_uris / location_uris is required. Defaults to 10 events, newest first; use sort_by="size" for the biggest stories. Use get_event for details on one. For companies, people, places or organisations, resolve them with suggest_concepts first and pass concept_uris; keyword is for free terms/topics and is noisy with common words (e.g. "Telefónica" also matches the Spanish adjective "telefónica").

输入参数langpagecountkeywordsort_bydate_endsort_ascdate_startsource_urissummary_lenconcept_urisallow_archive另有 3 个

get_event

Get one event by URI (the `uri` from search_events, e.g. "eng-1234567"). Returns its summary info by default; set include_articles=true to instead list the articles covering it (paginated, default 5 per page, body truncated to body_len). Cost: 5 tokens (info view) or 1 (articles view), measured live.

输入参数body_lenevent_uri必填articles_pagearticles_countinclude_articles

suggest_concepts

Resolve a name to concept URIs (people, organisations, places, Wikipedia topics). Pass the returned `uri` as concept_uris to search_articles / search_events — much more precise than a keyword. Does not consume search tokens. Sorted by prominence in the news; check `type` and `label` to pick the right homonym.

输入参数langpagecounttypesprefix必填

suggest_categories

Resolve a topic name to category URIs (e.g. "news/Business", "dmoz/Sports/Soccer"). Pass the `uri` as category_uris to search_articles / search_events. Does not consume search tokens.

输入参数pagecountprefix必填

suggest_sources

Resolve a publication name or domain to news source URIs (e.g. "bbc.co.uk"). Pass the `uri` as source_uris to search_articles / search_events. Does not consume search tokens.

输入参数pagecountprefix必填data_types

suggest_locations

Resolve a city or country name to a location URI. Pass the `uri` as location_uris to search_articles / search_events to find news that happened there. Does not consume search tokens.

输入参数langpagecountprefix必填

get_usage

Get the token budget of this NewsAPI.ai account: tokens available, used and remaining for the current period. Call it before a batch of searches (measured costs: search_articles and get_article 1 token, search_events and get_event info 5, get_trending_concepts 10). Free: does not consume tokens itself. Suggest tools are free too. Also reports this server’s session budget (NEWSAPI_AI_MAX_TOKENS_PER_SESSION, default 200): calls that would exceed it fail locally without reaching the API.

无需输入参数。

版本历史

2
  1. v1.0.2最新Oct 22, 2026
  2. v1.0.1Oct 19, 2026

评分

已满足适用检查项的 90%

该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。

  • 近 30 天内可连通25 分
  • 已声明认证方式10 分

    请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。

  • 已列出工具必需15 分
  • 描述必需15 分
  • 图标10 分
  • 文档15 分
  • 许可证10 分