Open-WebSearch

repository·main·Indexed 23 days ago

https://github.com/aas-ee/open-websearch

A versatile toolset for web search and content extraction available as an MCP server, CLI, and local HTTP daemon. It supports multi-engine search (including Bing, DuckDuckGo, Exa, and Brave) and content retrieval from GitHub, CSDN, Juejin, and general web pages without requiring API keys. Version 2.1.11 features structured JSON output, Playwright integration for browser-enhanced search, and deployment options via Docker.

Tokens
19.3K
Snippets
53
Records
113
Agent score
82%

What's inside open-websearch

  1. Overview of Open-WebSearch

    main

    Open-WebSearch is a tool for web searching and content scraping that does not require API keys. It provides multiple entry points depending on your use case:

    • MCP Server: Best for integration with MCP clients like Claude Desktop, Cherry Studio, or Cursor.
    • CLI: Best for one-off local commands, shell scripts, and terminal usage.
    • Local Daemon: A persistent local HTTP service for reusable access. It provides endpoints for status, GET /health, POST /search, and POST /fetch-*.
    • Skill: An agent-guidance layer used to help agents discover, enable, and use the tool within an agentic workflow.
  2. Overview of Open-WebSearch capabilities

    main

    Open-WebSearch provides a multi-engine web search and content retrieval system that does not require API keys or authentication. It can be used as an MCP server, a CLI tool, or a long-lived local daemon.

    Key Features:

    • Multi-engine search: Supports engines like bing, baidu, csdn, duckduckgo, exa, brave, juejin, startpage, and sogou.
    • Content retrieval: Fetches individual article content from csdn, github (README files), or generic HTTP(S) pages/Markdown content.
    • Structured results: Returns titles, URLs, and descriptions.
    • Configurability: Supports HTTP proxy configuration, customizable default search engines, and configurable result counts.

    Usage Paths:

    • MCP: Connect to clients like Claude Desktop, Cherry Studio, or Cursor.
    • CLI: For one-shot local commands and shell scripts.
    • Local Daemon: A long-lived HTTP service exposing status, GET /health, POST /search, and POST /fetch-* endpoints.
    • Skill: An agent-facing guidance layer that helps agents discover and activate the best path (MCP, CLI, or Daemon).
  3. Use the canonical error model

    main

    To ensure consistency across MCP, CLI, and local HTTP adapters, all services should use a shared error shape. A canonical error must include the following fields:

    • code: Error identifier.
    • message: Human-readable error message.
    • retryable: Boolean indicating if the operation can be retried.
    • hint: Guidance for the user.
    • details: Additional context or error data.
  4. Understand the Open-WebSearch architecture layers

    main

    Open-WebSearch is organized into three distinct layers to separate business logic from transport protocols:

    1. Core: Contains transport-agnostic business capabilities. It handles search dispatch, engine normalization, limit distribution, URL validation, and canonical result/error shaping. It must remain unaware of MCP, Express, CLI, or session handling.
    2. Shared Runtime / Service Container: Manages stateful and reusable services. It is responsible for configuration loading/caching, HTTP client setup, browser (Playwright) lifecycles, cookie/session helpers, and health/readiness state. This layer wires together config, engine services, and fetch services.
    3. Adapters: Translates protocol-specific input/output to core calls. Planned adapters include MCP, local HTTP, and CLI. Adapters are responsible for parsing transport-specific arguments and formatting responses, but they should not contain business logic or custom search dispatch.
  5. Understand the Open WebSearch architecture

    main

    Open WebSearch is designed as a multi-interface product that provides web search, fetching, and validation capabilities through three primary access patterns:

    1. MCP Adapter: Provides Model Context Protocol (MCP) compatibility via stdio or http for use with MCP clients.
    2. Local HTTP Adapter: A localhost service that allows for low-latency, frequent calls by reusing browser/runtime state.
    3. CLI Control: A command-line interface for direct interaction, orchestration, and service management.

    All interfaces share a single Core API (handling search, fetch, and validate) and a Shared Runtime (managing configuration, state, cache, and the browser lifecycle). This architecture ensures that business logic remains centralized in the core while transport adapters (MCP and HTTP) handle the communication layer.

    +----------------------+
                    |   Core APIs          |
                    | search/fetch/validate|
                    +----------+-----------+
                               |
                    +----------v-----------+
                    | Shared Runtime /     |
                    | Service Container    |
                    | config/state/cache   |
                    | browser lifecycle    |
                    +-----+-----------+----+
                          |           |
              +-----------v--+     +--v----------------+
              | MCP Adapter  |     | Local HTTP Adapter|
              | stdio/http   |     | localhost service |
              +-----------+--+     +--+----------------+
                          |           |
                      MCP clients     | localhost HTTP
                                      |
                             +--------v--------+
                             | CLI Control     |
                             | search/fetch/...|
                             | serve/status    |
                             +--------+--------+
                                      |
                        skill prefers CLI/daemon, keeps MCP compatibility
  6. Understand the Local HTTP Adapter architecture

    main

    The Local HTTP Adapter provides a localhost-based HTTP interface for the open-websearch daemon. It is designed for local automation, debugging, and probing from CLI or skill flows.

    Key architectural principles:

    • Runtime Model: The adapter sits on top of the same shared runtime used by the MCP (Model Context Protocol) adapter. A single runtime container supports two protocol 'front doors': MCP and local HTTP.
    • Binding Model: By default, the adapter binds to 127.0.0.1 on a configurable port. It is intended for local use only and not for public exposure.
    • Response Model: All routes use a consistent JSON envelope containing status, data, error, and hint fields, ensuring compatibility between the HTTP API and the CLI.
  7. Understand the open-websearch retrieval workflow

    main

    The open-websearch skill follows a specific hierarchy of decision rules to provide information efficiently:

    1. Direct URL Fetch: If a specific public URL is provided, fetch it directly instead of searching.
    2. Focused Search: For current information, discovery, or comparisons, start with a single focused search.
    3. Deep Reading: If a search snippet is insufficient, use fetchWebContent on the promising URL.
    4. Repository Retrieval: If the target is a GitHub repository, use fetchGithubReadme instead of generic page fetching.

    Engine Selection Heuristics:

    • General English: Prefers startpage.
    • Broad Web: Uses bing as a secondary option.
    • Chinese-language/China-hosted: Uses baidu, csdn, or juejin.
    • Multi-engine: Only used for cross-checking when a single pass is insufficient.
  8. Understand the open-websearch HTTP response envelope

    main

    All API responses follow a consistent envelope structure.

    Success Response:

    {
      "status": "ok",
      "data": { ... },
      "error": null,
      "hint": null
    }

    Error Response:

    {
      "status": "error",
      "data": null,
      "error": {
        "code": "error_code",
        "message": "Human readable error"
      },
      "hint": "Suggestion for resolution"
    }
  9. Supported Search Engines and Content Extraction

    main

    Open-WebSearch supports searching across multiple engines and extracting content from specific sources:

    Search Engines:

    • bing
    • baidu
    • csdn
    • duckduckgo
    • exa
    • brave
    • juejin
    • startpage
    • sogou

    Content Extraction (Fetch):

    • csdn: Extracts full text from CSDN blog posts.
    • github: Extracts README files.
    • General: Supports general HTTP(S) web pages and Markdown content extraction.
  10. Integrate with the Open-WebSearch CLI JSON Protocol

    main

    When building skills, plugins, or automated integrations, use the --json flag to ensure you receive machine-readable, stable output. Do not rely on the default human-readable format for programmatic consumption.

    Output Envelope

    All JSON responses follow a common envelope structure:

    Success Envelope:

    {
      "status": "ok",
      "data": { ... },
      "error": null,
      "hint": null
    }

    Error Envelope:

    {
      "status": "error",
      "data": null,
      "error": {
        "code": "string",
        "message": "string",
        "retryable": boolean,
        "details": {}
      },
      "hint": "string"
    }

    Exit Codes

    • 0: Command succeeded.
    • 1: Command failed with a structured error or validation failure.
    • 130: Shell-level interruption (e.g., SIGINT).

    Note: open-websearch serve exits with 0 only after a clean shutdown via SIGINT or SIGTERM.

  11. Start and check the open-websearch local daemon

    main

    The open-websearch daemon provides a local HTTP API for scripts, tooling, and plugin integrations. By default, it binds to 127.0.0.1 and is not accessible from the public internet.

    To start the daemon using the default configuration:

    npm run serve

    To start the daemon on a specific port:

    node build/index.js serve --port 3211

    To check the daemon status via the CLI:

    npm run status -- --json
    # Or specify a custom base URL:
    npm run status -- --base-url http://127.0.0.1:3211 --json

    Note: When calling localhost directly via curl, you may need to bypass shell proxy settings using the --noproxy '*' flag.