Is TrendRadar a Command-Line Tool or a Web Application? Both Modes Explained

TrendRadar is primarily a command-line tool invoked with python -m trendradar, but it also ships an optional FastMCP-based HTTP server that exposes the same functionality through a web API.

TrendRadar is an open-source news aggregation and analysis project that can operate in two distinct modes depending on your deployment needs. The core functionality—crawling platforms, analyzing frequency, generating AI insights, and building reports—remains identical across both interfaces. The only difference is the outer wrapper that launches the process.


How TrendRadar Works as a Command-Line Tool

The CLI mode is the default and most common way to run TrendRadar. It is designed for scheduled execution, local automation, and direct terminal interaction.

CLI Entry Point

The command-line interface is implemented in trendradar/__main__.py. This file handles argument parsing through argparse and orchestrates the full analysis pipeline.


# Basic execution with default configuration

python -m trendradar

# Incremental report mode with proxy configuration

python -m trendradar \
    --report-mode incremental \
    --proxy http://127.0.0.1:7890

What Happens During CLI Execution

When you invoke TrendRadar from the command line, trendradar/__main__.py performs the following steps:

  1. Parses CLI arguments (--report-mode, --proxy, --config, etc.)
  2. Loads configuration from config/config.yaml via trendradar.core.config.load_config()
  3. Instantiates NewsAnalyzer from trendradar/core/analyzer.py
  4. Executes the crawler to fetch news from configured platforms
  5. Performs frequency analysis and AI-powered content analysis
  6. Generates HTML reports in trendradar/report/ modules
  7. Dispatches notifications if configured

The CLI mode is ideal for cron jobs, CI/CD pipelines, and local development workflows where you want direct control over execution parameters.


How TrendRadar Works as a Web Application

TrendRadar can also run as an HTTP server using the Model Context Protocol (MCP) implementation. This mode exposes the analysis functionality as JSON-RPC tools that can be called over HTTP.

Web Server Architecture

The web interface is built on FastMCP 2.0, a Python framework for implementing MCP servers. The server code resides in mcp_server/server.py and registers tool functions that mirror the CLI capabilities.


# Start the HTTP server using the provided script

./start-http.sh

# Or start manually with uv

uv run python -m mcp_server.server \
    --transport http \
    --host 0.0.0.0 \
    --port 3333

Available Web API Tools

The MCP server exposes several tools defined in mcp_server/tools/:

Tool Description
get_latest_news Retrieve latest news from specified platforms
search_news Search news with keywords and date filters
resolve_date_range Parse natural language date expressions

Example HTTP API Call

You can interact with the TrendRadar web server using standard HTTP POST requests:

curl -X POST http://localhost:3333/mcp \
  -H "Content-Type: application/json" \
  -d '{
        "jsonrpc":"2.0",
        "method":"get_latest_news",
        "params":{
          "platforms":["zhihu","weibo"],
          "limit":20,
          "include_url":true
        },
        "id":1
      }'

The response contains JSON-encoded news data identical to what the CLI generates.

Alternative: stdio Transport Mode

The MCP server also supports stdio mode for local integration with other Python processes:

python - <<'PY'
import json, subprocess, sys

proc = subprocess.Popen(
    [sys.executable, "-m", "mcp_server.server", "--transport", "stdio"],
    stdin=subprocess.PIPE, stdout=subprocess.PIPE, text=True
)

request = json.dumps({
    "jsonrpc":"2.0",
    "method":"resolve_date_range",
    "params":{"expression":"本周"},
    "id":42
}) + "\n"

proc.stdin.write(request)
proc.stdin.flush()
print(proc.stdout.readline())
PY

Core Architecture: Shared Between Both Modes

Whether you run TrendRadar as a command-line tool or a web application, the underlying functionality is identical. Both modes leverage the same core modules:

Module Path Purpose
trendradar/core/config.py Configuration loading from config/config.yaml
trendradar/core/analyzer.py Main NewsAnalyzer orchestration class
trendradar/core/scheduler.py Task scheduling and execution
trendradar/ai/ AI-powered content analysis and translation
trendradar/report/ HTML report and RSS generation
trendradar/utils/ Shared utility functions

The CLI wrapper (trendradar/__main__.py) and MCP server (mcp_server/server.py) are thin layers that instantiate these core components differently:

  • CLI: Parses terminal arguments, runs once, outputs to files/stdout
  • Web: Registers tools, listens for HTTP requests, returns JSON responses

Summary

  • TrendRadar is both a command-line tool and a web application—the same codebase supports both interfaces.

  • CLI mode (python -m trendradar) is the default entry point via trendradar/__main__.py, ideal for automation and scheduled execution.

  • Web mode starts a FastMCP HTTP server via mcp_server/server.py, exposing JSON-RPC tools for remote access and integration.

  • Both modes share identical core functionality—crawling, analysis, AI processing, and reporting—accessed through different wrappers.

  • Launch scripts (start-http.sh, start-http.bat) simplify starting the web server with proper configuration.


Frequently Asked Questions

How do I choose between CLI and web mode for TrendRadar?

Choose CLI mode for local automation, cron jobs, or when you need file-based outputs. Choose web mode when integrating with other services, building custom dashboards, or when multiple clients need remote access to TrendRadar's analysis capabilities.

Can I run both CLI and web modes simultaneously?

Yes. The modes are independent processes. You can run the CLI for scheduled reporting while the HTTP server handles ad-hoc queries. Both access the same configuration files and can share data directories if configured appropriately.

What protocols does the TrendRadar web server support?

The web server implements FastMCP 2.0 with JSON-RPC 2.0 over HTTP. It supports both HTTP transport (for remote clients) and stdio transport (for local process integration). The endpoint /mcp handles all incoming tool requests.

Does the web API provide the same features as the CLI?

The web API exposes a subset of core functionality as discrete tools—currently get_latest_news, search_news, and resolve_date_range. The CLI includes additional orchestration features like scheduled execution, full report generation, and multi-channel notification dispatch that are not yet exposed as web tools.

Have a question about this repo?

These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:

Share the following with your agent to get started:
curl -s "https://instagit.com/install.md"

Works with
Claude Codex Cursor VS Code OpenClaw Any MCP Client

Maintain an open-source project? Get it listed too →