Errors

Reference

How tool calls, resource reads and HTTP requests fail, with the exact error messages the server and its NSF API client produce and which failures are retried.

Status
stable
Trust tier
unverified
Generated
claude-code/claude-opus-5-5, 2026-12-05
Tags
errorstroubleshootingretriesvalidation

The server reports failures on three channels. A failed tool call comes back as a normal result with isError: true and the message as text, so the model can read it and try again. A failed resource read is a JSON-RPC error. A request that the HTTP transport refuses gets an HTTP error status before it reaches MCP. 1 2

This page lists each kind of failure and its exact message. Messages written as <name> contain a value from the request or the response. For problems with installing or connecting the server, see Troubleshooting.

Tool error results

A tool call can fail in three places, and all three give the same result shape:

  1. The SDK validates the arguments against the tool’s input schema before the handler runs (input validation).
  2. The handler throws: a missing award or report, or an error from the NSF API client (not found, NSF API errors).
  3. The SDK validates the handler’s data against the tool’s output schema (output validation).

For a thrown error, the registered callback in src/server.ts catches it and returns:1

{
  "content": [{ "type": "text", "text": "<error message>" }],
  "isError": true
}

The result has exactly one text item and no structuredContent, and search errors get no paging hint.3 The server also logs Tool call failed at warn level to stderr, with the tool name, the message and the elapsed milliseconds.1

Input validation errors

Arguments are checked before any API call, so these errors cost no request.4 3 The SDK formats the message; USAGE.md shows this example:4

Input validation error: Invalid arguments for tool search_nsf_awards: startDateTo: startDateFrom (12/31/2024) is after startDateTo (01/01/2020)

The server’s own validation messages are:5

Check Applies to Message
Date does not parse Every date argument (startDateFrom, startDateTo, expDateFrom, expDateTo, dateStart, dateEnd) Invalid date: expected mm/dd/yyyy or yyyy-mm-dd
Date range reversed The pairs startDateFrom/startDateTo, expDateFrom/expDateTo, dateStart/dateEnd <fromKey> (<from>) is after <toKey> (<to>), with both dates shown as mm/dd/yyyy; reported on the <toKey> path
Amount range reversed The pairs estimatedTotalAmtFrom/estimatedTotalAmtTo, fundsObligatedAmtFrom/fundsObligatedAmtTo <fromKey> (<from>) is greater than <toKey> (<to>); reported on the <toKey> path
Award ID not numeric awardId of get_award_details and get_project_outcomes (1 to 10 digits after trimming) Award IDs are numeric (e.g. 2632685)
Odd number of double quotes keyword of search_nsf_awards keyword has an unmatched double quote
Unbalanced parentheses keyword of search_nsf_awards keyword has an unmatched parenthesis
More than one quoted phrase keyword of search_nsf_awards keyword can hold only one quoted phrase (the NSF API reads everything from the first quote to the last as one phrase); quote one phrase and join other words with AND, e.g. "wildfire smoke" AND health

The keyword checks catch syntax the API mishandles: an unmatched quote or parenthesis fails upstream with a generic AwardAPI-004 notice, and two quoted phrases are read as one phrase from the first quote to the last, so they silently match almost nothing.5

Other checks use the schema library’s standard messages, which name the argument: limit outside 1 to 25, offset outside 0 to 9999 or not an integer, a negative amount, a status or detail value outside its enum, a missing required argument (institutionName, lastName, awardId), and an institutionName, lastName or firstName that is empty after trimming.5 3 The parameters themselves are described in Shared search parameters and on each tool’s page.

Not-found errors

The lookup tools throw NotFoundError (defined in src/tools/shared.ts) when the API has no data:6

Tool Message
get_award_details No NSF award found with ID <awardId>
get_project_outcomes No Project Outcomes Report for award <awardId>: the award does not exist, is still active, or predates outcome reports

Sources: the two tool handlers.7 8 The API reports a missing award as HTTP 200 with an empty award list, not a 404, and only that empty list counts as “not found”.9 An HTTP 404 means the API has moved or broken, so the client reports it as an NSF API client error (NSF API award lookup failed (HTTP 404)), without a retry.10

NSF API client errors

