新闻分析助手

一个基于NewsAPI.org和大型语言模型的新闻信息获取与分析工具,提供新闻搜索、信息提取和情感分析功能。

  • by an1604
  • Python
  • 本地部署
  • 更新于
在 GitHub 查看 an1604/news-mcp-server

使用说明

GenAI新闻助手MCP服务器

此存储库包含一个用于构建模型上下文协议(MCP)服务器的模板,该服务器提供使用NewsAPI.org和大型语言模型获取和分析新闻信息的工具。

项目结构

.
├── python/                # Python implementation
│   ├── Dockerfile         # Python Docker configuration
│   └── src/               # Python source code
├── typescript/            # TypeScript implementation
│   ├── Dockerfile         # TypeScript Docker configuration
│   └── src/               # TypeScript source code
└── README.md              # This file

先决条件

  • Docker已安装在您的系统上
  • NewsAPI.org API密钥(免费注册,网址:https://newsapi.org/)
  • OpenAI API密钥(用于LLM功能)

环境变量

需要以下环境变量:

  • NEWS_API_KEY:您的NewsAPI.org API密钥
  • OPENAI_API_KEY:您的OpenAI API密钥

建立和运行

Python版本

# Build the Docker image
cd python
docker build -t news-assistant-python .

# Run the container
docker run -p 3000:3000 \
  -e NEWS_API_KEY=your_news_api_key \
  -e LLM_API_KEY=your_llm_api_key \
  news-assistant-python

TypeScript版本

# Build the Docker image
cd typescript
docker build -t news-assistant-typescript .

# Run the container
docker run -p 3000:3000 \
  -e NEWS_API_KEY=your_news_api_key \
  -e LLM_API_KEY=your_llm_api_key \
  news-assistant-typescript

测试

您可以使用MCP检查器验证服务器在开发中是否按预期工作https://github.com/modelcontextprotocol/inspector

MCP工具

服务器应实现以下MCP工具:

  1. search_news:搜索与特定查询匹配的最新新闻文章
  2. extract_information_from_article:从新闻文章中提取结构化信息
  3. extract_key_info_and_sentiment:分析关键实体和情绪的新闻文章

有关每个工具的详细规格,请参阅作业文件。

发展

根据您的喜好选择Python或TypeScript实现。这两种实现都通过MCP接口提供相同的功能。

许可证

这是一个仅用于带回家分配的私有存储库。