虚假信息监测平台

TruthLens是一个基于MCP协议的AI辅助虚假信息检测与分析平台,提供自动化事实核查和虚假信息监控功能。

  • by NemroNeno
  • Python
  • 本地部署
  • 更新于
在 GitHub 查看 nemroneno/mcp_server_truthanalyzer

使用说明

TruthLens:虚假信息监控平台

TruthLens是一个模型上下文协议(MCP)服务器,为AI助手提供检测、分析和验证潜在错误信息的工具。它使用Python和MCP框架构建,实现了自动事实检查和错误信息监控功能。

📋 特性

  • 网络内容摄入:从URL和新闻源中提取内容
  • 索赔提取:使用谷歌的Gemini AI自动识别文本中的事实主张
  • 索赔验证:使用人工智能和外部知识来源评估索赔的准确性
  • 新闻监测:搜索和分析新闻内容以查找错误信息
  • 趋势分析:按主题跟踪和报告趋势错误信息

🏗️ 建筑

┌───────────────────────────────────────────────────────────┐
│                    TruthLens MCP Server                   │
├───────────────┬───────────────────────┬───────────────────┤
│  Data Sources │      Core Tools       │  External APIs    │
├───────────────┼───────────────────────┼───────────────────┤
│               │                       │                   │
│  Web Content  │   ingest_url()        │   Google Gemini   │
│  News Sites   │   extract_claims()    │   NewsAPI         │
│  Social Media │   verify_claim()      │   Wikipedia API   │
│  Wikipedia    │   search_news()       │   Reddit API      │
│  Fact-check   │   analyze_source()    │   Fact Check API  │
│  Databases    │   get_trending_info() │                   │
│               │   setup_monitor()     │                   │
│               │                       │                   │
└───────────────┴───────────────────────┴───────────────────┘
                          │
                          ▼
┌───────────────────────────────────────────────────────────┐
│                    MCP Clients / AI Models                 │
└───────────────────────────────────────────────────────────┘

数据流:

  1. AI助手或MCP客户端请求有关索赔或URL的信息
  2. TruthLens服务器从网络源获取内容或接收直接文本
  3. 使用模式匹配或Gemini AI提取索赔
  4. 每个索赔都使用多个来源(维基百科、事实核查数据库)进行验证
  5. 结果将与证据和置信度评分一起返回给客户

🚀 设置和安装

先决条件

  • Python 3.10或更高版本
  • 用于外部服务的API密钥:
    • Google Gemini API(必需)
    • 新闻API(可选)
    • Reddit API(可选)

紫外线安装(推荐)

紫外线的 是一个快速的Python包安装程序和解析器。要使用UV安装和运行TruthLens,请执行以下操作:

  1. 安装UV (如果尚未安装)

    pip install uv
    
  2. 克隆此存储库

    git clone <repository-url>
    cd MCP\ Build
    
  3. 创建并激活虚拟环境

    uv venv
    # On Windows
    .venv\Scripts\activate
    # On macOS/Linux
    source .venv/bin/activate
    
  4. 安装依赖项

    uv pip install -r requirements.txt
    
  5. 设置API密钥

    • 创建一个名为的新文件 .env 在根目录中
    • 使用以下格式添加API密钥:
    # TruthLens API Keys
    # Replace placeholder values with your actual API keys
    
    # Google Gemini API Key (required for LLM-based claim extraction and verification)
    # Get it from: https://aistudio.google.com/app/apikey
    GEMINI_API_KEY=your_gemini_api_key_here
    
    # NewsAPI Key (used for fetching news articles)
    # Get it from: https://newsapi.org/
    NEWSAPI_KEY=your_newsapi_key_here
    
    # Reddit API Credentials (optional, for production use)
    # Get from: https://www.reddit.com/prefs/apps
    # Instructions:
    #  1. Click "Create App" button at the bottom
    #  2. Select "script" for personal use
    #  3. Fill in name (e.g., "TruthLens")
    #  4. For redirect URI, use: http://localhost:8000 (even though this app doesn't use it)
    #  5. After creation, you'll receive a client ID and secret
    REDDIT_CLIENT_ID=your_reddit_client_id_here
    REDDIT_CLIENT_SECRET=your_reddit_client_secret_here
    REDDIT_USER_AGENT=TruthLens/0.1 (by /u/YourUsername)
    
    # Google Fact Check Tools API Key (optional, for production use)
    # Get from: https://developers.google.com/fact-check/tools/api/
    FACTCHECK_API_KEY=your_factcheck_api_key_here
    

    重要提示:

    • 至少,你需要 GEMINI_API_KEY 用于人工智能分析
    • 如果API键丢失,系统将回退到模式匹配和演示数据
    • 永远不要承诺你的 .env 文件到版本控制
  6. 运行服务器

    python run_server.py
    

带管道的替代安装

如果你没有安装UV,你可以使用pip:

python -m venv .venv
# On Windows
.venv\Scripts\activate
# On macOS/Linux
source .venv/bin/activate
pip install -r requirements.txt
python run_server.py

🧪 测试

通过向服务器的MCP端点发送请求来测试服务器:

  1. 基本演示资源

    truthlens://demo
    
  2. 工具示例

    ingest_url(url="https://en.wikipedia.org/wiki/COVID-19_vaccine")
    extract_claims(text="Vaccines are effective at preventing serious illness.")
    verify_claim(claim_text="Climate change is caused by human activities.")
    

📚 API密钥

以下API密钥用于此项目:

  1. Google Gemini API -基于人工智能的索赔提取和验证所需

    • 来自:https://aistudio.google.com/app/apikey
  2. 新闻API -新闻搜索功能

    • 来自:https://newsapi.org/
  3. Reddit API -用于社交媒体内容监控(可选)

    • 来自:https://www.reddit.com/prefs/apps

⚠️ 局限性

  • 当前的实现使用内存存储,不适合生产
  • 与人工智能分析相比,模式匹配回退的准确性有限
  • 网络抓取可能受到费率限制和服务条款限制

📝 许可证

MIT许可证

🤝 贡献

欢迎投稿!请随时提交拉取请求。