src/client/nsf-api-client.ts turns every upstream failure into an Error with one of these messages, which the tool result then carries unchanged.10 The <operation> is search for searches (including both search_by_pi merges), award lookup for get_award_details and the award resource, and project outcomes lookup for get_project_outcomes and the outcomes resource.

Cause Message
The API rejected the request with an HTTP 200 serviceNotification of type ERROR or FATAL <notificationCode>: <notificationMessage>; several notices are joined with ;
HTTP error status, after retries (only 429 and 5xx are retried; a 404 is an error too, never “not found”) NSF API <operation> failed (HTTP <status>)
Timeout, after retries (each attempt gets the full NSF_API_TIMEOUT_MS; see Retries) NSF API <operation> failed (timed out)
Network failure without a response, after any retries (some are not retried; see Retries) NSF API <operation> failed (<axios error message>), or (network error) when the error has no message
The request was cancelled NSF API <operation> was cancelled
The caller’s cancellation while waiting for a shared includeCoPIs fetch NSF API search was cancelled
The response body is neither an object nor a string Unexpected NSF API response format
The parsed body has no response object (an HTML error page, {}, a proxy’s JSON error) Unexpected NSF API response (no "response" object, content-type <type>); the content-type part is left out when the reply has none
The body is not JSON or XML, or parses to null Failed to parse NSF API response
search_by_pi with includeCoPIs matches more than 250 awards on one side Search matches <total> awards, more than the 250 that can be merged; narrow it (e.g. add firstName, institution, stateCode or a date range)
A date filter that does not parse reaches the client Invalid date for <field>: <value> (expected mm/dd/yyyy or yyyy-mm-dd), where <field> is the API name, such as startDateStart

Notes:

  • Service notifications. The API reports rejected parameters as HTTP 200 with response.serviceNotification, for example AwardAPI-002 Invalid parameter(s). The client throws for notices whose notificationType is ERROR or FATAL (any case) and ignores other types.10 9 The live fixture produces this message:11

    AwardAPI-002: Invalid parameter(s) sent in the request. Invalid Parameter(s) {awardeeOrganization}
    

    The tools send only parameter names that were verified against the live API, so from a tool call this error most likely means the API changed.9 See Search parameters.

  • AwardAPI-004. A page that reaches past record 10,000 returns no records and a FATAL notice. The client shortens such pages to end at record 10,000, so the tools should not trigger it.10 9 See Paging and limits.
  • Invalid dates. The input schemas run the same date check first, so tool callers get the input validation message instead; the client check guards other callers.5 10
  • Merge limit. The check runs on the first page of each of the two searches, before the rest is downloaded. A failure of either search fails the call.10 3 See search_by_pi.
  • The client logs NSF API request failed at error level, with the operation, the status and the URL, for HTTP, timeout and network failures.10

Output validation errors

The SDK checks structuredContent against the tool’s output schema. The schemas are loose, but a field they name must have the declared type. Data that fails, such as an amount that arrives as the string "1498027", turns the call into an isError result whose text contains Output validation error and the failing path, for example award.estimatedTotalAmt.3 5 Because the client normalizes every record, this error means that the upstream data changed. See Award record.

Retries

The client retries a failed request with exponential backoff before it reports one of the errors above:10 12

Retried Not retried
Network errors without a response (except those listed as not retried), timeouts (ECONNABORTED), HTTP 429, HTTP 5xx Cancelled requests, other HTTP 4xx (including 404), serviceNotification errors and bodies without a response object (they arrive as HTTP 200), network errors that axios-retry treats as permanent: DNS lookup failures (ENOTFOUND), an unreachable network (ENETUNREACH), TLS certificate errors (such as CERT_HAS_EXPIRED), and errors without an error code
  • The number of retries after the first attempt is NSF_API_MAX_RETRIES (default 2), so a request makes at most three attempts by default.
  • The delay before retry n is 1000 ms × 2^(n-1): 1000 ms, then 2000 ms. The 1000 ms base has no environment variable.
  • Each attempt gets the full NSF_API_TIMEOUT_MS (default 15000): the client sets axios-retry’s shouldResetTimeout, so a slow attempt does not use up the time of the next one.10 13
  • Network errors are tested with axios-retry’s isNetworkError, which uses the is-retry-allowed deny list, so the permanent failures in the table fail on the first attempt.10 13
  • Timeouts (ECONNABORTED) are retried like network errors. With the defaults, a request that keeps timing out fails after three attempts of 15 s plus 1 s and 2 s of backoff, about 48 s, with NSF API <operation> failed (timed out).10

