- Google Alerts Mcp
Google Alerts Mcp
Retrieves news articles from google alerts service on specific topics.
Content
Google Alerts MCP Server
A Google Alerts plugin based on MCP (Model Context Protocol) that retrieves news articles on specific topics by simulating browser workflows. This plugin dynamically extracts state parameters from Google Alerts pages to avoid detection and blocking.
Features
- Dynamic State Extraction: Automatically extracts
window.STATEparameters from Google Alerts pages - Anti-Detection Mechanism: Uses fresh tokens and session cookies for each request to avoid blocking
- Multi-Language Support: Supports searches in Chinese, English, and other languages
- Browser Workflow Simulation: Fully simulates browser access flow: visit homepage → extract cookies/state → build preview URL
- No Hardcoded Parameters: All authentication tokens and state parameters are dynamically extracted, no hardcoded values
- URL Cleaning Feature: Configurable option to remove Google redirect parameters and get direct news links
Workflow
- Get Initial Cookies: Visit
https://www.google.com/alerts?hl={language}to get initial cookies - State Parameter Extraction: Extract
window.STATEparameters from the page, including authentication tokens - Build Preview URL: Use extracted parameters and search query to build preview URL
- Get Content: Use correct cookies and state parameters to get preview page
- Article Parsing: Extract article titles, URLs, snippets, and sources from HTML response
Installation
Using UV package manager:
# Clone the project
git clone https://github.com/ycrao/google-alerts-mcp.git
cd google-alerts-mcp
# Install dependencies
uv sync
# Activate virtual environment
source .venv/bin/activate # Windows: .venv\Scripts\activate
# Or run directly
uv run python src/google_alerts_mcp/server.py
Usage
Running as MCP Server
Add to your MCP client configuration:
{
"mcpServers": {
"google-alerts": {
"command": "uv",
"args": [
"--directory",
"/ABSOLUTE/PATH/TO/google-alerts-mcp/src/google_alerts_mcp/",
"run",
"server.py"
],
"env": {}
}
}
}
Or if published as a package:
{
"mcpServers": {
"google-alerts": {
"command": "uvx",
"args": ["google-alerts-mcp"],
"env": {}
}
}
}
Available Tools
search_google_alerts
Search Google Alerts news articles for specific topics.
Parameters:
query(required): Search query/topic (e.g., "silver", "bitcoin", "artificial intelligence")language(optional): Language code (default: "zh-CN")region(optional): Region code (default: "US")clean_urls(optional): Whether to clean Google redirect parameters for direct links (default: true)
Example:
{
"query": "bitcoin",
"language": "en-US",
"region": "US",
"clean_urls": true
}
URL Cleaning Feature:
- When
clean_urls=true, automatically removes Google redirect parameters and returns direct news website links - When
clean_urls=false, preserves original Google redirect URLs - Before cleaning:
https://www.google.com/url?q=https://example.com/article&sa=U&ved=... - After cleaning:
https://example.com/article
Technical Details
Dynamic Parameter Extraction
The server extracts the following parameters from window.STATE:
domain: Google domain (usually "com")language: Language code from stateregion: Region code from statenumber_param: Numeric parameter (varies by language)locale_format: Locale format stringtoken: Authentication token (key to avoiding detection)
Anti-Detection Features
- Fresh token extraction for each request
- Session cookie persistence
- Proper browser headers
- No hardcoded authentication parameters
- Graceful degradation when token extraction fails
Testing
Run the test suite to verify functionality:
# Test complete MCP server functionality
python test_mcp_server.py
Test Examples
# Test search functionality
import asyncio
from google_alerts_mcp.server import GoogleAlertsClient
async def test():
client = GoogleAlertsClient()
try:
# Chinese search
articles = await client.get_preview_content("白银", "zh-CN")
for article in articles:
print(f"Title: {article.title}")
print(f"URL: {article.url}")
print(f"Snippet: {article.snippet}")
print(f"Source: {article.source}")
print("-" * 50)
# English search (with URL cleaning enabled)
client_clean = GoogleAlertsClient(clean_urls=True)
articles = await client_clean.get_preview_content("bitcoin", "en-US")
for article in articles:
print(f"Title: {article.title}")
print(f"URL: {article.url}") # Direct link, no Google redirect parameters
print(f"Snippet: {article.snippet}")
print(f"Source: {article.source}")
print("-" * 50)
await client_clean.close()
# English search (preserve original URLs)
client_original = GoogleAlertsClient(clean_urls=False)
articles = await client_original.get_preview_content("bitcoin", "en-US")
for article in articles:
print(f"Title: {article.title}")
print(f"URL: {article.url}") # Contains Google redirect parameters
print(f"Snippet: {article.snippet}")
print(f"Source: {article.source}")
print("-" * 50)
await client_original.close()
finally:
await client.close()
asyncio.run(test())
Important Notes
- Dynamic Tokens: The system now fully relies on dynamically extracted tokens, no longer using any hardcoded values
- URL Cleaning: URL cleaning is enabled by default, can be disabled with
clean_urls=falseparameter to preserve original Google redirect URLs - Request Frequency: Avoid overly frequent requests, recommend appropriate intervals
- Error Handling: If token extraction fails, requests will fail gracefully rather than using outdated hardcoded values
- Real-time State: Each search gets fresh state parameters, ensuring optimal anti-detection effectiveness
Dependencies
- mcp: Model Context Protocol support
- httpx: Async HTTP client
- beautifulsoup4: HTML parsing
- pydantic: Data validation and serialization
License
MIT License
Server Config
{
"mcpServers": {
"google-alerts": {
"command": "uvx",
"args": [
"google-alerts-mcp"
],
"env": {}
}
}
}Recommend Servers
TraeBuild with Free GPT-4.1 & Claude 3.7. Fully MCP-Ready.
EdgeOne Pages MCPAn MCP service designed for deploying HTML content to EdgeOne Pages and obtaining an accessible public URL.
Jina AI MCP ToolsA Model Context Protocol (MCP) server that integrates with Jina AI Search Foundation APIs.
MCP AdvisorMCP Advisor & Installation - Use the right MCP server for your needs
Baidu Map百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Serper MCP ServerA Serper MCP Server
Tavily Mcp
Zhipu Web SearchZhipu Web Search MCP Server is a search engine specifically designed for large models. It integrates four search engines, allowing users to flexibly compare and switch between them. Building upon the web crawling and ranking capabilities of traditional search engines, it enhances intent recognition capabilities, returning results more suitable for large model processing (such as webpage titles, URLs, summaries, site names, site icons, etc.). This helps AI applications achieve "dynamic knowledge acquisition" and "precise scenario adaptation" capabilities.
ChatWiseThe second fastest AI chatbot™
MiniMax MCPOfficial MiniMax Model Context Protocol (MCP) server that enables interaction with powerful Text to Speech, image generation and video generation APIs.
AiimagemultistyleA Model Context Protocol (MCP) server for image generation and manipulation using fal.ai's Stable Diffusion model.
Y GuiA web-based graphical interface for AI chat interactions with support for multiple AI models and MCP (Model Context Protocol) servers.
TimeA Model Context Protocol server that provides time and timezone conversion capabilities. This server enables LLMs to get current time information and perform timezone conversions using IANA timezone names, with automatic system timezone detection.
WindsurfThe new purpose-built IDE to harness magic
Playwright McpPlaywright MCP server
CursorThe AI Code Editor
Amap Maps高德地图官方 MCP Server
DeepChatYour AI Partner on Desktop
BlenderBlenderMCP connects Blender to Claude AI through the Model Context Protocol (MCP), allowing Claude to directly interact with and control Blender. This integration enables prompt assisted 3D modeling, scene creation, and manipulation.
Howtocook Mcp基于Anduin2017 / HowToCook (程序员在家做饭指南)的mcp server,帮你推荐菜谱、规划膳食,解决“今天吃什么“的世纪难题;
Based on Anduin2017/HowToCook (Programmer's Guide to Cooking at Home), MCP Server helps you recommend recipes, plan meals, and solve the century old problem of "what to eat today"
Visual Studio Code - Open Source ("Code - OSS")Visual Studio Code