
Model Context Protocol (MCP) server for accessing the News API
概览
A Model Context Protocol (MCP) server that provides access to global news articles through the News API. This server implements a standardized interface for searching news articles, retrieving top headlines, and listing available news sources. - Search for news articles on any topic with advanced filtering options - Retrieve top headlines by country, category, or source - Get information about available news sources with filtering by category, language, and country - Built-in error handling and rate limit management - Clone the repository and build a local image to be utilized by your Claude desktop client - Change your claude_desktop_config.json to match the following, replacing REPLACE_API_KEY with your actual News API key: claude_desktop_config.json path - On MacOS: ~/Library/Application\ Support/Claude/claude_desktop_config.json - On Windows: %APPDATA%/Claude/claude_desktop_config.
README
以下为原文 README 节选,完整内容请查看原文。
News API MCP Server
A Model Context Protocol (MCP) server that provides access to global news articles through the News API. This server implements a standardized interface for searching news articles, retrieving top headlines, and listing available news sources.
Features
- Search for news articles on any topic with advanced filtering options
- Retrieve top headlines by country, category, or source
- Get information about available news sources with filtering by category, language, and country
- Built-in error handling and rate limit management
Installation
Using Claude Desktop
Installing via Docker
- Clone the repository and build a local image to be utilized by your Claude desktop client
cd news-api-mcp
docker build -t mcp/news-api .
- Change your
claude_desktop_config.jsonto match the following, replacingREPLACE_API_KEYwith your actual News API key:
claude_desktop_config.jsonpath
- On MacOS:
~/Library/Application\ Support/Claude/claude_desktop_config.json- On Windows:
%APPDATA%/Claude/claude_desktop_config.json
{
"mcpServers": {
"newsapi": {
"command": "docker",
"args": [
"run",
"-i",
"-e",
"NEWS_API_KEY",
"mcp/news-api"
],
"env": {
"NEWS_API_KEY": "REPLACE_API_KEY"
}
}
}
}
Installing via Smithery
To install News API MCP Server for Claude Desktop automatically via Smithery:
npx -y @smithery/cli install @berlinbra/news-api-mcp --client claude
Development Setup
Install packages
uv install -e .
Running
After connecting Claude client with the MCP tool via json file and installing the packages, Claude should see the server’s mcp tools.
You can run the server yourself via:
uv run src/news_api_mcp/server.py
with inspector:
npx @modelcontextprotocol/inspector uv --directory /Users/{INSERT_USER}/YOUR/PATH/TO/news-api-mcp run src/news_api_mcp/server.py
Available Tools
The server implements three tools:
search-news
Search for news articles on any topic.
Input Schema:
{
"query": {
"type": "string",
"description": "Keywords or phrases to search for in the article title and body"
},
"from_date": {
"type": "string",
"description": "Start date for article search (YYYY-MM-DD format)"
},
"to_date": {
"type": "string",
"description": "End date for article search (YYYY-MM-DD format)"
},
"sources": {
"type": "string",
"description": "Comma-separated list of news sources to filter by (e.g., 'bbc-news,cnn')"
},
"language": {
"type": "string",
"description": "Language of the articles",
"default": "en"
},
"sort_by": {
"type": "string",
"description": "Sort articles by relevancy, popularity, or publishedAt",
"default": "publishedAt"
},
"page_size": {
"type": "integer",
安装
docker run -i -e NEWS_API_KEY mcp/news-api配置
{
"mcpServers": {
"newsapi": {
"command": "docker",
"args": [
"run",
"-i",
"-e",
"NEWS_API_KEY",
"mcp/news-api"
],
"env": {
"NEWS_API_KEY": "REPLACE_API_KEY"
}
}
}
}