Skip to content

Architecture

src/nasa_mcp/
  server.py            the only module that imports the MCP SDK server API
  registry.py          @register_tool, validation, timeout, size budget
  tools/               one module per service (apod, neows, donki, epic, insight, techtransfer,
                       trek, gibs, eonet, images, ssd, exoplanet, osdr, sscweb, techport, tle)
                       plus core.py (nasa_ping, nasa_list_services) and _common.py
  providers/
    base.py            Service descriptor, service ids, API_GATEWAY_HOST, DEMO_KEY
    catalog.py         the 16 services: hosts (the HTTP allow-list), key hosts, docs,
                       citation, caveats, politeness policy, ping URL
    deps.py            per-process dependencies handed to tools
  upstream/            client.py (allow-list, redirects, key placement, retries),
                       ratelimit.py, cache.py, redact.py
  transport/           stdio, stateless Streamable HTTP, /healthz and /readyz
  resources.py prompts.py instructions.py config.py errors.py logging.py context.py

A call: the SDK hands tools/call to the server -> the registry validates the arguments against the tool's pydantic model (invalid_argument lists valid names) -> the tool validates dates and enums the upstream would ignore, converts them to the upstream's format, and asks the upstream client for the URL -> the client checks the host against the service's allow-list, attaches the api.nasa.gov key only for api.nasa.gov, applies the service's rate limit, serves from the cache when it can, follows redirects one hop at a time, and records redacted endpoints and X-RateLimit-* -> the tool parses the response (unwrapping SSCWeb's typed JSON, zipping JPL columns, mapping 200-with-error bodies), converts numbers, builds URLs and fills source.citation and caveat notes from the catalogue -> the registry dumps camelCase JSON, fits it to the 50 000-byte budget and returns text plus structuredContent with _meta io.nasa-mcp/upstream (an error result returns the {error: ...} JSON as text only).

Each tool module's docstring records the upstream quirks it handles, with a pointer to the matching section of RESEARCH.md.