chileung69/google-search-mcp
If you are the rightful owner of google-search-mcp and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.
A Model Context Protocol (MCP) server that provides Google search functionality with intelligent result summarization.
google_search
Returns raw search results in JSON format.
google_search_and_summarize
Returns a comprehensive markdown summary of search results.
Google Search MCP Server
A Model Context Protocol (MCP) server that provides Google search functionality with intelligent result summarization. š° Save money by using Google's official API directly with 100 free searches per day - no need for expensive third-party search services!
šÆ Key Selling Points
- š° FREE TIER INCLUDED: Uses Google Custom Search JSON API with 100 free searches daily - no subscription fees like other search services
- š DIRECT GOOGLE API: Official Google integration means reliable, up-to-date results without middleman costs
- šø COST-EFFECTIVE: Only pay Google directly if you exceed free tier (vs. expensive monthly subscriptions for other search MCPs)
- š PRODUCTION-READY: Enterprise-grade reliability without enterprise pricing
Features
- Google Search Integration: Uses Google Custom Search JSON API for reliable search results
- Two Search Tools:
google_search
: Returns raw search results in JSON formatgoogle_search_and_summarize
: Returns a comprehensive markdown summary of search results
- Smart Summarization: Organizes results by domain, provides key findings, and includes source links
- Comprehensive Error Handling: Handles API errors, rate limits, and authentication issues
- Detailed Logging: Console logging for debugging and monitoring
Prerequisites
1. Google Custom Search API Setup
You need to set up Google Custom Search API credentials:
-
Create a Google Cloud Project:
- Go to Google Cloud Console
- Create a new project or select an existing one
-
Enable Custom Search API:
- Navigate to "APIs & Services" > "Library"
- Search for "Custom Search JSON API"
- Click on it and enable the API
-
Create API Key:
- Go to "APIs & Services" > "Credentials"
- Click "Create Credentials" > "API Key"
- Copy your API key (keep it secure!)
-
Create Custom Search Engine:
- Go to Google Custom Search Engine
- Click "Add" to create a new search engine
- Enter
google.com
as the site to search - Click "Create"
- Copy the Search Engine ID from the settings
2. Environment Variables
Set these environment variables:
export GOOGLE_API_KEY="your_google_api_key_here"
export GOOGLE_SEARCH_ENGINE_ID="your_search_engine_id_here"
Installation
-
Clone/Download the project:
cd google-search-mcp npm install npm run build
-
Test the server (optional):
# Set environment variables first export GOOGLE_API_KEY="your_api_key" export GOOGLE_SEARCH_ENGINE_ID="your_engine_id" # Test the server echo '{"jsonrpc": "2.0", "id": 1, "method": "tools/list"}' | node build/index.js
MCP Configuration
Add this server to your MCP settings (typically in Claude Desktop or other MCP clients):
For Claude Desktop
Add to your claude_desktop_config.json
:
{
"mcpServers": {
"google-search": {
"command": "node",
"args": ["/path/to/google-search-mcp/build/index.js"],
"env": {
"GOOGLE_API_KEY": "your_google_api_key_here",
"GOOGLE_SEARCH_ENGINE_ID": "your_search_engine_id_here"
},
"disabled": false,
"autoApprove": []
}
}
}
For Other MCP Clients
Use the same configuration pattern, adjusting the path to match your installation location.
Available Tools
1. google_search
Returns raw search results in JSON format.
Parameters:
query
(required): The search query stringnumResults
(optional): Number of results to return (1-10, default: 10)
Example Usage:
{
"name": "google_search",
"arguments": {
"query": "artificial intelligence trends 2024",
"numResults": 5
}
}
2. google_search_and_summarize
Returns a comprehensive markdown summary of search results.
Parameters:
query
(required): The search query stringnumResults
(optional): Number of results to analyze (1-10, default: 10)
Example Usage:
{
"name": "google_search_and_summarize",
"arguments": {
"query": "climate change renewable energy solutions",
"numResults": 8
}
}
Output Formats
Raw Search Results (google_search
)
{
"query": "your search query",
"totalResults": 5,
"results": [
{
"title": "Page Title",
"url": "https://example.com/page",
"snippet": "Brief description of the page content...",
"domain": "example.com"
}
]
}
Summarized Results (google_search_and_summarize
)
# Search Results Summary for "your query"
Found 5 relevant results:
## Key Findings:
1. **First Result Title**
Brief description from the search snippet
Source: example.com
2. **Second Result Title**
Another description
Source: another-site.com
## Sources:
1. [First Result Title](https://example.com/page1)
2. [Second Result Title](https://another-site.com/page2)
## Domain Distribution:
- example.com: 2 results
- another-site.com: 1 result
Error Handling
The server handles various error conditions:
- Missing API credentials: Clear error message about required environment variables
- API authentication errors: Specific guidance about checking API key and search engine ID
- Rate limiting: Informative message about API quota limits
- Network timeouts: 10-second timeout with appropriate error messages
- Invalid queries: Validation of empty or invalid search queries
Rate Limits & Cost Comparison
Google Custom Search JSON API Limits
- Free tier: 100 queries per day (FREE!)
- Paid tier: Up to 10,000 queries per day
- Per request: Maximum 10 results per search
š° Cost Comparison vs. Other Search Services
Service | Free Tier | Paid Plans | Monthly Cost (1000 searches) |
---|---|---|---|
This MCP (Google Direct) | ā 100/day FREE | $5/1000 queries | ~$5 |
Serper API | ā None | $50/month | $50+ |
SearchAPI | ā None | $20/month | $20+ |
SerpApi | ā None | $25/month | $25+ |
Bing Search API | 1000/month | $4/1000 queries | ~$4 |
Savings: Up to $600+ per year compared to premium search services!
Troubleshooting
Common Issues
-
"Missing required environment variables":
- Ensure
GOOGLE_API_KEY
andGOOGLE_SEARCH_ENGINE_ID
are set - Check that variable names are spelled correctly
- Ensure
-
"Google API authentication failed":
- Verify your API key is correct
- Ensure Custom Search JSON API is enabled in your Google Cloud project
- Check that your search engine ID is correct
-
"Rate limit exceeded":
- You've hit the daily quota limit
- Wait for the quota to reset or upgrade to a paid plan
-
"No search results found":
- Try different search terms
- Check if your custom search engine is configured to search the entire web
Debugging
Enable detailed logging by checking the console output when running the server. All operations are logged with prefixes like [Setup]
, [API]
, [Error]
, etc.
Development
Project Structure
google-search-mcp/
āāā src/
ā āāā index.ts # Main server implementation
āāā build/ # Compiled JavaScript output
āāā package.json # Dependencies and scripts
āāā tsconfig.json # TypeScript configuration
āāā README.md # This file
Available Scripts
npm run build
: Compile TypeScript to JavaScriptnpm run watch
: Watch for changes and rebuild automaticallynpm run inspector
: Run the MCP inspector for debugging
Contributing
- Make changes to
src/index.ts
- Test with
npm run build
- Update documentation as needed
- Test with actual MCP client integration
License
This project is private and for personal/internal use.