Skip to main content
Glama
Aster Search MCP
by yustein
README.md
# Aster Search MCP

Self-hosted web search and AI-readable content extraction, with Amazon book and
author intelligence. **Version 0.2.0 adds experimental dynamic rendering and bounded catalogue traversal.**

Aster Search brings general web retrieval and specialist workflows into one MCP
server. The public core is MIT-licensed and runs without an Aster-hosted account.
Direct page reads and offline analysis require no paid API key. Search uses your
own SearXNG instance or Brave Search API credentials.

## What works in this version

- Live, bounded HTTP page retrieval with Markdown/text output inside a JSON
  evidence envelope: source/final URL, timestamp, content hash and truncation.
- Batch retrieval of up to ten URLs with three concurrent requests.
- Optional Chromium rendering in a fresh worker process, with bounded scrolling,
  request controls and explicit partial-result reporting. Disabled by default.
- Search-provider adapters for SearXNG and Brave, with domain filtering and
  deduplication. Search results explicitly remain unverified indexed snippets.
- Amazon product metadata parsing: observed titles, descriptions, authors,
  editions, ASINs, valid ISBNs, formats, covers, offers, ratings and visible review
  metadata. Fields that cannot be observed remain unknown.
- Discovery of product and pagination links present in an Amazon author page's
  loaded HTML, with explicit incomplete-catalogue status.
- Bounded traversal of observed same-author pagination, optional listing metadata
  and format-link discovery, and comparison with an operator-supplied ASIN baseline.
  Discovered candidates and confirmed author matches remain separate.
- ISBN-10/13 checksum validation and transparent comparisons by rating count,
  written review count, highest displayed rating or comparable sales rank.
- MCP over stdio or authenticated stateless Streamable HTTP, plus a small CLI.

**Not implemented yet:** verified exhaustive author coverage, complete work/edition
reconciliation, global availability verification, historical
storage, monitoring, private KDP reports, WordPress integration and commercial
skill packages. See the [roadmap](docs/ROADMAP.md).

The server does not guarantee access to every website. It returns explicit block
and failure states and does not solve CAPTCHAs or bypass login/paywall controls.
Being able to read a page does not prove that a book is buyable in a visitor's country.

## Quick start

Requires Python 3.11 or newer. No GPU is required.

```bash
git clone https://github.com/yustein/aster-search-mcp.git
cd aster-search-mcp
python3 -m venv .venv
.venv/bin/python -m pip install -e .
.venv/bin/aster-search fetch https://example.com
.venv/bin/aster-search serve
```

On Windows, use `.venv\Scripts\python.exe` and `.venv\Scripts\aster-search.exe`.
The default server transport is stdio. Diagnostic messages use stderr; stdout is
reserved for MCP messages. With `uv`, use `uv sync --frozen` and
`uv run --frozen aster-search serve` for the committed dependency set.

### Connect a local MCP client

Set the executable to the absolute path in your checkout:

```json
{
  "mcpServers": {
    "aster-search": {
      "command": "/absolute/path/aster-search-mcp/.venv/bin/aster-search",
      "args": ["serve"]
    }
  }
}
```

Supply provider variables through your client's environment configuration. Do
not put real keys in shared configuration or commit them to Git.

### Configure web search

Choose one or both adapters. `auto` prefers configured SearXNG, then Brave. It
does not automatically retry another paid provider after an error.

```bash
export ASTER_SEARCH_SEARXNG_URL=http://127.0.0.1:8080
export ASTER_SEARCH_TRUSTED_SEARCH_ORIGINS=http://127.0.0.1:8080
.venv/bin/aster-search search 'author bibliography' --site amazon.com
```

Enable JSON responses in your SearXNG `settings.yml`:

```yaml
search:
  formats:
    - html
    - json
```

Alternatively set `ASTER_SEARCH_BRAVE_API_KEY` to your own key and select
`--provider brave`. Costs and terms come from your provider. An unconfigured
server returns `not_configured`, never fabricated results. The trusted-origins
setting applies only to your configured search service; it never opens private
network access through `fetch_page`.

### Dynamic rendering and author traversal

The browser is an optional dependency. Install it only where a sandboxed Chromium
runtime is available, then explicitly enable the worker for the intended process:

```bash
uv sync --frozen --extra browser
uv run --frozen playwright install chromium
export ASTER_SEARCH_BROWSER_ENABLED=1
uv run --frozen aster-search render https://example.com --max-scrolls 4
```

An existing Chromium/Google Chrome installation can be selected with the
operator-only `ASTER_SEARCH_BROWSER_EXECUTABLE` environment variable. Its absolute
executable path is never an MCP argument. The worker retains the Chromium sandbox;
an unavailable runtime or unsupported sandbox returns a structured error.

To inspect the author catalogue used for this project's first use case:

```bash
uv run --frozen aster-search catalogue \
  https://www.amazon.com/stores/-/author/B07FB92Z7T \
  --mode browser --max-pages 5 --max-books 100 --metadata
```

Use repeated `--expected-asin` arguments to compare against a known reference list.
The report distinguishes observed candidates, author attribution, page failures,
remaining pagination and reference coverage. Even 100% coverage of that reference
does not establish that every published book or edition has been found.