See Configuration and NSF API client.

Resource read errors

Reads of nsf://award/{id} and nsf://award/{id}/outcomes fail with a JSON-RPC error, not an isError result.1

Case Message
Award not found, or an id that is not all digits No NSF award with ID <id>
No outcomes report, or an id that is not all digits No Project Outcomes Report for award <id>

Both are ResourceNotFoundErrors; the tests observe JSON-RPC code -32602 for the missing award.3 Note that these messages differ from the tools’ not-found messages. Upstream failures during a read throw the NSF API client errors above.

HTTP transport errors

With the Streamable HTTP transport, src/http.ts answers some requests itself: 2 14 12

Request Status Body
/mcp with a Host header not in the allow-list 403 A JSON-RPC error object; the tests observe error.code -32000
/mcp with an Origin header not in the allow-list 403 Same as above
Any path other than /mcp and /health 404 {"error":"Not found; the MCP endpoint is /mcp"}
/health with a method other than GET 405 {"status":"ok","version":"<version>"} (the same body as a GET)

The query string is ignored when the path is matched. /health is answered before the Host and Origin checks. The allow-lists come from HOST, MCP_ALLOWED_HOSTS and MCP_ALLOWED_ORIGINS; see Configuration. Requests without an Origin header, such as non-browser clients, are accepted.12

The Host check runs only when the host allow-list is non-empty. That list is MCP_ALLOWED_HOSTS, or the localhost names when HOST is a loopback address (localhost, 127.0.0.1, ::1 or [::1]). Binding to any other address without MCP_ALLOWED_HOSTS turns the check off, so no request gets the Host 403. The Origin allow-list always has a value: MCP_ALLOWED_ORIGINS, or by default localhost, 127.0.0.1 and [::1].2

Examples

A missing award through the tool:3

{
  "content": [{ "type": "text", "text": "No NSF award found with ID 9999999" }],
  "isError": true
}

An upstream outage after retries:3

NSF API award lookup failed (HTTP 503)

A timeout in one of the two includeCoPIs searches:3

NSF API search failed (timed out)
  1. MCP server factory, tool registration and resource templates ↩ ↩2 ↩3 ↩4

  2. Streamable HTTP transport ↩ ↩2 ↩3

  3. In-process MCP protocol tests ↩ ↩2 ↩3 ↩4 ↩5 ↩6 ↩7 ↩8 ↩9

  4. User guide ↩ ↩2

  5. Tool input and output schemas ↩ ↩2 ↩3 ↩4 ↩5

  6. Shared tool helpers (NotFoundError) ↩

  7. get_award_details tool handler ↩

  8. get_project_outcomes tool handler ↩

  9. Live API behaviour notes in CLAUDE.md ↩ ↩2 ↩3 ↩4

  10. NSF Award API client ↩ ↩2 ↩3 ↩4 ↩5 ↩6 ↩7 ↩8 ↩9 ↩10 ↩11

  11. Live AwardAPI-002 response fixture ↩

  12. Installation guide ↩ ↩2 ↩3

  13. Locked dependency versions (axios-retry 4.5.0, is-retry-allowed 2.2.0) ↩ ↩2

  14. Streamable HTTP transport tests ↩

Sources

  1. MCP server factory, tool registration and resource templates server-source
  2. NSF Award API client api-client
  3. Tool input and output schemas tool-schema
  4. Shared tool helpers (NotFoundError) shared-source
  5. get_award_details tool handler award-details-tool
  6. get_project_outcomes tool handler outcomes-tool
  7. Streamable HTTP transport http-source
  8. In-process MCP protocol tests server-tests
  9. Streamable HTTP transport tests http-tests
  10. Live AwardAPI-002 response fixture invalid-parameter-fixture
  11. User guide usage-guide
  12. Installation guide install-guide
  13. Live API behaviour notes in CLAUDE.md api-behaviour
  14. Locked dependency versions (axios-retry 4.5.0, is-retry-allowed 2.2.0) axios-retry