Skip to main content

Astro Copilot

Give your AI assistant real astronomical data-reduction tools — FITS inspection, photometry, light curves, and spectra, running locally, no external service required.

PyPI version Python 3.10+ License: MIT Publish

Why this exists

Doing real astronomical data reduction — aperture photometry, transit fitting, WCS-aware source lookups — normally means writing throwaway Astropy/Photutils/Lightkurve scripts by hand, every time. Astro Copilot exposes that workflow as a set of Model Context Protocol tools, so an LLM like Claude can inspect your FITS files, run photometry, detect sources, extract spectra, and fit light curves directly — with proper error propagation, WCS handling, and quality flags — entirely on your machine. No data leaves your computer, and no astronomy API keys required.

Features

  • FITS inspection — HDU structure, header keywords, WCS metadata, and robust image statistics (median, MAD-std, NaN/saturation flags)
  • Aperture photometry — circular apertures with local sky-background annulus subtraction, full CCD error propagation (Poisson + read noise), per-source quality_tier (good/marginal/bad), and out-of-bounds pre-validation
  • Automatic source detection — peak-finding with auto-estimated background and FWHM, minimum-separation filtering, and per-source SNR
  • Light curve analysis — Savitzky-Golay detrending, transit detection via Box Least Squares, periodic-signal detection via Lomb-Scargle, phase-folded diagnostics
  • 1D spectrum extraction — sum/median/center-row extraction from 2D spectroscopic FITS, header-based wavelength calibration, spectral feature (line) detection
  • Synthetic sample data generator — creates a test FITS image, transit light curve, and variable-star CSV with one call, no external downloads needed
  • Security-conscious by design — path traversal validation on every file input, coordinate bounds checking before expensive operations

Install

pip install astro-copilot

Quick Start

from astro_copilot.core.fits_io import inspect_fits_file
from astro_copilot.core.photometry import run_aperture_photometry

# Inspect a FITS file's structure, WCS, and image statistics
info = inspect_fits_file("sample_data/sample_image.fits")
print(info["selected_hdu"]["statistics"]["median"])

# Run aperture photometry on a known pixel position
result = run_aperture_photometry(
    file_path="sample_data/sample_image.fits",
    aperture_radius=6.0,
    positions=[[128.0, 128.0]],
    bkg_annulus_inner=9.0,
    bkg_annulus_outer=14.0,
)
print(result["sources"][0]["mag"], result["sources"][0]["quality_tier"])

Don't have a FITS file handy? Generate one:

from astro_copilot.server import generate_sample_datasets
generate_sample_datasets("sample_data")

Connect to Claude Desktop

Add this to your claude_desktop_config.json:

{
  "mcpServers": {
    "astro-copilot": {
      "command": "python",
      "args": ["-m", "astro_copilot.server"]
    }
  }
}

Restart Claude Desktop, and the following tools become available in chat: inspect_fits, aperture_photometry, detect_sources_auto, extract_spectrum, fit_lightcurve, and generate_sample_datasets.

Example

Once connected, you can ask Claude directly:

"Run aperture photometry on sample_image.fits at pixel (128, 128) with a 6-pixel aperture and a 9–14 pixel background annulus."

Claude calls aperture_photometry and gets back structured JSON like:

{
  "status": "success",
  "sources": [
    {
      "id": 1,
      "x_px": 128.0,
      "y_px": 128.0,
      "bkg_subtracted_flux": 94210.5,
      "snr": 187.3,
      "mag": 15.318,
      "mag_err": 0.006,
      "quality_tier": "good",
      "flags": ["OK"]
    }
  ]
}

More worked examples — including transit detection and WCS-based sky coordinate lookups — are in docs/example_prompts.md. Full tool parameter reference: docs/tools_reference.md.

Roadmap

  • PSF-fitting photometry for crowded fields
  • Multi-band/multi-epoch batch processing
  • Image alignment and stacking helpers

Have a feature request? Open an issue.

Contributing

Contributions are welcome:

  1. Fork the repo and create a feature branch from main
  2. Make your change, add or update tests under tests/, and run pytest -v
  3. Open a pull request describing what changed and why

License

MIT — see LICENSE.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

astro_copilot-0.1.0.tar.gz (26.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

astro_copilot-0.1.0-py3-none-any.whl (25.4 kB view details)

Uploaded Python 3

File details

Details for the file astro_copilot-0.1.0.tar.gz.

File metadata

  • Download URL: astro_copilot-0.1.0.tar.gz
  • Upload date:
  • Size: 26.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for astro_copilot-0.1.0.tar.gz
Algorithm Hash digest
SHA256 1e46ab4c5443ad63a9394c56c16dd24f30aa68d832af67970ae99e0756a1b4df
MD5 5ebfea72f54022e98d8991c7159e1402
BLAKE2b-256 7d1546f462eb0f1a43deb0dd0099b8a3e1c0afe93b3b8cca69d9fb249cda9677

See more details on using hashes here.

Provenance

The following attestation bundles were made for astro_copilot-0.1.0.tar.gz:

Publisher: publish.yml on ManiaSacha/Astro-mcp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file astro_copilot-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: astro_copilot-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 25.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for astro_copilot-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 953b5d5ca65a20c68362f694acc8b059e7716da3bd85dc3ec00c2d40b8f2712a
MD5 562b83592291209562041189e9335b22
BLAKE2b-256 52141b34e623aad1bd57c4ece8394e485782740b22a80170fd7735aede234bd7

See more details on using hashes here.

Provenance

The following attestation bundles were made for astro_copilot-0.1.0-py3-none-any.whl:

Publisher: publish.yml on ManiaSacha/Astro-mcp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page