Metadata-Version: 2.5
Name: skyhound
Version: 0.1.0
Summary: Retrieve astronomical data from telescope archives: a Python library, CLI and MCP server for AI agents.
Project-URL: Homepage, https://github.com/Aureusa/skyhound
Project-URL: Issues, https://github.com/Aureusa/skyhound/issues
Author: skyhound contributors
License-Expression: BSD-3-Clause
License-File: LICENSE
Keywords: archives,astronomy,astroquery,cutouts,euclid,gaia,hst,jwst,mast,mcp,psf
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Science/Research
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Scientific/Engineering :: Astronomy
Requires-Python: >=3.11
Requires-Dist: astropy>=6.0
Requires-Dist: astroquery>=0.4.10
Requires-Dist: mcp<3,>=2.3
Requires-Dist: mocpy>=0.17
Requires-Dist: numpy>=1.26
Requires-Dist: pandas>=2.1
Requires-Dist: photutils>=2.0
Requires-Dist: pillow>=10
Requires-Dist: pyarrow>=15
Requires-Dist: pyvo>=1.5
Requires-Dist: requests>=2.28
Requires-Dist: scipy>=1.11
Provides-Extra: dev
Requires-Dist: matplotlib>=3.8; extra == 'dev'
Requires-Dist: mypy>=1.10; extra == 'dev'
Requires-Dist: pytest-recording>=0.13; extra == 'dev'
Requires-Dist: pytest>=8.0; extra == 'dev'
Requires-Dist: ruff>=0.6; extra == 'dev'
Provides-Extra: notebooks
Requires-Dist: ipykernel>=6; extra == 'notebooks'
Requires-Dist: matplotlib>=3.8; extra == 'notebooks'
Requires-Dist: nbconvert>=7; extra == 'notebooks'
Description-Content-Type: text/markdown

# skyhound

<img src="https://raw.githubusercontent.com/Aureusa/skyhound/main/docs/logo/skyhound-logo.svg" alt="skyhound logo" width="96" align="right">

An open-source toolbox that lets Claude and other MCP-capable agents retrieve
astronomical data from telescope archives (Euclid, Gaia, MAST, HiPS cutouts, SIMBAD, …).

> **Status: alpha (0.1).** The library, CLI, MCP server and skills work and are tested;
> interfaces may still change. See [TODO.md](TODO.md) for the roadmap.

## Install

