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

Self-hosted web retrieval, rendering and AI-readable evidence extraction, with
Amazon book and author intelligence. **Version 0.3.0 is a development release with experimental
dynamic rendering, bounded author expansion, durable inventory and store suggestions.**

Aster Fetch reads public web sources, extracts structured data and records source
provenance through MCP. The public core is MIT-licensed and runs without an Aster-hosted account.
Direct page reads and offline analysis require no paid API key. Give Aster a source
URL directly, or use the optional SearXNG, Brave or Keenable adapter to find one.

## 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.
- Two operator-selected browser transports: a validated HTTP bridge, and native
  Chromium HTTPS through a DNS-pinned CONNECT proxy. The native author profile
  follows the observed All Books link and expands the fixed catalogue control.
- Search-provider adapters for SearXNG, Brave and Keenable, 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.
- Capture of structured author cards and whitelisted public embedded state, with
  separate provenance for rendered links, published links and embedded identifiers.
- Durable local inventory: immutable observations, explicit work relationships,
  field provenance, conflicts, atomic checkpoints, JSON/CSV export and resumable
  metadata enrichment. These filesystem operations are CLI-only.
- Pure bookstore suggestions from supplied listing evidence, country and format
  preferences, with visible stale/unknown choices and no automatic redirect.
- 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:** independently verified exhaustive author coverage,
automatic cross-marketplace edition matching or global availability checks,
geolocation, a website store-selector widget, complete review retrieval or sentiment
analysis, scheduled monitoring, private KDP reports and commercial skill packages.
Local observation history is implemented; a hosted history/trend service is not.
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-fetch.git
cd aster-fetch
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-fetch/.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

