The api.nasa.gov key¶
Only two services go through the api.nasa.gov gateway and spend its quota:
NeoWs (nasa_neo_feed, nasa_neo_lookup, nasa_neo_browse) and
InSight (nasa_insight_weather). Every other tool calls its service's
own keyless host, so it works the same with or without a key.
1. Get your own key (free, about a minute)¶
- Open api.nasa.gov and find Generate API Key.
- Fill in first name, last name and e-mail address (an application URL is optional), then submit.
- The key, a 40-character string, appears on the page and is e-mailed to you. Keep the e-mail: it is the only copy NASA sends.
One key works for every api.nasa.gov API, for 1,000 requests per hour. It is personal: do not share it, commit it or paste it into chats, issues or screenshots. If it leaks, generate a new one with the same form; the old one can no longer be trusted.
2. Store it outside the repository¶
The server reads the key only from the environment variable NASA_MCP_NASA__API_KEY. It is
not accepted from YAML (an api_key there is a configuration error), CLI flags, MCP tool
arguments or HTTP headers, and nasa-mcp never reads .env files on its own. The setup below keeps
the key in one private file per machine, which shells, client launchers and Docker can all read.
mkdir -p ~/.config/nasa-mcp
read -rs -p "Paste your NASA API key, then Enter: " K; echo
printf 'NASA_MCP_NASA__API_KEY=%s\n' "$K" > ~/.config/nasa-mcp/env; unset K
chmod 600 ~/.config/nasa-mcp/env
read -rs takes the key without echoing it, so it never appears on screen or in your shell
history. Run all four lines in the same terminal, and paste the key at the prompt.
The file must contain exactly one line, NASA_MCP_NASA__API_KEY=<key>: no export, no spaces
around =, no quotes needed. Check it without printing the key:
env -i bash -c '. ~/.config/nasa-mcp/env; [ -n "$NASA_MCP_NASA__API_KEY" ] && echo set || echo empty'
3. Use it¶
-
In a shell (for
nasa-mcp --check --live, tests, recording fixtures): -
In an MCP client: use the launcher in Connect an MCP client, which sources the file when the server starts, so the key is never written into a client config.
- With Docker:
docker run --env-file ~/.config/nasa-mcp/env ....
Then check with nasa_ping (or uv run nasa-mcp --check --live): apiKey.mode is personal.
The value itself is never shown.
Quotas¶
| Key | Documented | Observed 2026-11-27 |
|---|---|---|
| Personal key | 1,000 requests/hour, rolling, shared by every api.nasa.gov API | not tested |
DEMO_KEY |
30 requests/hour and 50/day per IP | X-RateLimit-Limit: 10; after ten requests HTTP 429 with Retry-After: 79518 (about 22 hours) |
Without a key the server falls back to DEMO_KEY (nasa.demo_key_fallback, default true), and
nasa_ping adds a note saying so. When the quota is exhausted, NeoWs and InSight tools return
rate_limited with details.retryAfterS at once: the server waits out a Retry-After of at most
10 seconds and reports anything longer. With nasa.demo_key_fallback: false no key is sent, and
api.nasa.gov answers API_KEY_MISSING, reported as auth_required naming the environment
variable.
Every result that touched api.nasa.gov carries the gateway's X-RateLimit-Limit and
X-RateLimit-Remaining in _meta["io.nasa-mcp/upstream"].apiNasaGovRateLimit
({"limit": ..., "remaining": ...}), and nasa_ping reports the last values seen.
Over HTTP¶
With --transport http, callers are anonymous. The operator's key is used only when
NASA_MCP_NASA__ALLOW_KEY_IN_HTTP_MODE=true; otherwise HTTP callers get DEMO_KEY even when a key
is set. Enabling it lends the operator's hourly quota to every caller of the endpoint.
What the server does with the key¶
- It sends the key as the
api_keyquery parameter only toapi.nasa.gov, and drops it on any redirect to another host. - URLs are redacted (
api_key=***) before they reach logs,source.endpoints, error details, cache keys or test fixtures. NeoWs echoes the key inside itslinks; those are never returned. - The value is registered with the log redactor at start-up; cache keys and rate-limit buckets use
tok:plus the first 12 hex digits of its SHA-256. --print-configshows***(ornullwhen unset).
Troubleshooting¶
| Symptom | Cause and fix |
|---|---|
apiKey.mode is demo although you set a key |
The server's environment does not contain NASA_MCP_NASA__API_KEY. Run the env -i check above. If it prints empty, rewrite the file. If the client was started from a desktop launcher, use the launcher command, which sources the file itself. |
... env: line 1: NASA_MCP_NASA__API_KEY: command not found |
The line has something between the name and = (a space, or an invisible character from copy and paste). Rewrite the file with the read -rs commands, or type the line in an editor. |
The check prints set in one terminal but empty with env -i |
An older value is still exported in that terminal (for example from an earlier set -a). Run unset NASA_MCP_NASA__API_KEY and fix the file; trust the env -i result. |
printf/echo wrote an empty key |
read -rs ran in a different terminal, or was skipped. Run all the lines in one terminal. |
rate_limited with retryAfterS around 80,000 |
DEMO_KEY (or your key) is exhausted for the period. Set a personal key, or wait. |
auth_required |
api.nasa.gov rejected the key (API_KEY_INVALID): it was mistyped or revoked. Generate a new one. |
No such file or directory: scripts/... |
Commands that use repository paths must run inside the checkout (cd ~/nasa-mcp first). |