Logo di 4get

4get

Community
yshalsager

A MCP server that provides seamless access to the 4get.ca Meta Search Engine API for LLM clients via FastMCP.

Autoreyshalsager
Repositorymcp-4get
LinguaPython
Fork
3
Stelle
16
Strumenti disponibili
0
Tipo di trasportostdio
Categorie
LicenzaGPL-3.0
Link
  • Collega gli strumenti ai flussi di lavoro IA

    4get mette a disposizione funzionalità MCP utilizzabili da client e agenti IA compatibili.

  • 0 strumenti disponibili

    Esplora le azioni richiamabili qui sotto, con nomi e descrizioni quando forniti dal server.

  • Configurazione pronta da copiare

    Usa gli esempi di installazione per configurare questo server nel tuo client MCP preferito.

  • Indicatori di interesse open source

    16 stelle e 3 fork nel repository collegato.

4get MCP Server

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

Codacy Badge Codacy Badge PyPI version PyPI Downloads

GitHub release GitHub Downloads

made-with-python Open Source Love

PayPal LiberaPay

✨ Features

  • 🔍 Multi Search Functions: Web, image, and news search with comprehensive result formatting
  • ⚡ Smart Caching: TTL-based response caching with configurable size limits
  • 🔄 Retry Logic: Exponential backoff for rate-limited and network errors
  • 🏗️ Production Ready: Connection pooling, comprehensive error handling, and validation
  • 📊 Rich Responses: Featured answers, related searches, pagination support, and more
  • 🧪 Well Tested: Extensive test suite including integration tests with real API, unit tests, and more
  • ⚙️ Highly Configurable: 11+ environment variables for fine-tuning
  • 🎯 Engine Shorthands: Pick a 4get scraper via the engine parameter without memorizing query strings

📋 Requirements

  • Python 3.13+
  • uv for dependency management

Quick Start

bash
# Install dependencies
uv sync

# Run the server
uv run -m mcp_4get

# Or use mise
mise run

⚙️ Configuration

The server is highly configurable via environment variables. All settings have sensible defaults for the public https://4get.ca instance.

Core Settings

VariableDescriptionDefault
FOURGET_BASE_URLBase URL for the 4get instancehttps://4get.ca
FOURGET_PASSOptional pass token for rate-limited instancesunset
FOURGET_USER_AGENTOverride User-Agent headermcp-4get/<version>
FOURGET_TIMEOUTRequest timeout in seconds20.0

Caching & Performance

VariableDescriptionDefault
FOURGET_CACHE_TTLCache lifetime in seconds600.0
FOURGET_CACHE_MAXSIZEMaximum cached responses128
FOURGET_CONNECTION_POOL_MAXSIZEMax concurrent connections10
FOURGET_CONNECTION_POOL_MAX_KEEPALIVEMax persistent connections5

Retry & Resilience

VariableDescriptionDefault
FOURGET_MAX_RETRIESMaximum retry attempts3
FOURGET_RETRY_BASE_DELAYBase retry delay in seconds1.0
FOURGET_RETRY_MAX_DELAYMaximum retry delay in seconds60.0

🚀 Running the Server

Local Development

bash
uv run -m mcp_4get

Production Deployment

bash
# With custom configuration
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

You can integrate the 4get MCP server with popular IDEs and AI assistants. Here are configuration examples:

Cursor IDE

Add this to your Cursor MCP configuration (~/.cursor/mcp.json):

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):

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

The server exposes three powerful search tools with comprehensive response formatting:

fourget_web_search

python
fourget_web_search(
    query: str,
    page_token: str = None,        # Use 'npt' from previous response
    extended_search: bool = False, # Enable extended search mode
    engine: str = None,             # Pick a scraper from the supported engine list
    extra_params: dict = None      # Language, region, etc.
)

Response includes: web[], answer[], spelling, related[], npt

fourget_image_search

python
fourget_image_search(
    query: str,
    page_token: str = None,   # Use 'npt' from previous response
    engine: str = None,       # Pick a scraper from the supported engine list
    extra_params: dict = None # Size, color, type filters
)

Response includes: image[], npt

fourget_news_search

python
fourget_news_search(
    query: str,
    page_token: str = None,   # Use 'npt' from previous response
    engine: str = None,       # Pick a scraper from the supported engine list
    extra_params: dict = None # Date range, source filters
)

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.

