elos-navy/elos-google-search-mcp
If you are the rightful owner of elos-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 dayong@mcphub.com.
Elos Google Search MCP Server is a Model Context Protocol server that integrates Google Search capabilities using FastMCP and the Google Custom Search API.
Elos Google Search MCP Server
A Model Context Protocol (MCP) server that provides Google Search capabilities using FastMCP and the Google Custom Search API.
Features
- Google Search: Perform web searches using Google Custom Search API
- Image Search: Search for images using Google Image Search
- Web Search: Specialized web search functionality
- Health Monitoring: Built-in health checks and status monitoring
- Flexible Authentication: Support for API keys and service accounts
- FastMCP Integration: Built on the FastMCP framework for optimal performance
Prerequisites
Google API Setup
- Google Cloud Project: Create a project in Google Cloud Console
- Enable APIs: Enable the following APIs:
- Custom Search API
- Custom Search Engine API
- Create Custom Search Engine:
- Go to Google Programmable Search Engine
- Create a new search engine
- Note the Search Engine ID (cx)
- API Key or Service Account:
- Option A: Create an API key in Google Cloud Console
- Option B: Create a service account and download the JSON credentials
Local Development Requirements
- Python 3.9+
- Docker/Podman
- Access to quay.io registry
Installation
Local Development
-
Clone the repository:
git clone <repository-url> cd elos-mcp-google-search -
Install dependencies:
pip install -e . -
Set environment variables:
export GOOGLE_API_KEY="your-api-key" export GOOGLE_CSE_ID="your-search-engine-id" # OR for service account: export GOOGLE_APPLICATION_CREDENTIALS="/path/to/service-account.json" -
Run the server:
python -m elos_google_search_mcp.server
Docker Build
-
Build the image:
podman build -t elos-google-search-mcp:latest . -
Test locally:
podman run -p 8000:8000 \ -e GOOGLE_API_KEY="your-api-key" \ -e GOOGLE_CSE_ID="your-search-engine-id" \ elos-google-search-mcp:latest
Deployment
Push to Quay.io
-
Login to Quay.io:
podman login quay.io -
Tag the image:
podman tag elos-google-search-mcp:latest quay.io/elostech/elos-mcp-google-search:latest -
Push the image:
podman push quay.io/elostech/elos-mcp-google-search:latest
Kubernetes Deployment
-
Update the secret with your actual credentials:
# Edit kubernetes/elos-google-search-secret.yaml # Replace placeholder values with actual credentials -
Apply the configuration:
kubectl apply -k kubernetes/ -
Verify deployment:
kubectl get pods -l app=elos-google-search-mcp kubectl get services -l app=elos-google-search-mcp
Configuration
Environment Variables
| Variable | Description | Required |
|---|---|---|
GOOGLE_API_KEY | Google API key for authentication | Yes (if using API key) |
GOOGLE_CSE_ID | Custom Search Engine ID | Yes |
GOOGLE_APPLICATION_CREDENTIALS | Path to service account JSON file | Yes (if using service account) |
Kubernetes Secrets
The deployment uses Kubernetes secrets to store sensitive information:
google-api-key: Your Google API keygoogle-cse-id: Your Custom Search Engine IDgoogle-credentials: Service account JSON (if using service account auth)
API Endpoints
The MCP server provides the following tools:
google_search(query, num_results)
Perform a general Google search.
Parameters:
query(str): Search query stringnum_results(int): Number of results (max 10)
Returns: List of search results with title, link, and snippet
google_search_web(query, num_results)
Perform a web-specific search.
Parameters:
query(str): Search query stringnum_results(int): Number of results (max 5)
Returns: List of web search results
google_search_images(query, num_results)
Search for images.
Parameters:
query(str): Search query stringnum_results(int): Number of results (max 5)
Returns: List of image search results
get_search_health()
Check server health and configuration.
Returns: Health status and configuration information
Usage Examples
Basic Search
from elos_google_search_mcp.server import google_search
results = google_search("OpenAI GPT-4", num_results=5)
for result in results:
print(f"Title: {result['title']}")
print(f"Link: {result['link']}")
print(f"Snippet: {result['snippet']}")
print("---")
Health Check
from elos_google_search_mcp.server import get_search_health
health = get_search_health()
print(f"Status: {health['status']}")
print(f"Credentials Available: {health['credentials_available']}")
Troubleshooting
Common Issues
-
"No Google credentials available"
- Ensure environment variables are set correctly
- Check that API key or service account file is valid
-
"GOOGLE_CSE_ID environment variable not set"
- Set the
GOOGLE_CSE_IDenvironment variable - Verify the Custom Search Engine ID is correct
- Set the
-
API Quota Exceeded
- Check your Google Cloud Console for quota limits
- Consider upgrading your API plan
-
Authentication Errors
- Verify API key permissions
- Check service account roles and permissions
Debug Mode
Enable debug logging by setting the log level:
import logging
logging.basicConfig(level=logging.DEBUG)
Development
Project Structure
elos-mcp-google-search/
├── elos_google_search_mcp/
│ ├── __init__.py
│ └── server.py
├── kubernetes/
│ ├── elos-google-search-deployment.yaml
│ ├── elos-google-search-secret.yaml
│ └── kustomization.yaml
├── Containerfile
├── pyproject.toml
└── README.md
Adding New Tools
To add new search tools, use the @mcp.tool() decorator:
@mcp.tool()
def new_search_function(query: str) -> Dict[str, Any]:
"""Description of the new tool."""
# Implementation here
return {"result": "data"}
Testing
Run tests locally:
pytest tests/
Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests for new functionality
- Submit a pull request
License
This project is licensed under the MIT License - see the LICENSE file for details.
Support
For support and questions:
- Create an issue in the GitHub repository
- Contact the Elos Tech team
Changelog
v0.1.0
- Initial release
- Google Search functionality
- Image search support
- Health monitoring
- Kubernetes deployment support