# belluxx/sharp-search architecture

> Architecture diagram of the GitHub repository belluxx/sharp-search, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-12-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/belluxx/sharp-search
- Repository: https://github.com/belluxx/sharp-search

## Overview

sharp-search is a lightweight MCP server exposing web search and page fetching. An MCP client invokes the server, which routes search requests to the in-container SearXNG instance and formats results, or delegates fetch requests to the page-fetching implementation. Fetching retrieves public pages, converts content to Markdown, and can retry blocked pages with alternate user agents; script-based bot challenges are evaluated offline in a restricted Deno sandbox. The README documents search-engine fan-out and merging. Some implementation details are unsampled, so only documented or excerpt-supported relationships are shown.

Main entry points: [`src/fetch.py`](https://github.com/Belluxx/sharp-search/blob/main/src/fetch.py) (Page retrieval), [`src/server.py`](https://github.com/Belluxx/sharp-search/blob/main/src/server.py) (MCP server), [`searxng/settings.yml`](https://github.com/Belluxx/sharp-search/blob/main/searxng/settings.yml) (SearXNG), [`challenge/challenge.mjs`](https://github.com/Belluxx/sharp-search/blob/main/challenge/challenge.mjs) (Script challenge runner)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_mcp["MCP Interface"]
  node_server["MCP server<br/>[server.py]"]
end

subgraph group_search["Web Search"]
  node_search_tool["Search tool<br/>[server.py]"]
  node_searxng["SearXNG<br/>[settings.yml]"]
  node_engines(("Search engines"))
  node_search_results["Search results<br/>[server.py]"]
end

subgraph group_fetch["Page Fetch"]
  node_fetch_tool["Fetch tool<br/>[server.py]"]
  node_page_fetcher["Page retrieval<br/>[fetch.py]"]
  node_websites(("Public websites"))
  node_markdown["Markdown page<br/>[fetch.py]"]
  node_fallbacks["User-agent retries<br/>[fetch.py]"]
end

subgraph group_challenge["Challenge Handling"]
  node_challenge_runner["Script challenge runner<br/>[challenge.mjs]"]
  node_sandbox["Deno sandbox"]
end

node_client(("MCP client"))

node_client -->|"calls MCP"| node_server
node_server -->|"dispatches"| node_search_tool
node_search_tool -->|"queries"| node_searxng
node_searxng -->|"queries and merges"| node_engines
node_search_tool -->|"formats"| node_search_results
node_server -->|"dispatches"| node_fetch_tool
node_fetch_tool -->|"delegates to"| node_page_fetcher
node_page_fetcher -->|"requests pages"| node_websites
node_page_fetcher -->|"converts to"| node_markdown
node_page_fetcher -->|"retries blocked pages"| node_fallbacks
node_page_fetcher -->|"runs scripts"| node_challenge_runner
node_challenge_runner -->|"executes inside"| node_sandbox

click node_server "https://github.com/Belluxx/sharp-search/blob/main/src/server.py"
click node_search_tool "https://github.com/Belluxx/sharp-search/blob/main/src/server.py"
click node_searxng "https://github.com/Belluxx/sharp-search/blob/main/searxng/settings.yml"
click node_search_results "https://github.com/Belluxx/sharp-search/blob/main/src/server.py"
click node_fetch_tool "https://github.com/Belluxx/sharp-search/blob/main/src/server.py"
click node_page_fetcher "https://github.com/Belluxx/sharp-search/blob/main/src/fetch.py"
click node_markdown "https://github.com/Belluxx/sharp-search/blob/main/src/fetch.py"
click node_fallbacks "https://github.com/Belluxx/sharp-search/blob/main/src/fetch.py"
click node_challenge_runner "https://github.com/Belluxx/sharp-search/blob/main/challenge/challenge.mjs"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_server,node_client toneBlue
class node_search_tool,node_searxng,node_engines,node_search_results toneAmber
class node_fetch_tool,node_page_fetcher,node_websites,node_markdown,node_fallbacks toneMint
class node_challenge_runner,node_sandbox toneRose
```

## Components

### MCP Interface

- [MCP server](https://github.com/Belluxx/sharp-search/blob/main/src/server.py): `src/server.py`

### Web Search

- [Search tool](https://github.com/Belluxx/sharp-search/blob/main/src/server.py): `src/server.py`
- [SearXNG](https://github.com/Belluxx/sharp-search/blob/main/searxng/settings.yml): `searxng/settings.yml`
- **Search engines**
- [Search results](https://github.com/Belluxx/sharp-search/blob/main/src/server.py): `src/server.py`

### Page Fetch

- [Fetch tool](https://github.com/Belluxx/sharp-search/blob/main/src/server.py): `src/server.py`
- [Page retrieval](https://github.com/Belluxx/sharp-search/blob/main/src/fetch.py): `src/fetch.py`
- **Public websites**
- [Markdown page](https://github.com/Belluxx/sharp-search/blob/main/src/fetch.py): `src/fetch.py`
- [User-agent retries](https://github.com/Belluxx/sharp-search/blob/main/src/fetch.py): `src/fetch.py`

### Challenge Handling

- [Script challenge runner](https://github.com/Belluxx/sharp-search/blob/main/challenge/challenge.mjs): `challenge/challenge.mjs`
- **Deno sandbox**

### Other components

- **MCP client**

## Connections

- MCP client → MCP server: calls MCP (evidence: `README.md`)
- MCP server → Search tool: dispatches (evidence: `src/server.py`)
- Search tool → SearXNG: queries (evidence: `src/server.py`)
- SearXNG → Search engines: queries and merges (evidence: `README.md`)
- Search tool → Search results: formats (evidence: `src/server.py`)
- MCP server → Fetch tool: dispatches (evidence: `src/server.py`)
- Fetch tool → Page retrieval: delegates to (evidence: `src/server.py`)
- Page retrieval → Public websites: requests pages (evidence: `src/fetch.py`)
- Page retrieval → Markdown page: converts to (evidence: `src/fetch.py`)
- Page retrieval → User-agent retries: retries blocked pages (evidence: `README.md`)
- Page retrieval → Script challenge runner: runs scripts (evidence: `src/fetch.py`)
- Script challenge runner → Deno sandbox: executes inside (evidence: `challenge/challenge.mjs`)