To run general search independently of Keenable, configure a private SearXNG instance.
The [example settings](docs/searxng-settings.example.yml) query FreeSerp's web index,
Wiby, and the English and Turkish Wikipedia search APIs. Queries go to those upstreams.
Configure a unique `SEARXNG_SECRET` in the SearXNG service environment, keep the
listener private, and configure its exact URL in Aster. The sample uses port 8888.
Follow the [SearXNG installation guide](https://docs.searxng.org/admin/installation.html)
for your deployment method.

For a standalone check in the same environment as the installed CLI:

```sh
export ASTER_SEARCH_SEARXNG_URL=http://127.0.0.1:8888
export ASTER_SEARCH_TRUSTED_SEARCH_ORIGINS=http://127.0.0.1:8888
export ASTER_SEARCH_DEFAULT_PROVIDER=searxng
export ASTER_SEARCH_KEENABLE_ENABLED=0
aster-search search "Which RFC specifies HTTP semantics?"
```

Check each candidate's `upstream_engines`, follow a returned URL with `fetch_page`,
and verify the claim against the retrieved source. Preserve Wiby's attribution link
when displaying its results. A failed upstream is reported in `unresponsive_engines`;
an empty result set with an upstream failure is reported as incomplete.


Alternatively set `ASTER_SEARCH_BRAVE_API_KEY` to your own key and select
`--provider brave`. Set `ASTER_SEARCH_KEENABLE_ENABLED=1` to enable the free
Keenable public API with `--provider keenable`. This sends search queries to
Keenable with the application name `Aster Fetch`. Its documented keyless limit
is 1,000 requests per hour and 10 per second per endpoint and public IP.
Results carry the source URL, provider-reported publication and acquisition times
where available, and the time Aster ran the search. Fetch the source to verify
current page content. See the [Keenable keyless API guide](https://docs.keenable.ai/guides/keyless-access).

With no provider pins, `auto` chooses configured SearXNG, Brave, then Keenable.
Pin general discovery with `ASTER_SEARCH_DEFAULT_PROVIDER=searxng`. Operators can
also set `ASTER_SEARCH_AMAZON_PROVIDER=keenable` and enable Keenable for Amazon
marketplace requests. Set `site` to a supported store such as `amazon.com.tr` to
restrict the results. Use `intent=amazon_marketplace` (CLI `--intent amazon_marketplace`)
for shopping, author storefronts or monitoring when the query or site does not
identify the marketplace. Use `intent=general` for ambiguous topics such as the
Amazon river. An explicit provider overrides the pin for comparisons. An
unavailable pin returns `not_configured` and the request does not try a different
provider on failure. `ASTER_SEARCH_KEENABLE_ENABLED=0` prevents even explicit
Keenable searches. The trusted origin is available only to the configured search
adapter. Page retrieval continues to enforce its public-destination checks.

### Dynamic rendering and author traversal

The browser is an optional Linux-only component. Install it where a sandboxed
Chromium runtime is available, then explicitly enable 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.

The default `bridge` transport fetches content through the validated Python HTTP
reader. Native transport uses Chromium's normal HTTPS stack and fresh ephemeral
cookies through the bounded public-destination proxy. Choose it explicitly for
the Amazon author interaction profile; no tool argument can change transport.

```bash
export ASTER_SEARCH_BROWSER_TRANSPORT=native
# Set AUTHOR_URL to the actual public author storefront URL you want to read.
uv run --frozen aster-search render "$AUTHOR_URL" \
  --profile amazon_author --wait-ms 5000 --timeout 900 \
  --max-actions 40 --max-chars 100000 > author-result.json
```

The profile preserves cumulative product cards even if earlier cards disappear
from the final DOM. It selects only an observed same-author All Books link and a
unique, exact catalogue Show more/Load more control. It may issue the page's fixed
public catalogue-read POST; arbitrary POSTs remain blocked. Explicit denials stop
further catalogue reads. The result also captures a safe subset of the page's
public embedded catalogue state, without raw session data.

For bounded catalogue traversal and optional per-listing metadata, browser mode
defaults to 900 seconds and accepts up to 1,200 seconds:

```bash
uv run --frozen aster-search catalogue \
  "$AUTHOR_URL" --mode browser --max-pages 5 --max-books 100 \
  --timeout 900 --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 do not import login cookies or execute caller-provided scripts.
Unsupported controls, requests, sign-in or CAPTCHA can leave a result partial or
blocked. There is no automatic transport switch after a denial. Wire-byte limits
are not a bound on decompressed renderer memory: this experimental component is
for operator-controlled single-user deployment, with external resource controls
required for hostile workloads. See
[browser and catalogue operation](docs/BROWSER_AND_CATALOGUE.md).

### Save, resume and export a catalogue

Keep generated data outside the source checkout. Import a saved author result or
your own JSON observation array into a trusted local checkpoint:

```bash
uv run --frozen aster-search inventory import /absolute/data/catalogue.json \
  --input author-result.json --kind author-result
uv run --frozen aster-search enrich /absolute/data/catalogue.json \
  --mode browser --max-items 10 --timeout 180
uv run --frozen aster-search inventory export /absolute/data/catalogue.json \
  --export-directory /absolute/data/export
```

Pass `--author-id` to enrichment when product bylines must be checked against a
known author identifier. Each accepted metadata observation is committed before
continuing. The attempt journal makes subsequent runs resume without repeating
successful, failed, denied or interrupted listings; `--refresh` explicitly makes
prior attempts eligible again. An access denial or HTTP 429 stops the batch.

Checkpoints retain prior evidence when a later field is missing or a page fails.
Ratings and visible review sets remain whole observations, never summed across
editions. Exports include the inventory JSON, listing/work/observation CSV files
and a manifest of file hashes. A supplied baseline measures reference coverage;
it cannot certify an entire bibliography. See the
[inventory workflow and schemas](docs/INVENTORY.md).

### Save project source observations

On POSIX, provision a dedicated service account and a directory under its control
for each client/project trust boundary. A typical deployment sets up the directory
and starts the MCP process under that account:

```bash
install -d -m 0700 /absolute/private/project-observations
export ASTER_SEARCH_OBSERVATION_DIR=/absolute/private/project-observations
.venv/bin/aster-search serve
```

This enables three tools and sets `capabilities().project_observations` to true.
The service owns the SQLite file. Every caller authorized for that instance can
access observations in its store. For HTTP, protect the backend with the dedicated
token and restrict access at the gateway. Grant write access only to principals
authorized to save and delete evidence for the project. For separate principals
or projects with independent access policies, run separate service instances
with separate credentials and directories.

Call `save_source_observation` with a new UUID, an HTTP(S) source URL, an ISO 8601
observation time including its timezone, and a note of up to 4096 characters.
Save the returned revision. A replay with the same UUID and contents returns the
existing revision. Different contents with that UUID return `conflict`. A store
holds up to 4096 observations. A full store returns `limit_reached`.
`get_source_observation` returns the submitted citation, note, UTC observation
time, service save time, and `caller_supplied_unverified` provenance. These tools
perform no network requests. Treat the note as untrusted source text. Record public
evidence only and keep private records, credentials, and signed URLs out of notes.
`delete_source_observation` requires the observation UUID and its exact revision.
A successful deletion returns `deleted: true`, and a later read returns `not_found`.

### 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

The server exposes fourteen tools by default. Enabling project observation storage
adds three tools for a total of seventeen. Inventory files and enrichment jobs are
local CLI operations.

| Tool | Behavior |
| --- | --- |
| `save_source_observation` (optional) | Persist one public source note under a caller-supplied UUID. |
| `get_source_observation` (optional) | Read one note and its provenance from the configured project. |
| `delete_source_observation` (optional) | Remove one note by UUID and matching revision. |
| `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. |
| `reconcile_book_records` | Reconcile up to 500 supplied observations into listing/work projections without fetching or writing files. |
| `recommend_bookstores` | Suggest from up to 500 supplied listing observations, keeping country/format choices and freshness labels explicit. |

`recommend_bookstores` accepts evidence; it does not fetch or geolocate. Callers
must supply listings known to represent the intended book. A published href can
remain an unverified option, while a suggestion needs fresh product-page/API
existence evidence. Unknown stock is labelled unknown; checkout and delivery are
never guaranteed. See [store recommendation inputs](docs/INVENTORY.md#store-recommendation-inputs).

## 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. JSON-producing CLI operations use exit
code 0 for `ok`, 2 for `partial`, and 1 for other result states. Argument-parsing
errors may also exit with code 2 and a diagnostic instead of JSON. Always inspect
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)
- [Inventory, enrichment and store suggestions](docs/INVENTORY.md)
- [Roadmap and acceptance gates](docs/ROADMAP.md)
- [Development status](docs/DEVELOPMENT_STATUS.md)

TDQS

B3.4/5.0

Scored across 14 tools

Disambiguation4/5

Most tools map to distinct actions or resources, such as fetching versus rendering versus batch fetching. However, parse_book_metadata and extract_content both parse caller-supplied HTML, and parse_book_metadata can be confused with get_book_metadata's fetch-and-parse role; descriptions help but the boundaries are not perfect.

Naming Consistency4/5

All tool names use snake_case and nearly all follow a verb_noun pattern, e.g. discover_author_books, fetch_batch, reconcile_book_records. The lone noun-only name, capabilities, is a minor deviation from the otherwise consistent convention.

Tool Count5/5

14 tools fit comfortably within the expected 3-15 range for a multi-step search, crawl, parse, verify, rank, and recommend workflow. Each tool covers a specific workflow phase without extreme bloat.

Completeness4/5

The surface covers discovery, fetching, parsing, ISBN verification, ranking, reconciliation, store recommendation, and capability reporting. Minor gaps remain around direct title/author book search and richer price or review comparison, but agents can work around them with search_web and get_book_metadata.

Maintenance

ActivityMaintained
ResponsivenessNo recent community issues