Pick one. All three use the same package from PyPI; the plugin and `claude mcp add` routes
need [uv](https://docs.astral.sh/uv/) (`uvx` fetches and runs the server for you).

**1. Claude Code plugin** (MCP server and skills):

```
/plugin install skyhound --marketplace Aureusa/skyhound
```

or in two steps: `/plugin marketplace add Aureusa/skyhound`, then
`/plugin install skyhound@skyhound`. Skills then appear as `skyhound:<skill>`.

**2. MCP server only** (any project, no skills):

```bash
claude mcp add skyhound -- uvx --from skyhound skyhound-mcp
```

**3. Python library and CLI** (no AI needed):

```bash
pip install skyhound
skyhound --version
```

Results go to `./skyhound-data` unless `SKYHOUND_OUTPUT` is set. On an HPC cluster, set
`SKYHOUND_LAUNCHER=slurm` and `SKYHOUND_SLURM_ARGS="-p <partition> -t 02:00:00"` so that
background jobs (batch cutouts, PSF batches) run through Slurm, not on the login node.

### Other MCP clients

The server speaks MCP over stdio, so any MCP client can use it. For **Claude Desktop**,
add to `claude_desktop_config.json`; for **Cursor**, to `.cursor/mcp.json` (same shape):

```json
{
  "mcpServers": {
    "skyhound": {
      "command": "uvx",
      "args": ["--from", "skyhound", "skyhound-mcp"],
      "env": { "SKYHOUND_OUTPUT": "/path/to/skyhound-data" }
    }
  }
}
```

Set `SKYHOUND_OUTPUT` there: desktop apps start the server in a directory you may not
expect. Without uv, `pip install skyhound` and use `"command": "skyhound-mcp"`.

## Does it help?

![Graded scores per task: plain Claude Code vs Claude Code with skyhound](https://raw.githubusercontent.com/Aureusa/skyhound/main/docs/figures/eval-v0.1-scores.png)

We gave Claude Code (Sonnet 5.5) 19 realistic astronomy data tasks twice: once as a plain
session with its usual tools (shell, files, web search), and once with the skyhound MCP
server and skills. Both had the same Python environment, including astroquery. The tasks
range from "make Euclid cutouts for every source in this file", "build a 300-galaxy
training set split by sky region" and "get me the PSFs of five telescopes" to "is NGC 6505
in Euclid DR1?".

Every run was scored 1-100 against a rubric written per task: the product (50: is it
exactly what was asked, and usable?), following the request (20), the answer (20: true
to the files, with the caveats that matter) and efficiency (10, from the wall time). The
scoring was automatic, with human supervision: a grader model (Claude Opus 5.5, blind to
the setup) reads measured facts about the files each run produced, its tool calls and its
answer; every run was also scored by hand, and the grader's rules were adjusted where the
two disagreed (they agree with r = 0.90). **With skyhound the runs score 89 on average,
plain 62.** By the pass/fail outcome checks, 18 of 19 tasks were done with skyhound and 12
plain, at less than half the cost and a quarter of the time
([pass/fail, cost and time](https://raw.githubusercontent.com/Aureusa/skyhound/main/docs/figures/eval-v0.1-summary.png)).

[The tasks, checks and rubrics](evals/cases.md) ·
[per-task pass/fail](https://raw.githubusercontent.com/Aureusa/skyhound/main/docs/figures/eval-v0.1-per-case.png) ·
[raw numbers](https://raw.githubusercontent.com/Aureusa/skyhound/main/docs/figures/eval-v0.1-results.csv) ·
[notebook with every score and its evidence](notebooks/evals.ipynb).

Caveats:

- **One run per task.** Agent runs vary; a few results could flip on a re-run, and the
  grader's score of one run moves by about 5 points between passes. Repeated runs with
  error bars are planned.
- **Small, home-made task set** (19 tasks, written by the authors), weighted towards
  Euclid. It measures this tool on its intended jobs, not general astronomy ability.
- **One plain run was stopped by hand.** The plain machine-learning-set task (A5) was
  cancelled after 28 minutes without a single cutout. Its cost was estimated from its
  token use, since a cancelled session reports none.
- **The blinding is partial**: the tool calls show which setup a run used.
- Cost is the API cost reported by Claude Code; time includes waiting for archives and
  background jobs.

## Archives

| Name | Data | Cone search | Cutouts | PSF | ADQL | Login | Coverage |
|---|---|---|---|---|---|---|---|
| `euclid-dr1` | Euclid DR1 (2026), ESA | MER catalogue (Wide Survey) | VIS, NISP Y/J/H | survey model (MER PSF grid; also DES g/r/i/z) | yes | optional | ~2,400 deg² |
| `euclid-q1` | Euclid Q1 (2025), ESA | MER catalogue | VIS, NISP Y/J/H | survey model | yes | optional | Deep Fields, ~63 deg² |
| `gaia` | Gaia DR3 (ESA, AIP mirror) | gaia_source | – | – | yes | – | all sky |
| `vizier` | any VizieR catalogue (CDS, CfA mirror) | `table="I/355/gaiadr3"` | – | – | – | – | per catalogue |
| `simbad` | SIMBAD objects (CDS, Harvard mirror) | basic | – | – | yes | – | all sky |
| `hips2fits` | any HiPS survey (CDS) | – | `band="DSS2-red"`, `"PanSTARRS-g"`, any HiPS ID | empirical (linear HiPS only) | – | – | per survey |
| `mast` | HST, JWST, TESS, … (STScI) | `search_products` / `download_product` | `"TESS[:sector]"`, `"HST:<filter>"` | library: `"HST:F814W"`, `"JWST:F200W"`, … | – | optional token | pointed |
| `panstarrs` | Pan-STARRS1 DR2 stacks (STScI) | – | g, r, i, z, y (calibrated) | empirical | – | – | Dec > −30° |
| `legacysurvey` | Legacy Surveys DR10 (NOIRLab) | – | g, r, i, z (calibrated) | empirical | – | – | ~20,000 deg² |

```python
from skyhound.archives import get_archive
from skyhound.core import parse_coordinates

dr1 = get_archive("euclid-dr1")
target = parse_coordinates("04:04:57.6 -48:25:12")
print(dr1.check_coverage(target).message)
print(dr1.cone_search(target, radius_arcsec=10).summary())
print(dr1.cutout(target, size_arcsec=20, band="VIS").summary())
```

## What's in the repo

| Layer | Where | What it does |
|---|---|---|
| Python library | `src/skyhound/` | All the logic. Usable without any AI. |
| CLI | `skyhound` | The same functions, for people and scripts. |
| MCP server | `skyhound-mcp` | A thin wrapper that exposes the library as tools. |
| Skills | `skills/*/SKILL.md` | Written workflows that tell the agent how to use the tools well. |
| Claude Code plugin | `.claude-plugin/`, `.mcp.json` | Bundles the server and skills for a one-step install. |

Tools never return pixels or large tables to the model. They write data to disk and return
a path, a short summary and a `<file>.provenance.json` sidecar with the query, versions and
the archive's citation text.

## Development

```bash
git clone https://github.com/Aureusa/skyhound.git
cd skyhound
pip install -e ".[dev]"
pytest                      # offline tests
pytest --remote             # also run tests against live archives
skyhound --version
skyhound-mcp      # starts the MCP server on stdio
```

## Cutouts for a whole list of objects

Give a source list and get one cutout per object. The list can be a text file (one
`RA Dec`, sexagesimal position or object name per line), any table (CSV, ECSV, FITS,
VOTable, e.g. a `cone_search` result) or a URL; RA/Dec columns are detected.

```bash
skyhound batch-cutouts targets.csv --archive euclid-dr1 --band VIS --size 10
# run it in the background instead (on a cluster: through Slurm)
export SKYHOUND_SLURM_ARGS="-p cpu-short -t 02:00:00 -c 4 --mem 4G"
skyhound batch-cutouts targets.csv --archive euclid-dr1 --band VIS --size 10 --background slurm
skyhound job-status
# look at them
skyhound quicklook skyhound-data/batches/<batch>/ --sample 100
skyhound citations skyhound-data/batches/<batch>/
```

Batches are resumable (re-running keeps finished cutouts) and write a `manifest.csv`
with the status of every object (ok / exists / outside / failed). Objects outside the
archive's footprint are skipped without a request.

## PSFs

`get_psf` (one) and `start_psf_batch` (many positions × surveys) return the PSF as a FITS
image: odd size, sum 1, peak in the central pixel, on the survey's pixel grid, with its
kind and FWHM in the header and provenance:

- **survey model**: Euclid's own MER PSF grids (read as one stamp with HTTP range requests,
  ~8 MB instead of the 1.5 GB file);
- **library**: STScI's empirical HST (ACS, WFC3, WFPC2) and JWST (NIRCam per detector,
  NIRISS, MIRI) PSFs;
- **empirical**: built from isolated Gaia stars in a 10′ image of the field (photutils
  ePSF), for any archive with calibrated images. Display-scaled images (e.g. the CDS HiPS
  of Pan-STARRS, DSS plates) are detected and refused.

```bash
skyhound psf "61.24 -48.42" --archive euclid-dr1 --band VIS
skyhound psf-batch euclid-dr1:VIS euclid-dr1:NIR_H mast:JWST:F200W panstarrs:r --target "150.1 2.2"
```

## Validation notebooks

[`notebooks/`](notebooks/) has executed notebooks that check what the tools and agents
produced against independent references: [`cutouts.ipynb`](notebooks/cutouts.ipynb)
(positions, batches, training-set splits, blank cutouts, study selections) and
[`psfs.ipynb`](notebooks/psfs.ipynb) (Euclid model vs empirical PSFs, HST/JWST against
the diffraction limit, ground-based PSFs and agent PSF runs).

## MCP tools

`resolve_object`, `list_archives`, `archive_status`, `auth_status`, `check_coverage`,
`cone_search`, `get_cutout`, `run_query`, `search_products`, `download_product`,
`preview_table`, `quicklook`, `citations`, `start_batch_cutouts`, `start_target_cutouts`,
`job_status`, `cancel_job`, `inspect_data_record`, `download_data_file` (catalogues
published with papers on Zenodo), `get_psf`, `start_psf_batch`. Run the server with `skyhound-mcp` (stdio).

## Logging in to archives

Some archives need an account for non-public data (ESA, ESO) or an API token (MAST).
Log in once from a terminal; the agent never sees your password:

```bash
skyhound login euclid-esa        # prompts for username/e-mail and password
skyhound auth-status             # which archives need a login, what is stored
skyhound logout euclid-esa
```

Credentials go to the system keyring if there is one, otherwise to
`~/.config/skyhound/credentials.netrc` (readable only by you). You can also
set `SKYHOUND_<ARCHIVE>_USERNAME` / `_PASSWORD` / `_TOKEN`, or reuse an
existing `~/.netrc` entry for the archive's host.

## License

BSD-3-Clause. See [LICENSE](LICENSE).
