Skip to main content Switch to mobile version casper-astro-tools 0.4.0 Open astronomy tools for AI agents and scripts: NASA ADS and arXiv, SIMBAD/NED/VizieR/Gaia and VO archives, and offline coordinate, time, unit, cosmology and observing calculators, as a Python library, a command line and an MCP server.
pip install casper-astro-tools==0.4.0 Copy PIP instructions
Open astronomy tools for AI agents and scripts. The open, public part of CASPER, the assistant platform of CAMCEAD at the Institute of Astronomy, University of Cambridge.
116 tools behind one calling protocol (64 read-only tools for the public services and the calculators, 21 tools that work on Gaia files in a folder of your own machine, 20 of them offered by default, and 31 opt-in tools that explore, check, audit and plot WEAVE L1/L2 files on your own machine), usable as a Python library, a command line and a Model Context Protocol server (stdio and Streamable HTTP), with any model that can call functions:
The tool catalogue has one page per tool (description, input schema, example call, example output); docs/tools.json is the same in machine-readable form. Both are generated from the code and a test fails if they drift.
Also in this repository: a worked case study (plan a night at La Palma, check proper motions, find the key papers; runs offline), and CASPER AstroToolBench, a seed benchmark of 73 offline tasks with checkable answers for models that use these tools (bench/README.md).
Cluster ages from Gaia photometry, offline (0.3.0)
casper_astro_tools.isochrones and the tools astro_isochrone / astro_isochrone_fit carry a 2 MB copy of the MIST v1.2 isochrones in the Gaia bands (G, BP, RP; 1 Myr to 20 Gyr; [Fe/H] -2 to +0.5) and fit the age of a clean cluster sequence (distance from the parallax, extinction and metallicity fixed or searched, an age with a 68 % interval, notes on what the sample cannot constrain). pip install casper-astro-tools is all that is needed, so it works in a sandbox that reaches package managers only. More models (MIST non-rotating, BaSTI-IAC) can be added with the bank builder; guide, measured results on M 67 and Praesepe, limits and the terms of the models: docs/ISOCHRONES.md; the whole workflow as a script: examples/cluster_age_from_gaia.py.
pip install casper-astro-tools # from PyPI; from a checkout: pip install . casper-astro-tools doctor # checks the installation (no network) pip install 'casper-astro-tools[gaia]' # optional: plots (matplotlib), Parquet (pyarrow), XP spectra (GaiaXPy); and [gaia-selection] for the DR3 selection function Python 3.10 or newer (tested on 3.11). Dependencies: astropy, numpy, scipy, httpx, defusedxml, mcp.
import casper_astro_tools as at at.call("astro_convert_coordinates", lon="18h36m56.3364s", lat="+38:47:01.291", to_frame="galactic")["output"]["l_deg"] # 67.448... at.call("astro_cosmology", redshifts=[0.5])["results"][0]["luminosity_distance_mpc"] # Planck18 at.call("gaia_source", source_id="4472832130942575872") # needs the network Every call returns a dict: {"ok": true, ...} or {"ok": false, "error": " ", "message": "..."}. Inside a running event loop use await at.acall(...).
casper-astro-tools list # the tools casper-astro-tools describe astro_night_info # schema and examples of one tool casper-astro-tools call astro_night_info date=2026-11-12 site=wht casper-astro-tools call resolve_name name="M 51" --offline # answer from the bundled recordings, no network MCP server (Claude Desktop, Claude Code, any MCP client)
casper-astro-tools serve # stdio casper-astro-tools serve --http --port 8765 # Streamable HTTP at http://127.0.0.1:8765/mcp { "mcpServers": { "casper-astro-tools": { "command": "casper-astro-tools", "args": ["serve"], "env": { "ADS_API_TOKEN": "your-ads-token" } } } } Every tool is annotated read-only except the local Gaia tools that can write a result file (below); the literature and archive tools are marked "open world" (they contact a public service), the calculators and the local file tools (Gaia and WEAVE) are not.
Your own Gaia downloads: the local file tools
Download Gaia data (an archive query, a DataLink product, astroquery output) into a folder, start the server on that folder, and let your model work on the files without uploading them anywhere:
casper-astro-tools gaia-demo ~/gaia_demo # optional: a small SYNTHETIC set of files to try claude mcp add gaia-local -- casper-astro-tools serve --data-dir ~/gaia_data # Claude Code (stdio) { "mcpServers": { "gaia-local": { "command": "casper-astro-tools", "args": ["serve", "--data-dir", "/path/to/gaia_data"], "env": { "CASPER_ASTRO_TOOLS_GROUPS": "local,calculators" } } } } The gaia_local_* tools read only files inside that folder (symbolic links are followed and must stay inside; special files, unknown extensions and files over 2 GB are refused), write only into its casper_out subfolder and never overwrite, make no network call and run no program. Text from a file is treated as data. The one exception is gaia_local_fetch, which downloads public Gaia data and is not even offered unless you start the server with --allow-downloads. Details, limits, example prompts and the Gaia DR4 notes: docs/GAIA_LOCAL_DATA.md.
Your own WEAVE files: the weave_files tools
For people who download WEAVE L1 and L2 files and run the public PyAPS code (the WEAVE analysis package) on their own machine. The 28 weave_* tools let an assistant look into those files, plot them and check them, so that "is this product sane?" and "what is in this fibre?" become questions you ask instead of scripts you write. They are the explorer, check and audit side of PyAPS; there is no processing tool (no pPXF, line-strength or EMI run, no SLURM, no pipeline stage), and nothing from non-public code is used.
Set it up. Name the directories that hold your files (the L1, L2 and calibration trees may be on different disks; separate directories like PATH) and start the server. Until you do, the group is not offered and nothing on your disk is readable.
export CASPER_ASTRO_TOOLS_WEAVE_ROOTS=/path/to/weave/L1:/path/to/weave/L2 # or: casper-astro-tools serve --weave-root /path/to/weave/L1 --weave-root /path/to/weave/L2 claude mcp add weave-files -- casper-astro-tools serve # Claude Code (stdio); the variable is read from your environment casper-astro-tools list --group weave_files # the tools (works without the variable too) { "mcpServers": { "weave-files": { "command": "casper-astro-tools", "args": ["serve"], "env": { "CASPER_ASTRO_TOOLS_WEAVE_ROOTS": "/path/to/weave/L1:/path/to/weave/L2", "CASPER_ASTRO_TOOLS_GROUPS": "weave_files,calculators" } } } } Paths in a question may be absolute (inside a root) or relative to a root. weave_files_status says what is configured and whether PyAPS and matplotlib are installed (both optional: PyAPS, installed from its public repository or with pip install 'casper-astro-tools[weave]' if your package index has it, adds cross-checks; pip install 'casper-astro-tools[plot]' adds the PNG plots; no result depends on either).
"Plot the best-fit pPXF model over the spectrum of FIBREID=100 in 20250101/10001/single_3148291__single_3148290_APS.fits." The assistant calls weave_l2_spectrum with fibreid=100, kind="ppxf", plot=true: the data (wavelength in Angstrom, flux, model, residual, good-pixel mask, ZWARN / FWHM_FLAG read in words) and a PNG with the model over the spectrum, the unused pixels shaded and a caption that names file, target, kind and flags. It says plainly when the fit failed or the spectrum is all NaN.
"Check this folder for all-NaN line strengths." weave_audit_ob (one OB folder) or weave_check_file (one file) report every all-NaN line-strength or emission-line column group with the likely cause: products made before PyAPS prod 2549797 (2026-11-06) have all-NaN indices and FWHM_FLAG 3 everywhere. Findings are ranked, carry stable codes and name the next tool to run, and the result lists what was not checked.
"What is in stack_3148290.fit, and how good is fibre 12?" weave_file_info (family, mode, arms, versions, completeness), weave_l1_fibres (the fibre table, filtered), weave_l1_spectrum (one fibre; chosen by the value of FIBREID, Nspec, CNAME or TARGID, never by row number) and weave_l1_quality.
"Why does this OB have so many patches?" weave_l2_tree and weave_ifu_patch_table compare the patches defined against the patches written and flag outliers; weave_compare_files shows what changed between a product before and after a re-run.
Safe to give to a model. Read-only (files are opened read-only, memory-mapped; there is no write path and no output folder), offline (no network call, CASPER_ASTRO_TOOLS_NETWORK=0 does not matter to them), and nothing leaves the machine except the answers the assistant sees. One guard decides every path: it must lie inside a configured root after symbolic links are followed; .., ~, URLs, control characters, FIFOs, sockets, devices, pickles and .npy files are refused; a path outside the roots gets the same answer whether it exists or not; results carry paths relative to a root. Caps on rows (500), spectrum points (2000), bytes read per call (64 MB), directory entries and result size. Text from your files (column names, header cards, cell values) is cleaned, shortened and labelled as untrusted data. What the tools assume about the files is one committed file, src/casper_astro_tools/data/weave_contract.json, made from the public PyAPS code (see docs/WEAVE_FILES_UPDATING.md). Start with the quickstart; the design is in docs/WEAVE_FILES_DESIGN.md, the tools in L1, L2 and checks.
Settings (environment variables, all optional)
What it does to be safe to give to a model
Read-only. No tool uploads, runs code or changes anything anywhere; the only tools that write are the local Gaia ones, and they write new files inside casper_out of your data folder, never over an existing file. ADQL queries must be a single SELECT (no comments, no semicolon, no write or sleep words outside quotes); TOP and MAXREC are forced to the row cap (500).
Allow-listed hosts. The archive tools only contact hosts listed in src/casper_astro_tools/archives/services.py (https, port 443, no IP literals, every resolved address must be public; redirects are followed by hand and re-checked). A host found by a registry search is accepted for one hour in that process; no environment variable widens the list.
Bounded. Row, byte, time and size caps on every call; arXiv is queued to one request per three seconds; ADS to 60 calls a minute.
Untrusted data is labelled. Archive and literature results carry their provenance (service, address, query, time) and a notice that the content is third-party data, not instructions.
Offline by construction. The calculators force astropy offline: nothing is downloaded, ever. The local Gaia tools do the same, and the one download tool is off unless you switch it on.
Local files are fenced in. One allowed folder (the WEAVE tools: the list of folders you named, nothing else, through the same single path guard); the resolved path of every file must lie inside it; size, row and time caps; no pickle, no code evaluation (filters are a fixed list of operators); VOTable and ECSV are checked for entity and object tricks first; column names, header cards and text cells are cleaned, shortened and labelled as untrusted data.
The HTTP server has no login: it binds to localhost. Put your own authenticating proxy in front before exposing it. See SECURITY.md.
The hours-above-altitude figures count a 5-minute grid including both ends of the window, so they can exceed the true duration by one grid step (0.08 h).
No dust map: astro_extinction_law takes E(B-V) from you. Cosmology distances ignore radiation (a 0.02 % effect at z = 0.5) and absolute_magnitude_no_k_correction has no K-correction by name.
The Earth-orientation table is the one inside astropy; it is never refreshed over the network.
Archive answers change when the archives do. The recordings under src/casper_astro_tools/data/fixtures are snapshots (archives 2026-10-22, arXiv and Gaia 2026-10-30), kept for tests and for the offline mode; the CDS services were unreachable from the recording host on 2026-10-30, so their snapshot is the older one.
No ADS answer is recorded (ADS needs a personal token): the ADS examples in the catalogue come from an invented stand-in and say so on the page.
Tests, regenerating the docs
pip install -e .[test] pytest # no network; about 2 minutes python tools/gen_catalogue.py # regenerate docs/catalogue and docs/tools.json (the test suite fails if you forget) python bench/make_tasks.py # regenerate the benchmark task files python tools/record_fixtures.py out.json # re-record the public-service answers (network; read-only) Authors, citing, licence
Authors (all at the Institute of Astronomy, University of Cambridge; the first is the corresponding author): Alireza Molaeinezhad, Nicholas Walton, Marco Riello, Eduardo González Solares, Leigh Smith, Giuseppe D'Ago, David Homan.
Molaeinezhad, A., Walton, N., Riello, M., González Solares, E., Smith, L., D'Ago, G., Homan, D. (2026). CASPER Astro Tools: open astronomy tools for AI agents and scripts (version 0.3.0) [Computer software]. Institute of Astronomy, University of Cambridge. https://doi.org/10.5281/zenodo.24111059
Archive record: 10.5281/zenodo.24111059 (this version, 0.3.0); 10.5281/zenodo.23855283 always resolves to the latest version (0.2.0 is 10.5281/zenodo.24032233, 0.1.0 is 10.5281/zenodo.23855284).
Security reports: see SECURITY.md.
Related work: ToolUniverse (an open platform of biomedical tools behind one protocol). This package is a small, astronomy-specific, read-only counterpart; see docs/DESIGN.md for how the two differ.
This package is a client of public services and of open software. If you publish results obtained with it, please acknowledge what you used; the full sentences, citations and terms are in docs/ACKNOWLEDGEMENTS.md (reviewed and accepted by the authors on 2026-11-01; where a service publishes different wording, use the service's). In short:
This research has made use of the SIMBAD database, operated at CDS, Strasbourg, France. (Wenger et al. 2000, A&AS 143, 9)
This research has made use of the VizieR catalogue access tool, CDS, Strasbourg, France (DOI: 10.26093/cds/vizier). (Ochsenbein et al. 2000, A&AS 143, 23)
This research has made use of the NASA/IPAC Extragalactic Database (NED), which is funded by the National Aeronautics and Space Administration and operated by the California Institute of Technology.
This work has made use of data from the European Space Agency (ESA) mission Gaia (https://www.cosmos.esa.int/gaia), processed by the Gaia Data Processing and Analysis Consortium (DPAC, https://www.cosmos.esa.int/web/gaia/dpac/consortium). (Gaia Collaboration 2016, 2023)
This research has made use of NASA's Astrophysics Data System Bibliographic Services. ADS content is not redistributed by this package; the ADS examples are labelled stand-ins.
This research made use of Astropy (http://www.astropy.org), a community-developed core Python package for Astronomy (Astropy Collaboration, 2013, 2018, 2022).
arXiv: the API terms (one request per three seconds) are followed by the client; the arXiv metadata excerpts are shipped under arXiv's CC0 statement for metadata. Sesame, the CDS cross-match, hips2fits and the Virtual Observatory: see the acknowledgements page.
The short recorded excerpts of public answers under src/casper_astro_tools/data/fixtures each carry a mark naming the service and the date; see NOTICE.
Author: Alireza Molaeinezhad, Nicholas Walton, Marco Riello, Eduardo González Solares, Leigh Smith, Giuseppe D'Ago, David Homan
Maintainer: Alireza Molaeinezhad
Apache Software License (Apache-2.0)
test gaia gaia-selection weave plot
CASPER astronomy mcp model-context-protocol llm-tools astropy ads arxiv virtual-observatory benchmark gaia isochrones
Development Status 3 - Alpha
Intended Audience Science/Research
License OSI Approved :: Apache Software License
Programming Language Python :: 3
Topic Scientific/Engineering :: Astronomy
Release files for casper-astro-tools 0.4.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
Built distribution (wheel)
Total release size: 7.2 MB
Release files / casper_astro_tools-0.4.0.tar.gz
Security for casper-astro-tools 0.4.0
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.
Release history Release notifications | RSS feed
Nov 28, 2026 2 release files No provenance
Nov 22, 2026 2 release files No provenance
Nov 18, 2026 2 release files No provenance
Nov 10, 2026 2 release files No provenance
Nov 7, 2026 2 release files No provenance
Nov 1, 2026 2 release files No provenance
"PyPI", "Python Package Index", and the blocks logos are registered trademarks of the Python Software Foundation.
© 2026 Python Software Foundation




