
MCP Server for GNews API
概览
A Model Context Protocol (MCP) server that provides access to the GNews API for fetching news articles and headlines. This server enables AI applications to search for news, get trending headlines, and access comprehensive news data through a standardized interface. - - Search for news articles using keywords with advanced filtering - - Get trending news articles by category - - List of supported language codes - - List of supported country codes - - Comprehensive guide to search query syntax - - Generate comprehensive news research prompts for specific topics 3. - Visit gnews.io - Sign up for a free account - Get your API key from the dashboard Add to your Claude Desktop configuration file (claude_desktop_config.json): The server supports the standard MCP protocol and can be used with any MCP-compatible client. Use the stdio transport for local connections. Search for news articles using specific keywords.
README
以下为原文 README 节选,完整内容请查看原文。
GNews API MCP Server
A Model Context Protocol (MCP) server that provides access to the GNews API for fetching news articles and headlines. This server enables AI applications to search for news, get trending headlines, and access comprehensive news data through a standardized interface.
Features
🔧 Tools
search_news- Search for news articles using keywords with advanced filteringget_top_headlines- Get trending news articles by category
📚 Resources
gnews://supported-languages- List of supported language codesgnews://supported-countries- List of supported country codesgnews://query-syntax- Comprehensive guide to search query syntax
🎯 Prompts
create_news_search_prompt- Generate comprehensive news research prompts for specific topics
Installation
-
Clone or download this repository
git clone cd gnews-server -
Install dependencies
pip install -r requirements.txt # or using uv uv sync -
Get a GNews API key
- Visit gnews.io
- Sign up for a free account
- Get your API key from the dashboard
-
Set up environment variables
export GNEWS_API_KEY="your_api_key_here"
Usage
Running the Server
Development mode (stdio):
python main.py
Using uv:
uv run main.py
Integration with Claude Desktop
Add to your Claude Desktop configuration file (claude_desktop_config.json):
{
"mcpServers": {
"gnews": {
"command": "python",
"args": ["/absolute/path/to/gnews-server/main.py"],
"env": {
"GNEWS_API_KEY": "your_api_key_here"
}
}
}
}
Integration with Other MCP Clients
The server supports the standard MCP protocol and can be used with any MCP-compatible client. Use the stdio transport for local connections.
API Reference
Tools
search_news
Search for news articles using specific keywords.
Parameters:
q(required): Search keywords with support for logical operatorslang(optional): Language code (2 letters, e.g., “en”, “es”)country(optional): Country code (2 letters, e.g., “us”, “gb”)max(optional): Number of articles to return (1-100, default: 10)in(optional): Search in specific fields: “title”, “description”, “content”nullable(optional): Allow null values for: “description”, “content”, “image”from(optional): Filter from date (ISO 8601 format)to(optional): Filter until date (ISO 8601 format)sortby(optional): Sort by “publishedAt” or “relevance”page(optional): Page number for pagination
Example queries:
- "Apple iPhone"
- "Apple AND iPhone"
- "Apple OR Microsoft"
- "(Apple AND iPhone) OR Microsoft"
- "Apple NOT iPhone"
- "Apple iPhone 15" AND NOT "Apple iPhone 14"
Returns:
{
"success": true,
安装
This server does not publish a one-line install command.
Open the repository installation guide 新手?先看 mcpskill.org 教程 →配置
{
"mcpServers": {
"gnews": {
"command": "python",
"args": ["/absolute/path/to/gnews-server/main.py"],
"env": {
"GNEWS_API_KEY": "your_api_key_here"
}
}
}
}