Browser reads use bounded GET requests and do not import login cookies or execute
arbitrary user-provided scripts. Sites requiring unsupported requests, interactive
controls, sign-in or CAPTCHA can remain partial or blocked. There is no automatic
retry through another access route after a denial. See
[browser and catalogue operation](docs/BROWSER_AND_CATALOGUE.md).

### HTTP transport

Generate a dedicated random token and keep it in your shell or secret manager:

```bash
export ASTER_SEARCH_API_KEY="$(python3 -c 'import secrets; print(secrets.token_urlsafe(32))')"
.venv/bin/aster-search serve --transport streamable-http --port 8787
```

The endpoint is `http://127.0.0.1:8787/mcp`. Send
`Authorization: Bearer <your-token>`. All HTTP requests require the token, even
on localhost. Tokens shorter than 32 bytes are rejected. This is a bearer-token
transport for compatible clients; native OAuth app enrollment is a separate
integration and is not supplied by this version.

For remote hosting, put TLS, appropriate authentication and request limits in
front of the service. Set `ASTER_SEARCH_ALLOWED_HOSTS` and
`ASTER_SEARCH_ALLOWED_ORIGINS` to explicit comma-separated values for the intended
hostname/origin; never use `*`. Use `--host 0.0.0.0` only behind your intended
network controls. No hosted public endpoint is provided by this repository.

### Container

```bash
docker build -t aster-search-mcp .
docker run --rm -i aster-search-mcp
```

The image runs as a non-root user. To use HTTP, pass the token via an environment
variable and publish only on the host loopback interface:

```bash
docker run --rm --read-only --tmpfs /tmp -p 127.0.0.1:8787:8787 \
  -e ASTER_SEARCH_API_KEY aster-search-mcp \
  serve --transport streamable-http --host 0.0.0.0 --port 8787
```

This base image supplies native HTTP retrieval; it does not install Chromium or
enable the experimental browser worker.

## MCP tools

| Tool | Behavior |
| --- | --- |
| `capabilities` | Report version and configured features without exposing secrets. |
| `search_web` | Search an operator-configured provider. |
| `fetch_page` | Read one public page as Markdown/text with provenance. |
| `render_page` | Render JavaScript content with an explicitly enabled browser worker. |
| `fetch_batch` | Read up to ten pages with individual result states. |
| `extract_content` | Parse supplied HTML without making a network request. |
| `get_book_metadata` | Fetch and parse one Amazon listing using HTTP or browser mode. |
| `discover_author_books` | Extract product links from one loaded Amazon page using either mode. |
| `crawl_author_catalogue` | Traverse observed author pages with budgets, attribution and reference coverage. |
| `parse_book_metadata` | Parse supplied Amazon HTML; provenance is unverified. |
| `verify_isbn` | Validate and normalize an ISBN; does not establish book identity. |
| `rank_author_books` | Rank supplied observations by an explicit metric. |

## Answering “Which is the most popular book?”

The default comparison is **most rated among the supplied observations in one
marketplace**. It is not a claim about verified sales or an author's full catalogue.
The ranking tool returns its metric, eligible and excluded records, ties, source
links and limitations. Shared review groups and editions are not summed.

`highest_rated` requires a minimum sample of ratings (default ten). `sales_rank`
requires one category and format, observations no more than 24 hours apart, and
reports that lower rank is better. It does not convert ranks to sales quantities.
Private sales, Kindle Unlimited pages, website visits and downloads are future
optional inputs that must remain distinct measurements.

## Evidence and access boundaries

Native HTTP reads have a 30-second total deadline, five-redirect limit and 2 MB
wire/decompressed body limits. Fetch targets must use HTTP(S) on ports 80/443 and
resolve to public IP addresses. Connections pin validated IPs and preserve the
original TLS hostname; redirects are validated separately. Ambient proxy settings,
browser cookies and arbitrary caller headers are not used.

The response is untrusted source content. It cannot instruct the caller to reveal
secrets or take actions. API keys are only sent to their configured provider.
See [SECURITY.md](SECURITY.md) for deployment boundaries and known limitations.

Use material you are authorized to retrieve and reuse. Original publisher copy,
retailer descriptions and user reviews have different provenance and reuse
conditions. The public repository contains synthetic fixtures, not a harvested
review database or private publishing records.

## Development

```bash
uv sync --frozen --extra dev
uv run --frozen python scripts/verify.py
```

The default test suite is offline. It exercises request boundaries, redirects,
decompression limits, parser ambiguity, unknown values, review deduplication,
rank comparability and the actual MCP interface. Live site access is a separate
check and is not implied by fixture tests.

Verification runs directly on the developer's or operator's own machine.
This project does not use GitHub Actions. The CLI uses exit code 0 for an `ok`
result, 2 for a `partial` result and 1 for a retrieval/configuration failure;
always inspect the returned coverage and warnings as well as the exit code.

- [Product specification](docs/PRODUCT_SPEC.md)
- [Decisions and assumptions](docs/DECISIONS.md)
- [Data model](docs/DATA_MODEL.md)
- [Roadmap and acceptance gates](docs/ROADMAP.md)
- [Development status](docs/DEVELOPMENT_STATUS.md)