Skip to main content
Glama

MCP-EXP 项目

项目简介

MCP-EXP 是一个基于 MCP (Model Context Protocol) 框架的实验项目,集成了 OpenAI API 和 Serper API,用于实现热点新闻搜索、情感分析以及邮件发送等功能。

Related MCP server: newsapi-mcp

功能特点

  • 热点新闻搜索:通过 Serper API 搜索指定关键词的最新新闻

  • 情感分析:利用 OpenAI API 对新闻内容进行情感分析

  • 邮件发送:自动将分析结果发送到指定邮箱

  • 客户端-服务器架构:基于 MCP 框架实现异步通信

快速开始

环境要求

  • Python 3.10 或更高版本

  • uv 包管理器(推荐)或 pip

安装步骤

  1. 克隆仓库

    git clone https://github.com/HugoWw/MCP-EXP.git
    cd mcp-exp
  2. 安装依赖

    使用 uv(推荐):

    uv sync

    或使用 pip:

    pip install -e .
  3. 配置环境变量

    创建 .env 文件并添加以下配置:

    # OpenAI API 配置
    OPENAI_API_KEY=your_openai_api_key
    BASE_URL=your_api_base_url
    MODEL=your_model_name
    
    # Serper API 配置(用于谷歌新闻搜索)
    SERPER_API_KEY=your_serper_api_key
    
    # 邮件配置(用于发送结果)
    EMAIL_HOST=smtp.example.com
    EMAIL_PORT=465
    EMAIL_USER=your_email@example.com
    EMAIL_PASSWORD=your_email_password

运行项目

python client.py

启动脚本后根据提示输入内容,比如:
分析下小米yu7的热点新闻,并发送邮件给xxx@example.com

使用示例

新闻搜索与分析流程

  1. 客户端连接到服务器

  2. 调用新闻搜索工具获取热点新闻

  3. 对新闻进行情感分析

  4. 生成分析报告并保存

  5. 发送分析报告到指定邮箱

主要工具接口

项目提供了以下主要工具接口(可在 MCP 交互中使用):

  • search_google_news:搜索指定关键词的新闻

  • analyze_sentiment:分析新闻的情感倾向

  • send_email:发送邮件

生成的结果

生成的报告会存放到sentiment_reports目录下,如:该工程生成的示例报告

注意事项

根据实际项目情况修改和调整内容,(如 OpenAI API 密钥、Base URL、 SERPER_API_KEY等)为实际值。 SERPER_API_KEY可到Serper官网注册账户获取,邮箱的话可以去163去获取,模型可以去阿里的百练平台获取。

许可证

MIT License

Related MCP Connectors

Related MCP Servers

  • A
    license
    Not graded
    quality
    D
    maintenance
    This MCP server performs multi-topic searches in business, news, finance, and politics using the Tavily API, providing high-quality sources and intelligent summaries.
    1
    MIT
  • A
    license
    Not graded
    quality
    C
    maintenance
    A Model Context Protocol (MCP) server that provides real-time news intelligence using NewsAPI.ai. This server enables LLMs to search articles, track events, and analyze news through natural conversation.
    13 npm
    2
    MIT
  • F
    license
    Not graded
    quality
    D
    maintenance
    An AI-powered news aggregator MCP server that fetches live news from multiple sources, provides AI summaries via Claude, and performs sentiment analysis and trending topic detection.
    -
  • A
    license
    Not graded
    quality
    C
    maintenance
    A persistent news intelligence MCP server that enables AI agents to fetch, store, deduplicate, embed, and semantically query news from Google News across 141 countries and 41 languages.
    8
    MIT