๐ 4get MCP Server
A MCP server that enables seamless access to the 4get Meta Search engine API for LLM clients via FastMCP.
)



โจ Features
- ๐ Multi Search Functions: Conduct web, image, and news searches with comprehensive result formatting.
- โก Smart Caching: Implement TTL-based response caching with configurable size limits.
- ๐ Retry Logic: Apply exponential backoff for rate-limited and network errors.
- ๐๏ธ Production Ready: Utilize connection pooling, comprehensive error handling, and validation.
- ๐ Rich Responses: Receive featured answers, related searches, pagination support, and more.
- ๐งช Well Tested: Benefit from an extensive test suite including integration tests with real API, unit tests, and more.
- โ๏ธ Highly Configurable: Fine-tune the server using 11+ environment variables.
- ๐ฏ Engine Shorthands: Select a 4get scraper via the
engine parameter without memorizing query strings.
๐ฆ Installation
๐ Requirements
- Python 3.13+
- uv for dependency management
๐ Quick Start
uv sync
uv run -m mcp_4get
mise run
โ๏ธ Configuration
The server can be highly configured through environment variables. All settings have reasonable defaults for the public https://4get.ca instance.
Core Settings
| Property |
Details |
Default |
FOURGET_BASE_URL |
Base URL for the 4get instance |
https://4get.ca |
FOURGET_PASS |
Optional pass token for rate-limited instances |
unset |
FOURGET_USER_AGENT |
Override User-Agent header |
mcp-4get/<version> |
FOURGET_TIMEOUT |
Request timeout in seconds |
20.0 |
Caching & Performance
| Property |
Details |
Default |
FOURGET_CACHE_TTL |
Cache lifetime in seconds |
600.0 |
FOURGET_CACHE_MAXSIZE |
Maximum cached responses |
128 |
FOURGET_CONNECTION_POOL_MAXSIZE |
Max concurrent connections |
10 |
FOURGET_CONNECTION_POOL_MAX_KEEPALIVE |
Max persistent connections |
5 |
Retry & Resilience
| Property |
Details |
Default |
FOURGET_MAX_RETRIES |
Maximum retry attempts |
3 |
FOURGET_RETRY_BASE_DELAY |
Base retry delay in seconds |
1.0 |
FOURGET_RETRY_MAX_DELAY |
Maximum retry delay in seconds |
60.0 |
๐ป Usage Examples
Running the Server
Local Development
uv run -m mcp_4get
Production Deployment
export FOURGET_BASE_URL="https://my-4get-instance.com"
export FOURGET_PASS="my-secret-token"
export FOURGET_CACHE_TTL="300"
export FOURGET_MAX_RETRIES="5"
uv run -m mcp_4get
MCP Server Integration
Cursor IDE
Add this to your Cursor MCP configuration (~/.cursor/mcp.json):
{
"mcpServers": {
"4get": {
"command": "uvx",
"args": [
"mcp_4get@latest"
],
"env": {
"FOURGET_BASE_URL": "https://4get.ca"
}
}
}
}
OpenAI Codex
Add this to your Codex MCP configuration (~/.codex/config.toml):
[mcp_servers.4get]
command = "uvx"
args = ["mcp_4get@latest"]
env = { FOURGET_BASE_URL = "https://4get.ca" }
Note: Replace /path/to/your/mcp-4get with the actual path to your project directory.
MCP Tools
fourget_web_search
fourget_web_search(
query: str,
page_token: str = None,
extended_search: bool = False,
engine: str = None,
extra_params: dict = None
)
Response includes: web[], answer[], spelling, related[], npt
fourget_image_search
fourget_image_search(
query: str,
page_token: str = None,
engine: str = None,
extra_params: dict = None
)
Response includes: image[], npt
fourget_news_search
fourget_news_search(
query: str,
page_token: str = None,
engine: str = None,
extra_params: dict = None
)
Response includes: news[], npt
Engine shorthands
All MCP tools accept an optional engine argument that maps directly to the 4get scraper query parameter. This shorthand overrides any scraper value you may include in extra_params.
| Value |
Engine |
ddg |
DuckDuckGo |
brave |
Brave |
mullvad_brave |
Mullvad (Brave) |
yandex |
Yandex |
google |
Google |
google_cse |
Google CSE |
mullvad_google |
Mullvad (Google) |
startpage |
Startpage |
qwant |
Qwant |
ghostery |
Ghostery |
yep |
Yep |
greppr |
Greppr |
crowdview |
Crowdview |
mwmbl |
Mwmbl |
mojeek |
Mojeek |
baidu |
Baidu |
coccoc |
Coc Coc |
solofield |
Solofield |
marginalia |
Marginalia |
wiby |
wiby |
curlie |
Curlie |
If you need to pass additional 4get query parameters (such as country or language), continue to supply them through extra_params.
๐ Pagination
All tools support pagination via the npt (next page token):
result = await client.web_search("python programming")
if result.get('npt'):
next_page = await client.web_search("ignored", page_token=result['npt'])
๐ Using the Async Client Directly
import asyncio
from mcp_4get.client import FourGetClient
from mcp_4get.config import Config
async def main() -> None:
client = FourGetClient(Config.from_env())
data = await client.web_search(
"model context protocol",
options={"scraper": "mullvad_brave"},
)
for result in data.get("web", []):
print(result["title"], "->", result["url"])
asyncio.run(main())
This enables you to integrate 4get search capabilities directly into your Python applications without going through the MCP protocol.
๐ง Technical Details
๐ก๏ธ Error Handling & Resilience
Automatic Retry Logic
- Rate Limiting (429): Exponential backoff with jitter
- Network Errors: Connection failures and timeouts
- Non-retryable: HTTP 404/500 errors fail immediately
Error Types
FourGetAuthError: Rate limited or invalid authentication
FourGetAPIError: API returned non-success status
FourGetTransportError: Network or HTTP protocol errors
FourGetError: Generic client errors
Configuration Validation
All settings are validated on startup, with clear error messages for misconfigurations.
๐ Response Format
Based on the real 4get API, responses include rich metadata:
{
"status": "ok",
"web": [
{
"title": "Example Result",
"description": "Result description...",
"url": "https://example.com",
"date": 1640995200,
"type": "web"
}
],
"answer": [
{
"title": "Featured Answer",
"description": [{"type": "text", "value": "Answer content..."}],
"url": "https://source.com",
"table": {"Key": "Value"}
}
],
"spelling": {
"type": "no_correction",
"correction": null
},
"related": ["related search", "terms"],
"npt": "pagination_token_here"
}
๐งช Testing
uv run pytest
uv run pytest -m "not integration"
uv run pytest -m integration
uv run pytest --cov=src
uv run pytest tests/test_cache.py
uv run pytest tests/test_client.py
uv run pytest tests/test_integration.py
Test Categories
- Unit Tests: Fast, deterministic tests using mock transports
- Integration Tests: Real API tests with rate limiting and resilience validation
- Cache Tests: TTL expiration, eviction policies, concurrent access
- Retry Tests: Exponential backoff, error handling, timeout scenarios
- Configuration Tests: Validation logic and environment variable parsing
The tests follow FastMCP testing guidelines with comprehensive fixtures and proper isolation.
๐ค Contributing
- Setup: Refer to the Installation and Quick Start sections.
- Tests: See the Testing section.
- Linting: Run
uv run ruff check.
- Format: Run
uv run ruff format.
๐ License
GPLv3 License - see LICENSE file for details.