mcp-websearch
If you are the rightful owner of mcp-websearch 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 implementation for searching content from various Indonesian news portals and Wikipedia, deployable as a Google Cloud Function.
Web Search MCP Server
A Model Context Protocol (MCP) server implementation for searching content from various Indonesian news portals and Wikipedia. This application can be deployed as a Google Cloud Function.
What is MCP?
MCP (Model Context Protocol) is an open protocol that standardizes how applications provide context to LLMs. Think of MCP like a USB-C port for AI applications - it provides a standardized way to connect AI models to different data sources and tools.
Key Benefits
- A growing list of pre-built integrations that your LLM can directly plug into
- Flexibility to switch between LLM providers and vendors
- Best practices for securing your data within your infrastructure
Architecture Overview
MCP follows a client-server architecture where a host application can connect to multiple servers:
- MCP Hosts: Programs like Claude Desktop, IDEs, or AI tools that want to access data through MCP
- MCP Clients: Protocol clients that maintain 1:1 connections with servers
- MCP Servers: Lightweight programs that expose specific capabilities through the standardized Model Context Protocol
- Data Sources: Both local (files, databases) and remote services (APIs) that MCP servers can access
Core MCP Concepts
MCP servers can provide three main types of capabilities:
- Resources: File-like data that can be read by clients (like API responses or file contents)
- Tools: Functions that can be called by the LLM (with user approval)
- Prompts: Pre-written templates that help users accomplish specific tasks
System Requirements
- Python 3.11 or higher
- Google Cloud SDK
- Google Cloud account with billing enabled
- Serper API key for web search functionality
Local Development Setup
- Clone the repository:
git clone git@github.com:addhe/mcp-websearch.git
cd mcp-websearch
- Create and activate a virtual environment:
python -m venv .venv
source .venv/bin/activate # On Windows use: .venv\Scripts\activate
- Install dependencies:
pip install -r requirements.txt
- Create a
.env
file with your Serper API key:
SERPER_API_KEY=your_api_key_here
- Run locally:
python main.py
VS Code Integration
- Create
.vscode/mcp.json
with the following configuration:
{
"servers": {
"my-mcp-server-websearch": {
"type": "http",
"url": "https://your-cloud-function-url.cloudfunctions.net/websearch"
}
}
}
- Install any MCP-compatible extension in VS Code to use the search functionality.
Deploying to Google Cloud Functions
Prerequisites
- Install the Google Cloud SDK
- Initialize the SDK and set your project:
gcloud init
Deployment Steps
- Make sure your SERPER_API_KEY is set in your environment:
export SERPER_API_KEY=your_api_key_here
- Run the deployment script:
./deploy.sh
The script will:
- Enable required Google Cloud APIs
- Deploy the function with Python 3.11 runtime
- Configure the function with your SERPER_API_KEY
Function Usage
When using the MCP protocol, send HTTP POST requests with this JSON body format:
{
"name": "get_docs",
"parameters": {
"query": "your search query",
"library": "detik|liputan6|cnn|wikipedia"
}
}
Example response:
{
"result": "Text content from the searched portal",
"type": "success"
}
Available portals:
- detik (news.detik.com/berita)
- liputan6 (liputan6.com/news)
- cnn (cnnindonesia.com/nasional)
- wikipedia (www.wikipedia.org)
Technical Details
- Runtime: Python 3.11
- HTTP Trigger with MCP protocol support
- Async implementation using httpx and aiohttp
- BeautifulSoup4 for HTML parsing
- Memory: 256MB (default)
- Timeout: 60 seconds (default)
Environment Variables
SERPER_API_KEY
: Your Google Serper API key for web search functionality (required)
Error Handling
The function returns appropriate HTTP status codes:
- 200: Successful request with MCP format response
- 400: Missing or invalid parameters
- 404: Function name not found
- 500: Server error or timeout
Error responses follow MCP format:
{
"error": "Error message",
"type": "error"
}
Limitations
- Maximum timeout: 60 seconds
- Maximum memory: 256MB (can be increased if needed)
- Rate limits apply based on your Serper API plan
- Currently supports only Indonesian news portals and Wikipedia
Contributing
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add some amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
License
This project is licensed under the MIT License. See the file for details.