ValueEngine
ddgDuckDuckGo
braveBrave
mullvad_braveMullvad (Brave)
yandexYandex
googleGoogle
google_cseGoogle CSE
mullvad_googleMullvad (Google)
startpageStartpage
qwantQwant
ghosteryGhostery
yepYep
grepprGreppr
crowdviewCrowdview
mwmblMwmbl
mojeekMojeek
baiduBaidu
coccocCoc Coc
solofieldSolofield
marginaliaMarginalia
wibywiby
curlieCurlie

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):

python
# Get first page
result = await client.web_search("python programming")

# Get next page if available
if result.get('npt'):
    next_page = await client.web_search("ignored", page_token=result['npt'])

🐍 Using the Async Client Directly

You can reuse the bundled async client outside MCP for direct API access:

python
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 allows you to integrate 4get search capabilities directly into your Python applications without going through the MCP protocol.

🛡️ 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:

json
{
  "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"
}

Development

This project uses several tools to streamline the development process:

mise

mise is used for managing project-level dependencies and environment variables. mise helps ensure consistent development environments across different machines.

To get started with mise:

  1. Install mise by following the instructions on the official website.
  2. Run mise install in the project root to set up the development environment.

Environment Variable Overrides: You can override any environment variable by creating a .mise.local.toml file in the project root:

toml
[env]
FOURGET_BASE_URL = "https://your-custom-4get-instance.com"
FOURGET_CACHE_TTL = "300"
# Add any other environment variables you want to override

This file is automatically loaded by mise and allows you to customize your local development environment without modifying the shared configuration files.

UV

UV is used for dependency management and packaging. It provides a clean, version-controlled way to manage project dependencies.

To set up the project with UV:

  1. Install UV using mise, or by following the instructions on the official website.
  2. Run uv sync to install project dependencies.

MCP Server Integration for local development

Cursor IDE

Add this to your Cursor MCP configuration (~/.cursor/mcp.json):

json
{
  "mcpServers": {
    "4get": {
      "command": "uv",
      "args": [
        "run",
        "--project",
        "/path/to/your/mcp-4get",
        "-m",
        "src"
      ],
      "env": {
        "FOURGET_BASE_URL": "https://4get.ca"
      }
    }
  }
}

OpenAI Codex

Add this to your Codex MCP configuration (~/.codex/config.toml):

toml
[mcp_servers.4get]
command = "uv"
args = ["run", "--project", "/path/to/your/mcp-4get", "-m", "src"]
env = { FOURGET_BASE_URL = "https://4get.ca" }

Note: Replace /path/to/your/mcp-4get with the actual path to your project directory.

🧪 Testing

Comprehensive test suite with unit, integration, and performance tests:

bash
# Run all tests
uv run pytest

# Run only fast unit tests (exclude integration)
uv run pytest -m "not integration"

# Run integration tests with real 4get API
uv run pytest -m integration

# Run with coverage
uv run pytest --cov=src

# Run specific test categories
uv run pytest tests/test_cache.py      # Cache behavior tests
uv run pytest tests/test_client.py     # Client and retry logic tests
uv run pytest tests/test_integration.py # Real API integration tests

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

  1. Setup: See Development and Quick Start sections
  2. Tests: See Testing section
  3. Linting: uv run ruff check
  4. Format: uv run ruff format

📄 License

GPLv3 License - see LICENSE file for details.

Installazione

TypingMind
Prerequisiti:

Node.js 18+

{
  "mcpServers": {
    "4get": {
      "command": "uvx",
      "args": [
        "mcp_4get@latest"
      ],
      "env": {
        "FOURGET_BASE_URL": "https://4get.ca"
      }
    }
  }
}

Usa MCP 4get con più modelli IA

TypingMind collega gli strumenti MCP a livello di area di lavoro: una volta connesso 4get, puoi usarlo con diversi modelli IA in TypingMind, senza configurarlo separatamente per ogni modello. Questa integrazione MCP viene eseguita localmente sul tuo dispositivo tramite il connettore MCP di TypingMind.

Guida alla configurazione del connettore locale

Usa questo metodo quando il server MCP deve accedere a file locali, app o risorse private sul tuo computer.

1

Apri le impostazioni MCP

In TypingMind, vai su Impostazioni, Impostazioni avanzate, poi su Model Context Protocol e scegli Configura MCP.

  1. Apri TypingMind nel tuo browser.
  2. Fai clic sull'icona Impostazioni.
  3. Vai a Impostazioni avanzate.
  4. Apri la sezione Model Context Protocol.
  5. Fai clic su Configura MCP e scegli Questo dispositivo.
