MM

matteoantoci/mcp-newsapi

Developer tools

このページは AI により自動翻訳されています。技術的な詳細は原文をご確認ください。 原文を見る

3 stars 7 forks 品質 51 トレンド 10NOASSERTION

An MCP server exposing News API endpoints for searching and retrieving news articles. Provides reliable, easy-to-use tools for integrating news data into applications and workflows, with robust error...

概要

A Model Context Protocol (MCP) server that exposes endpoints from the News API (https://newsapi.org) to search for and retrieve news articles. This server allows programmatic access to news data via the MCP protocol. - Node.js (v18 or later recommended) - npm (comes with Node.js) - A News API key (get one from https://newsapi.org) - (Optional) MCP-compatible client or runner (e.g., VSCode extension, CLI) 3. This will create a build directory with the compiled JavaScript code. 4. The server reads the API key from the NEWSAPI_KEY environment variable. Set this variable in your environment before running the server. Example (Bash/Zsh): Replace "YOUR_API_KEY" with your actual News API key. - Ensure the NEWSAPI_KEY environment variable is set, then run: or, if you have a start script: - Configure your MCP client to run the server using stdio transport. You will also need to configure the environment variable for the API key within your MCP runner's settings.

README

以下は原文 README の抜粋です。原文を見る。

MCP News API Server

A Model Context Protocol (MCP) server that exposes endpoints from the News API (https://newsapi.org) to search for and retrieve news articles. This server allows programmatic access to news data via the MCP protocol.

Prerequisites

  • Node.js (v18 or later recommended)
  • npm (comes with Node.js)
  • A News API key (get one from https://newsapi.org)
  • (Optional) MCP-compatible client or runner (e.g., VSCode extension, CLI)

Setup

  1. Clone the repository or ensure you are in the project directory.

  2. Install dependencies:

    npm install
    
  3. Build the server:

    npm run build
    

    This will create a build directory with the compiled JavaScript code.

  4. Set your News API Key: The server reads the API key from the NEWSAPI_KEY environment variable. Set this variable in your environment before running the server. Example (Bash/Zsh):

    export NEWSAPI_KEY="YOUR_API_KEY"
    

    Replace "YOUR_API_KEY" with your actual News API key.

Running the Server

  • Directly: Ensure the NEWSAPI_KEY environment variable is set, then run:

    node build/index.js
    

    or, if you have a start script:

    npm run start
    
  • Via MCP runner: Configure your MCP client to run the server using stdio transport. You will also need to configure the environment variable for the API key within your MCP runner’s settings. Example MCP settings entry:

    "mcp-newsapi": {
      "transportType": "stdio",
      "command": "node",
      "args": [
        "/path/to/mcp-newsapi/build/index.js"
      ],
      "environment": {
        "NEWSAPI_KEY": "YOUR_API_KEY"
      }
      // ... other optional settings ...
    }
    

    Replace "YOUR_API_KEY" with your actual News API key.

Available Tools

The server exposes the following tools via MCP, corresponding to News API endpoints:

search_articles

  • Description: Searches for news articles using the News API “Everything” endpoint.
  • Input:
    • q (string, required): Keywords or phrases to search for in the article title and body.
    • sources (string, optional): A comma-separated string of identifiers for the news sources or blogs you want headlines from.
    • domains (string, optional): A comma-separated string of domains (e.g. bbc.co.uk, techcrunch.com) to search within.
    • excludeDomains (string, optional): A comma-separated string of domains (e.g. bbc.co.uk, techcrunch.com) to exclude from the search.
    • from (string, optional): A date and optional time for the oldest article allowed. Format: YYYY-MM-DD or YYYY-MM-DDTHH:MM:SS (e.g. 2024-01-01 or 2024-01-01T10:00:00).
    • to (string, optional): A date and optional time for the newest article allowed. Format: YYYY-MM-DD or YYYY-MM-DDTHH:MM:SS.
GitHub で README 全文を見る

インストール

This server does not publish a one-line install command.

Open the repository installation guide MCP 初心者?mcpskill.org のガイドから始めましょう →