Configuration
Reference
Every environment variable and command-line flag the server reads, with its default from the code, accepted values and fallback rules.
The server has no configuration file. Everything is set with environment variables, plus one command-line flag,
--http.1 This page lists every variable that the code in src/ reads, with its default as written
in the code and what happens to a value that is blank or invalid. Invalid numeric values (PORT and the
NSF_API_* numbers) fall back to their defaults, and an empty HOST, NSF_API_BASE_URL or LOG_LEVEL gives the
default. Other values are used as given: a HOST or PORT that cannot be bound (an unresolvable host name, or a
port already in use) stops the server with exit status 1.2 3 4
5
The variables are read once, when the process starts. The NSF API client and the logger are configured when their
modules load, and the HTTP options when the HTTP server starts, so a change needs a restart.4
5 2 With a stdio client, set the variables in the env object of the client’s server
entry; see Connecting clients.
Summary
| Variable or flag | Default | Read in | Purpose |
|---|---|---|---|
--http |
Not set (stdio) | src/index.ts |
Serve Streamable HTTP instead of stdio. |
MCP_TRANSPORT |
Not set (stdio) | src/index.ts |
http serves Streamable HTTP, like --http. |
HOST |
127.0.0.1 |
src/http.ts |
HTTP bind address. |
PORT |
3000 |
src/http.ts |
HTTP listen port. |
MCP_ALLOWED_HOSTS |
localhost,127.0.0.1,[::1] on a loopback HOST; otherwise none (Host check off) |
src/http.ts |
Allowed Host header hostnames (no port) on /mcp. |
MCP_ALLOWED_ORIGINS |
localhost,127.0.0.1,[::1] |
src/http.ts |
Allowed Origin hostnames on /mcp. |
NSF_API_BASE_URL |
https://www.research.gov/awardapi-service/v1 |
src/client/nsf-api-client.ts |
Base URL of the NSF Award API. |
NSF_API_TIMEOUT_MS |
15000 |
src/client/nsf-api-client.ts |
Timeout of each request attempt, in ms; every retry gets the full value. |
NSF_API_MAX_RETRIES |
2 |
src/client/nsf-api-client.ts |
Retries after the first attempt. |
NSF_API_CACHE_TTL_MS |
300000 (5 minutes) |
src/client/nsf-api-client.ts |
Lifetime of the cached full result sets behind includeCoPIs; 0 disables the cache. |
LOG_LEVEL |
info |
src/utils/logger.ts |
Minimum log level. |
NODE_ENV |
Not set | src/utils/logger.ts |
production also writes log files. |
Defaults from src/index.ts, httpOptionsFromEnv, configFromEnv with the NSFApiClient constructor, and
src/utils/logger.ts.3 2 4 5
Transport
–http and MCP_TRANSPORT
The server serves Streamable HTTP when the command line contains --http or when MCP_TRANSPORT is exactly
http. The comparison is case-sensitive, so HTTP or any other value means stdio.3 Over stdio, the
server reads MCP messages on stdin and writes them on stdout. See Transports and
HTTP transport.
node build/index.js # stdio
node build/index.js --http # Streamable HTTP
MCP_TRANSPORT=http node build/index.js # Streamable HTTP
HTTP settings
These variables apply only in HTTP mode. They are parsed by httpOptionsFromEnv in src/http.ts.2
HOST
- Default:
127.0.0.1. An empty value also gives the default. - The address the HTTP server binds to. The loopback default accepts only local clients.1
localhost,127.0.0.1,[::1]and::1count as loopback. The loopback test decides the default ofMCP_ALLOWED_HOSTS.2- Any other non-empty value is used as given. If the server cannot bind to it, for example because the host name
does not resolve, the error reaches the
uncaughtExceptionhandler, which logsUncaught exceptionand exits with status 1.2 3
PORT
- Default:
3000. - Must be a positive integer. Any other value, such as
abc,0,-1,80.5or an empty string, falls back to3000.2 6
MCP_ALLOWED_HOSTS
- A comma-separated list of hostnames, without ports, accepted in the
Hostheader on/mcp. Each item is trimmed and empty items are dropped, so a value such as ` , ` counts as unset.2 6 - The check compares each entry with the hostname parsed from the header, so the port in the header is ignored. An
entry that includes a port, such as
nsf.example.org:8080, never matches and every request gets 403. IPv6 addresses need brackets ([::1]). The check comes fromhostHeaderValidationin the@modelcontextprotocol/nodeSDK package.2 7 - Default on a loopback
HOST:localhost,127.0.0.1and[::1]. - Default on any other
HOST(for example0.0.0.0): an empty list, which turns the Host check off. Set this variable to the public host name, or run behind a reverse proxy that sets it.2 1 - A request that fails the check gets HTTP 403. These checks protect against DNS rebinding.1
MCP_ALLOWED_ORIGINS
- A comma-separated list of
Originhostnames accepted on/mcp, parsed likeMCP_ALLOWED_HOSTS. Give bare hostnames: the check compares the hostname parsed from theOriginheader, so an entry with a scheme or port, such ashttps://app.example.org, never matches.2 7 - Default:
localhost,127.0.0.1and[::1], whateverHOSTis.2 - Requests without an
Originheader, such as non-browser clients, are accepted. A foreignOrigingets HTTP 403.1 6
The HTTP server has no CORS handling and no authentication; put a proxy in front of anything public.1 See Deployment.
NSF API client settings
configFromEnv in src/client/nsf-api-client.ts reads these variables, and the NSFApiClient constructor supplies
the defaults.4
The three numeric variables share one parsing rule: an unset or blank value, a value that is not a finite number, or
a negative value is ignored and the default applies. 0 is accepted. Fractional values are not rejected.
4 1
NSF_API_BASE_URL
- Default:
https://www.research.gov/awardapi-service/v1. An empty value also gives the default. - Every request path (
/awards.json,/awards/{id}.json,/awards/{id}/projectoutcomes.json) is relative to it. See NSF API. - The offline test suite points it at a closed local port, so an unmocked request fails instead of reaching the real API.8
NSF_API_TIMEOUT_MS
- Default:
15000(15 seconds). - The timeout of each attempt, in milliseconds. A request that times out is retried (see
NSF_API_MAX_RETRIES), and each retry gets the full timeout again. When the last attempt times out, the call fails withNSF API <operation> failed (timed out).4 9 See Errors.
NSF_API_MAX_RETRIES
- Default:
2, so at most three attempts. - Retries after the first attempt, for network errors, timeouts, HTTP 429 and HTTP 5xx. Each retry gets the full
NSF_API_TIMEOUT_MS. Cancelled requests are never retried.0disables retries.4 1 9 - The backoff starts at 1000 ms and doubles for each retry (1000 ms, 2000 ms, …). The 1000 ms base is fixed in the code; no variable sets it.4
NSF_API_CACHE_TTL_MS
- Default:
300000(5 minutes). - How long the two full result sets behind a
search_by_picall withincludeCoPIs: true(the PI search and the Co-PI search) stay cached, in milliseconds, so paging through the merged list does not fetch them again.0disables the cache. No other call is cached.4 1 - The cache keeps at most about 100 entries; expired entries are removed when a new one is added, and failed fetches are never cached.4 See search_by_pi and NSF API client.
Logging
All logs go to stderr, never stdout, because stdout carries the MCP protocol in stdio mode.5 10
LOG_LEVEL
- Default:
info. An empty value also gives the default. - The value is not validated and is case-sensitive. An unrecognized value such as
INFOorlouddoes not fall back toinfo: it turns off all console (stderr) output, errors included. WithNODE_ENV=production,logs/error.logstill records errors, because that file transport sets its ownerrorlevel;logs/combined.logstays empty.5 - The minimum level of the winston logger. README.md and INSTALL.md list
error,warn,infoanddebug; the logger also sendsverboseto stderr.5 10 1 debugadds a line for every NSF API request, with its URL and parameters, and for every retry.4
NODE_ENV
- Default: not set.
- When it is exactly
production, the logger also writes two files, relative to the working directory:logs/error.log(levelerroronly) andlogs/combined.log(every level that passesLOG_LEVEL). Each file rotates at 5242880 bytes (5 MB) and keeps at most 5 files.5 - No other code in
src/readsNODE_ENV.
Where the defaults are overridden
| File | Settings |
|---|---|
Dockerfile |
NODE_ENV=production, LOG_LEVEL=info, HOST=0.0.0.0, PORT=3000; the default command serves stdio11 |
docker-compose.yml |
NODE_ENV=production, MCP_TRANSPORT=http, HOST=0.0.0.0, LOG_LEVEL from the shell (default info); the nsf-awards-mcp-dev service (profile dev) sets NODE_ENV=development, MCP_TRANSPORT=http, HOST=0.0.0.0, LOG_LEVEL=debug12 |
docker-compose.override.yml |
Loaded automatically by docker compose up; overrides the nsf-awards-mcp service with NODE_ENV=development, MCP_TRANSPORT=http, HOST=0.0.0.0, LOG_LEVEL=debug, DEBUG=* and runs npm run dev13 1 |
.mcp.json |
NODE_ENV=production, LOG_LEVEL=info for the stdio server that Claude Code starts in this repository14 |
deployment/systemd/nsf-awards-mcp.service |
NODE_ENV=production, LOG_LEVEL=info, MCP_TRANSPORT=http, PORT=3000; HOST is left at 127.0.0.1 for the nginx proxy, and MCP_ALLOWED_HOSTS is commented out, so requests that carry the public Host header get 403 until it is set15 |
deployment/gcp/cloud-run.yaml |
NODE_ENV=production, LOG_LEVEL=info, PORT=3000, MCP_TRANSPORT=http, HOST=0.0.0.0; MCP_ALLOWED_HOSTS is commented out16 |
deployment/gcp/deploy.sh, deployment/aws/cloudformation.yaml |
NODE_ENV=production, LOG_LEVEL=info, MCP_TRANSPORT=http, on top of the image’s HOST and PORT17 18 |
tests/setup.ts |
NODE_ENV=test, LOG_LEVEL=error; without NSF_LIVE=1, also NSF_API_BASE_URL=http://127.0.0.1:9/awardapi-service/v1, NSF_API_MAX_RETRIES=0 and NSF_API_TIMEOUT_MS=20008 |
Because the Docker image sets HOST=0.0.0.0, the Host check is off in a container that runs in HTTP mode unless
MCP_ALLOWED_HOSTS is set.11 2 NSF_LIVE is read only by the test suite, not by the
server.8
Examples
Run over HTTP on all interfaces behind a proxy that forwards the public host name:
MCP_TRANSPORT=http HOST=0.0.0.0 PORT=8080 \
MCP_ALLOWED_HOSTS=nsf.example.org \
node build/index.js
A stdio client entry with a longer timeout and debug logging:
{
"mcpServers": {
"nsf-awards": {
"command": "node",
"args": ["/absolute/path/to/nsf-awards-mcp/build/index.js"],
"env": { "NSF_API_TIMEOUT_MS": "30000", "LOG_LEVEL": "debug" }
}
}
}
-
Streamable HTTP transport and httpOptionsFromEnv ↩ ↩2 ↩3 ↩4 ↩5 ↩6 ↩7 ↩8 ↩9 ↩10 ↩11 ↩12 ↩13
-
NSF Award API client and configFromEnv ↩ ↩2 ↩3 ↩4 ↩5 ↩6 ↩7 ↩8 ↩9 ↩10 ↩11
-
Docker Compose services ↩
-
Docker Compose development override ↩
-
Claude Code project server registration ↩
-
systemd service unit ↩
-
Cloud Run service definition ↩
-
Cloud Run deploy script ↩
-
AWS CloudFormation template ↩