Schermata di configurazione del connettore MCP di TypingMind con Questo dispositivo selezionato
2

Esegui il comando del connettore

Scegli Questo dispositivo, copia il comando da TypingMind ed eseguilo nel terminale. Lascia il processo in esecuzione mentre usi MCP.

  1. Copia il comando di configurazione mostrato da TypingMind.
  2. Apri Terminale su macOS o Windows Terminal su Windows.
  3. Incolla ed esegui il comando.
  4. Conferma l'installazione del pacchetto se il terminale ti chiede di procedere.
  5. Tieni aperta la finestra del terminale con il processo in esecuzione mentre usi gli strumenti MCP.
3

Aggiungi 4get come server

Quando lo stato del connettore è Pronto, fai clic su Modifica server e incolla la configurazione del server MCP.

  1. Attendi che lo stato del connettore sia Pronto.
  2. Fai clic su Modifica server.
  3. Incolla la configurazione del server MCP di 4get.
  4. Salva l'elenco dei server.
  5. Aggiorna per verificare che il connettore sia ancora pronto.
Impostazioni MCP di TypingMind con un server attivo e il pulsante Modifica server
{
  "mcpServers": {
    "4get": {
      "command": "npx",
      "args": [
        "-y",
        "mcp-4get"
      ]
    }
  }
}
4

Usa la connessione con diversi modelli

Salva l'elenco dei server, apri Plugin, abilita gli strumenti MCP di 4get, poi seleziona un modello IA supportato in TypingMind e usa gli strumenti in chat o assegnali a un agente IA.

  1. Apri la pagina Plugin in TypingMind.
  2. Abilita gli strumenti MCP di 4get.
  3. Avvia una chat e scegli il modello IA che vuoi usare.
  4. Usa gli strumenti MCP in chat o assegnali a un agente IA.
  5. Passa a un altro modello IA quando serve, senza riconnettere MCP.
Chat di TypingMind che usa gli strumenti MCP abilitati con un modello IA selezionato
Puoi usare 4get per aiutarmi con questa attività?
4get
Certo. Ho letto.
Ecco cosa ho trovato con 4get.

Domande frequenti

A cosa serve il server MCP 4get?

4get è un server MCP che consente ai client IA compatibili di accedere a strumenti e informazioni di contesto esterni. In TypingMind puoi aggiungere questo server MCP una sola volta e rendere disponibili i suoi strumenti nella tua area di lavoro IA.

Posso usare 4get MCP con più modelli IA in TypingMind?

Sì. TypingMind collega gli strumenti MCP a livello di area di lavoro, quindi puoi usare 4get con diversi modelli IA come Claude, ChatGPT, Gemini o altri modelli che hai configurato in TypingMind, senza dover configurare il server MCP separatamente per ogni modello.

Perché usare il connettore MCP 4get con TypingMind?

TypingMind è una delle migliori interfacce per chattare con gli LLM perché riunisce più modelli IA, prompt, plugin, agenti IA, chiavi API e strumenti MCP in un'unica area di lavoro. Collegando 4get, puoi usare i suoi strumenti MCP con i tuoi modelli preferiti e mantenere organizzato il tuo flusso di lavoro in chat su TypingMind.

Come collego 4get MCP a TypingMind?

4get funziona tramite il connettore MCP locale di TypingMind. È la soluzione ideale quando il server MCP deve accedere a file locali, app desktop, strumenti da riga di comando o risorse private sul tuo computer.

Quali strumenti offre 4get MCP in TypingMind?

4get mette a disposizione funzionalità MCP che puoi attivare dalla pagina Plugin di TypingMind e usare in chat o assegnare agli agenti IA.

Devo condividere le mie chiavi API con TypingMind per usare 4get MCP?

No. TypingMind privilegia il funzionamento in locale e ti permette di mantenere il controllo su fornitori di modelli, chiavi API, prompt e configurazione MCP. Se 4get richiede l'autenticazione, aggiungi le intestazioni, le impostazioni OAuth o la configurazione locale necessarie per quel server MCP quando crei la connessione.

Server MCP correlati

Vedi tutti

Crea subito la tua area di lavoro IA

Iscriviti alla nostra newsletter per ricevere aggiornamenti sulle nuove funzionalità e sulle prossime iniziative a premi 👇