---
title: "Testing"
description: "How nasa-mcp is tested: hermetic recorded fixtures with key scrubbing, MCP protocol tests and opt-in live tests."
type: Reference
tags:
  - testing
  - fixtures
  - ci
generated:
  by: "claude/opus-5.5"
  at: "2026-11-27T00:00:00Z"
sources:
  - id: design
    resource: "DESIGN.md"
    title: "nasa-mcp design"
    author: "team:nasa-mcp"
  - id: research
    resource: "RESEARCH.md"
    title: "nasa-mcp research notes (upstream services, 2026-11-27)"
    author: "team:nasa-mcp"
status: stable
---

<!--
SPDX-FileCopyrightText: 2026 Tyson Lee Swetnam
SPDX-License-Identifier: CC-BY-4.0
-->

# Testing

```bash
uv run pytest                                   # hermetic: no network (addopts = -m 'not network')
uv run pytest -m network tests/live             # live, small volume
uv run pytest -m "network and apikey" tests/live   # NeoWs/InSight live tests: spend key quota
uv run python scripts/record_fixtures.py check
```

* **Fixtures** (`tests/fixtures/<host>/...`, `manifest.json` with `key, status, contentType,
  transform, origin, recordedOn`) are replayed by `tests/fixture_router.py`, an
  `httpx.MockTransport` that fails the test on any unrouted request. `record_fixtures.py record`
  runs the calls in `tests/helpers.RECORDED_CALLS` through the real server with a recording
  transport, so keys are exactly what the server sends. Large bodies are reduced: the largest JSON
  list is halved until the file fits 48 KB, and the GIBS capabilities document is cut to a few
  layers; each reduction is the manifest `transform`.
* **`check`** (CI) enforces <= 64 KB per file, <= 2 MB total, allow-listed hosts, GET only, no
  credential headers, no `api_key`-like parameters in keys or file names, and **no registered
  secret in any file**. api.nasa.gov requests carry the key from `NASA_MCP_NASA__API_KEY` (or
  DEMO_KEY); fixture keys drop it.
* **Recorded fixtures:** 55, from the 16 hosts, recorded on 2026-11-27/28, including the NeoWs
  and InSight responses recorded with a personal key. NeoWs echoes the key inside its `links`
  URLs, so `record` masks every `api_key=` value (and any registered secret) before writing, and
  refuses to write a file that still contains the key. Keyed calls are skipped (keeping existing
  fixtures) when only DEMO_KEY is available. `scripts/make_synthetic_fixtures.py` can rebuild
  `origin: "synthetic"` stand-ins from saved samples if a personal key is ever unavailable.
* **Tool tests** (`tests/tools/`): every tool through the router, including the quirk paths
  (DONKI empty body, EPIC `[]` for a missing day, SBDB 200-not-found and 300-ambiguous, Sentry
  removed objects, SSCWeb typed JSON, TAP 400 VOTable, EONET Content-Type).
* **Client and cache:** key placement only on `api.nasa.gov` and never across redirects,
  redaction, short and long `Retry-After`, stale-if-error, single-flight.
* **MCP protocol:** `tests/test_spec_conformance_2026_07_28.py` runs every tool through the SDK
  client in process (outputSchema validation, text == structured, `_meta`, cache hints), plus a
  real stdio subprocess and HTTP against uvicorn on 127.0.0.1 (health, readiness, 405s, Host
  guard, 413).
* **Meta:** `test_integration_meta.py` (every tool has a unit and a live test),
  `test_docs_generation.py` (generated docs in sync, OKF valid, `llms.txt` complete),
  `test_no_local_paths.py`.
* **Live tests** (`tests/live/`) carry `network`; NeoWs and InSight tests also carry `apikey`.
  They use `NASA_MCP_NASA__API_KEY` when set. Never on pull requests.
* Coverage `fail_under = 85`; `mypy --strict`; ruff `E,F,I,UP,B,SIM,S,RUF`, line length 100.
