CAMSPER Astro Tools (camsper-astro-tools)
Open astronomy tools for AI agents and scripts. The open, public part of CAMSPER, 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:
| group | tools | needs |
|---|---|---|
| Offline calculators (35) | coordinate frames, proper motion, separation; time scales, sidereal time, barycentric corrections; units, magnitudes and fluxes, redshift and distance in a chosen cosmology, extinction law, spectral lines; observing sites, night timeline, target visibility and airmass, best nights, field-of-view membership; Gaia data analysis (16 astro_gaia_* tools: parallax zero point, quality verdicts, distances, photometry corrections and colour relations, extinction per Gaia band, radial-velocity correction, kinematics with errors, covariance and Monte Carlo, proper-motion frames, 6D epoch propagation, Gaia time, period search; the same numbers as pure functions in casper_astro_tools.gaia_math for your own scripts) |
nothing, no network |
| Literature (10) | NASA ADS (search, one paper, references, citations, an object's literature, libraries) and arXiv (search, recent, one paper), with provenance on every result | arXiv: nothing. ADS: your own token in ADS_API_TOKEN |
| Local Gaia files (21; the "bring your own data" half) | inspect a Gaia download of any release (DR1 to DR3, newer releases by their columns) and report its quality; RUWE / IPD / C* cuts and the Lindegren et al. 2021 parallax zero point; distances, absolute magnitudes, Hess diagrams, space velocities, full-covariance Monte Carlo errors; position and source_id cross-match with your own catalogue and epoch propagation; declarative row filters, cone and box selection, joins, DR2 to DR3 comparison; XP spectra, epoch photometry with period search; the DR3 selection function; plots; and, only if you switch it on, one download tool | nothing but your files (matplotlib, pandas, pyarrow, GaiaXPy, gaiaunlimited are optional extras); no network by default |
| Public archives (19) | name resolution (CDS Sesame), SIMBAD, NED, VizieR, CDS cross-match, Gaia DR3, any Virtual Observatory TAP service and the VO registry, a table-driven search of SDSS, Pan-STARRS, Legacy Surveys, DESI, MAST, ESO, IRSA, HEASARC, CADC and ALMA, sky cut-out links | nothing; the public services must be reachable |
| Local WEAVE files (28; opt-in, for people who run the public PyAPS on their own machine) | explore WEAVE L1 and L2 FITS files in the folders you name: what a file is, its fibres and spectra, the best-fit pPXF, Redrock, RVS or emission-line model over a spectrum (optional PNG), line strengths, IFU patches and bins, and read-only checks and audits of a file or an OB folder against what PyAPS writes (all-NaN line strengths, a merged file that skipped an input, a patch explosion, mixed versions, truncated files). Nothing is processed, nothing is written, nothing leaves the machine | CASPER_ASTRO_TOOLS_WEAVE_ROOTS (or --weave-root); not offered until you set it. PyAPS and matplotlib are optional |
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 CAMSPER 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 camsper-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.
The new name: camsper-astro-tools
This package is the successor of casper-astro-tools (PyPI versions 0.1.0 to 0.4.1), renamed because the platform it belongs to is now called CAMSPER; the code, the authors and the licence are the same. What changes and what does not:
| new | old (still works) | |
|---|---|---|
| install | pip install camsper-astro-tools |
pip install casper-astro-tools installs the new package (a thin bridge release, 0.5.0, that only depends on it) |
| command | camsper-astro-tools |
casper-astro-tools (the same program, installed by the new package) |
| Python import | import camsper_astro_tools |
import casper_astro_tools |
| environment variables | unchanged: CASPER_ASTRO_TOOLS_*, CASPER_ASTRO_DATA_DIR, CASPER_WORK_DIR, CASPER_CACHE_DIR and the output folder name casper_out |
Why the import name was not changed: the code lives in the package casper_astro_tools, and every script, notebook and server configuration that already imports it keeps working without an edit. camsper_astro_tools is a small alias package that makes every camsper_astro_tools.X (at any depth) the same module object as casper_astro_tools.X, never a second copy, so classes and settings are shared whichever spelling a program uses. Use the new spelling in new code; the old one will not be removed without a notice here first. Likewise the environment variables keep their names so that nothing configured today breaks. The earlier PyPI releases and Zenodo versions stay as published, under the old name.
Install
pip install camsper-astro-tools # from PyPI; from a checkout: pip install .
camsper-astro-tools doctor # checks the installation (no network)
pip install 'camsper-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.
Use it
Python
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": "<code>", "message": "..."}. Inside a running event loop use await at.acall(...).
Command line
camsper-astro-tools list # the tools
camsper-astro-tools describe astro_night_info # schema and examples of one tool
camsper-astro-tools call astro_night_info date=2026-11-12 site=wht
camsper-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)
camsper-astro-tools serve # stdio
camsper-astro-tools serve --http --port 8765 # Streamable HTTP at http://127.0.0.1:8765/mcp
{ "mcpServers": { "camsper-astro-tools": { "command": "camsper-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:
camsper-astro-tools gaia-demo ~/gaia_demo # optional: a small SYNTHETIC set of files to try
claude mcp add gaia-local -- camsper-astro-tools serve --data-dir ~/gaia_data # Claude Code (stdio)
{ "mcpServers": { "gaia-local": { "command": "camsper-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: camsper-astro-tools serve --weave-root /path/to/weave/L1 --weave-root /path/to/weave/L2
claude mcp add weave-files -- camsper-astro-tools serve # Claude Code (stdio); the variable is read from your environment
camsper-astro-tools list --group weave_files # the tools (works without the variable too)
{ "mcpServers": { "weave-files": { "command": "camsper-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 'camsper-astro-tools[weave]' if your package index has it, adds cross-checks; pip install 'camsper-astro-tools[plot]' adds the PNG plots; no result depends on either).
Example conversations
- "Plot the best-fit pPXF model over the spectrum of FIBREID=100 in
20250101/10001/single_3148291__single_3148290_APS.fits." The assistant callsweave_l2_spectrumwithfibreid=100, kind="ppxf", plot=true: the data (wavelength in Angstrom, flux, model, residual, good-pixel mask,ZWARN/FWHM_FLAGread 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) orweave_check_file(one file) report every all-NaN line-strength or emission-line column group with the likely cause: products made before PyAPSprod2549797 (2026-11-06) have all-NaN indices andFWHM_FLAG3 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 ofFIBREID,Nspec,CNAMEorTARGID, never by row number) andweave_l1_quality. - "Why does this OB have so many patches?"
weave_l2_treeandweave_ifu_patch_tablecompare the patches defined against the patches written and flag outliers;weave_compare_filesshows 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)
| variable | meaning |
|---|---|
ADS_API_TOKEN or ADS_API_TOKEN_FILE |
your NASA ADS token (create one). Without it the ADS tools answer ads_not_configured; arXiv and the archives work. The token is never an argument, a result, a log line or an error. |
CASPER_ASTRO_TOOLS_CONTACT |
an e-mail address or URL added to the User-Agent sent to the public services (good manners for ADS, arXiv and the archives) |
CASPER_ASTRO_TOOLS_GROUPS |
which groups to offer: calculators,literature,archives,local,weave_files (default: all but weave_files, which is added when CASPER_ASTRO_TOOLS_WEAVE_ROOTS is set). calculators gives a server that never touches the network; local,calculators is the "my own Gaia files" server; weave_files,calculators the "my own WEAVE files" server. |
CASPER_ASTRO_TOOLS_WEAVE_ROOTS or --weave-root |
the directories (separated like PATH; repeat the flag for several) the weave_* tools may read. Absolute, existing, not the file system root. Without it the group is not offered. |
CASPER_ASTRO_TOOLS_WEAVE_CONTRACT |
optional: a newer weave_contract.json than the packaged one (see docs/WEAVE_FILES_UPDATING.md) |
CASPER_ASTRO_DATA_DIR or --data-dir |
the one folder the local Gaia tools may read; results go to its casper_out subfolder (default: the current directory) |
CASPER_ASTRO_ALLOW_DOWNLOADS=1 or --allow-downloads |
offer gaia_local_fetch and let the selection function fetch its map on first use (default: off, the local tools make no network call) |
CASPER_ASTRO_TOOLS_NETWORK=0 |
refuse every tool that would contact a public service |
CASPER_ASTRO_TOOLS_ARCHIVE_RATE |
archive calls allowed per ten minutes (default 60) |
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_outof your data folder, never over an existing file. ADQL queries must be a singleSELECT(no comments, no semicolon, no write or sleep words outside quotes);TOPandMAXRECare 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.
Known limitations
- 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_lawtakes E(B-V) from you. Custom cosmologies ignore radiation (a 0.02 % effect at z = 0.5; the named ones, Planck18 by default, include photons and neutrinos) andabsolute_magnitude_no_k_correctionhas 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/fixturesare 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.
Copyright 2026 CAMCEAD, Institute of Astronomy, University of Cambridge. Apache-2.0 (LICENSE, NOTICE). Please cite via CITATION.cff (GitHub and GitLab render it as "Cite this repository"), or as:
Molaeinezhad, A., Walton, N., Riello, M., González Solares, E., Smith, L., D'Ago, G., Homan, D. (2026). CAMSPER Astro Tools: open astronomy tools for AI agents and scripts (version 0.5.0) [Computer software]. Institute of Astronomy, University of Cambridge. https://doi.org/10.5281/zenodo.24623880
Archive record: 10.5281/zenodo.24623880 (this version, 0.5.0); 10.5281/zenodo.23855283 (all versions; 0.4.1 is 10.5281/zenodo.24450214, 0.4.0 is 10.5281/zenodo.24340564; those versions were published under the former name casper-astro-tools).
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.
Acknowledgements
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.
Metadata
Release files for camsper-astro-tools 0.5.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| camsper_astro_tools-0.5.0.tar.gz | 3.8 MB | Without provenance | Details for camsper_astro_tools-0.5.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| camsper_astro_tools-0.5.0-py3-none-any.whl | Python 3 | none | any | Details for camsper_astro_tools-0.5.0-py3-none-any.whl |
Total release size: 7.2 MB
Release files / camsper_astro_tools-0.5.0.tar.gz
| Download URL | camsper_astro_tools-0.5.0.tar.gz |
|---|---|
| Size | 3.8 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e0ee549e5e0acefb254a1952cfc48f92e685320de59ae19d7c254e9956cdc881
|
|
BLAKE2b-256 checksum How to use checksums |
54a4143bcf03ba702ff15ad703e123f9f82b275a8033586458b3cde5abd19e98
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.3
|
Release files / camsper_astro_tools-0.5.0-py3-none-any.whl
| Download URL | camsper_astro_tools-0.5.0-py3-none-any.whl |
|---|---|
| Size | 3.4 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d243b2a9fcaac882ed57739188ac3e8693824f2186b8c7681cfe5b38c3ae4915
|
|
BLAKE2b-256 checksum How to use checksums |
7a035a0be873928d472d732d558c4cef657b5e17f8a091d387bb6cd219872c4f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.3
|
Security for camsper-astro-tools 0.5.0
Provenance
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.
No provenance found
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.