Error classes
@frontmcp/sdk exports an error class for most things that can go wrong, from a model sending bad arguments to a provider that can't be built. This page groups them by area; a few other exported classes aren't listed. Each one has a string code, which clients receive, and is either public, so its message reaches the client in production, or internal, so production replaces it with an error ID. A handful are for you to fail with. Most are what FrontMCP throws itself, and knowing them tells you what a client saw and why. For how to fail a call, see this.fail(); for every code a client can receive, see Error codes.
this.fail(new PublicMcpError(message, code?, statusCode?))
throw new InvalidInputError(message?, details?)
Reference
McpError
Every FrontMCP error extends the abstract McpError, itself an Error, except the guard's errors and @frontmcp/auth's internal ones (see below).
| Member | Type | Description |
|---|---|---|
code | string | What kind of error it is, like "INVALID_INPUT". Clients get it as a tool result's _meta.code, or as data.code in a JSON-RPC error. |
isPublic | boolean | Whether the message may reach clients in production. |
statusCode | number | An HTTP-style status. It picks the JSON-RPC code for resources and prompts; a tool result is always HTTP 200. |
errorId | string | err_ and 16 hex digits, new for every error. Clients get it in _meta.errorId or data.errorId, and FrontMCP logs it with the error, so a user's report can be found in the log. |
message | string | The message as written, for your logs. |
getPublicMessage() | string | What a production client reads. |
getInternalMessage() | string | What a development client reads in a tool result. |
toMcpError(isDevelopment?) | CallToolResult | The isError tool result for this error. |
PublicMcpError(message, code?, statusCode?, wwwAuthenticate?, remedy?)
The error to fail with when the model should read the message. code defaults to "PUBLIC_ERROR", and statusCode to 400. wwwAuthenticate is only used on FrontMCP's own HTTP endpoints. remedy is { say, tool?, args? }: tool results append a To fix: line and include _meta.remedy. refused(message, { code?, status?, remedy? }) is the shorthand for code "REFUSED", status 403. New in 1.11.0: remedy and refused(). Subclass it for errors of your own:
export class TicketArchivedError extends PublicMcpError {
constructor(id: string) {
super(`Ticket ${id} is archived. Ask a lead to restore it.`, "TICKET_ARCHIVED", 409);
}
}
InternalMcpError(message, code?)
An error whose message must not leave the server. code defaults to "INTERNAL_ERROR", and statusCode is 500. Production clients get Internal FrontMCP error. Please contact support with error ID: err_…; the message goes to the log.
What the client receives
From a tool
A tool that fails, with this.fail() or by throwing, answers with a normal result: isError: true, the text, and _meta with errorId, code, timestamp, and in development, stack.
_meta.codeis the error'scode.this.fail()passes everyMcpErrorthrough as it is. A thrown error keeps its code too if it's public.- A thrown error that is neither public nor an auth error is wrapped as
ToolExecutionError: codeTOOL_EXECUTION_ERROR, textTool "…" execution failed:and the message. Passed tothis.fail(), the sameInternalMcpErrorkeeps its code, and a plainErrorbecomesSERVER_ERROR. See it run. - The text is
getInternalMessage()in development andgetPublicMessage()in production. For most public errors they're the same; the few that differ are marked below. - A few refusals are JSON-RPC errors instead, all before
execute()runs: a thrownToolCredentialsRequiredError(-32001, withdata.authUrl); for clients before MCP 2026-07-28,TaskAugmentationNotSupportedErrorandTaskAugmentationRequiredError(-32601); and under 2026-07-28, a call to a tool withexecution.taskSupport: "required"from a client that didn't declare the tasks extension (-32602,Tool "…" runs as a task; declare the io.modelcontextprotocol/tasks extension in clientCapabilities).
From a resource or a prompt
resources/read and prompts/get answer with a JSON-RPC error. Its message is getPublicMessage(), except that an internal error's message is kept in development, and data holds errorId and code. The JSON-RPC code comes from the class:
| Error | JSON-RPC code |
|---|---|
| A class with its own JSON-RPC mapping (marked "own" below) | Its own code, and its own data, without code |
Public, statusCode 401 | -32001 |
Public, statusCode 403 | -32003 |
Public, statusCode below 500 | -32602 |
Public, statusCode 500 or more | -32603, with the message kept |
| Internal | -32603 |
A thrown error that is neither public nor an auth error is wrapped, as ResourceReadError (Resource "…" read failed: ) or PromptExecutionError (Prompt execution failed: ). See it run.
From an events request
New in 1.12.0. events/poll, events/stream, events/subscribe and events/unsubscribe answer with a JSON-RPC error. A refusal the events protocol names is one of the five EventProtocolError classes below, which carry their own JSON-RPC code and data: the code is the SEP-3415 one, or the earlier design's for an OpenAI client. Arguments that don't match the event's inputSchema are an InvalidInputError, -32602. An event's authorize() that throws a PublicMcpError becomes an EventForbiddenError with that message as data.reason; any other error it throws becomes one with the reason the event refused it, in development too.
Before any handler
A few refusals happen before FrontMCP knows what the request is for. They're HTTP errors with a JSON-RPC body, and no error class of yours is involved: throttle.global gives HTTP 429 and -32029, throttle.ipFilter HTTP 403 and -32001 (see Guard options), and a body over http.bodyLimit gives HTTP 413 and -32600, Payload Too Large, on the Node HTTP server and the fetch handler. Limits above 4 MiB apply on Workers and edge runtimes too; see body size limits.
In production
With NODE_ENV=production, a public error's message is sent, and an internal error's is replaced with Internal FrontMCP error. Please contact support with error ID: err_…; InvalidOutputError says Output validation failed. Please contact support. instead. No stack is sent. The Playground runs in development, so the examples below format errors the way production does with createErrorHandler({ isDevelopment: false }).
Errors that aren't McpErrors
- An ordinary
Error, like aTypeErroror a driver's error, is internal. Passed tothis.fail(), it becomes aGenericServerError, codeSERVER_ERROR; in development the text addsOriginal error:and the stack. - The guard's errors (
ExecutionTimeoutError,ConcurrencyLimitErrorand the rest) extendGuardError, notMcpError. Passed tothis.fail(), they keep their code and message, as public errors. Thrown, onlyExecutionTimeoutErrorkeeps its code in a tool; the others are wrapped. In a resource or prompt, all of them are wrapped when thrown, like any error that isn't public. @frontmcp/auth's errors extendAuthInternalErrorand retain their own code. Non-public messages are hidden in production; public subclasses keep theirs. Changed in 1.11.3: before, auth errors were wrapped with generic codes.AuthorityDeniedError, from@frontmcp/auth, is howauthoritiesrefuses a call. Clients get codeAUTHORITY_DENIED, and its message is kept in production.
Live entries, jobs and local server errors
New in 1.11.0. These classes are exported by @frontmcp/sdk, except secure-store errors (@frontmcp/auth), observability errors (@frontmcp/observability) and result-handle errors (@frontmcp/plugin-result-handles). "Public" means the message reaches clients; internal startup errors stay in the server log.
Live surface and aliases
| Class | Code | Visibility | Meaning |
|---|---|---|---|
FeatureOffError | FEATURE_OFF | Public | An entry is turned off. Reference. |
StaleToolListError | STALE_TOOL_LIST | Public | List tools again; the session used an older surface. Reference. |
ToolAliasConflictError | TOOL_ALIAS_CONFLICT | Internal | An alias is another tool's name or alias. Reference. |
InvalidFileSignalError | INVALID_FILE_SIGNAL | Internal | A file signal needs a path, key and positive poll interval. Reference. |
HookOrderCycleError | HOOK_ORDER_CYCLE | Internal | Remove a before/after constraint in the reported cycle. Reference. |
InvalidResourceStoreError | INVALID_RESOURCE_STORE | Internal | Invalid resource-store options, key or missing from. Reference. |
LazyAppConfigurationError | LAZY_APP_CONFIGURATION_ERROR | Internal | A lazy app or its manifest cannot be used. Reference. |
LazyAppLoadError | LAZY_APP_LOAD_FAILED | Public | An app could not load; inspect retryable and the server log. Reference. |
Job runs
| Class | Code | Visibility | Meaning |
|---|---|---|---|
JobTimeoutError | JOB_TIMEOUT | Public | An attempt exceeded its deadline. Reference. |
JobCancelledError | JOB_CANCELLED | Public | A run was cancelled. Reference. |
JobInterruptedError | JOB_INTERRUPTED | Public | The server shut down or its runner disappeared. Reference. |
JobRunnerUnavailableError | JOB_RUNNER_UNAVAILABLE | Public | This runtime, entry or store cannot support the runner. Reference. |
JobRunnerBootError | JOB_RUNNER_BOOT_FAILED | Public | The detached process failed before taking over. Reference. |
JobAdmissionTimeoutError | JOB_ADMISSION_TIMEOUT | Public | Admission capacity did not become available in time. Reference. |
JobRunNotFoundError | JOB_RUN_NOT_FOUND | Public | Cancellation cannot find a run the caller may access. Reference. |
JobRunFinishedError | JOB_RUN_FINISHED | Public | A finished run cannot be cancelled. Reference. |
JobRunNotCancellableError | JOB_RUN_NOT_CANCELLABLE | Public | cancel_job does not cancel workflows. Reference. |
JobStoreNotSupportedError | JOB_STORE_NOT_SUPPORTED | Internal | Use Redis or SQLite for job stores, not Vercel KV. Reference. |
Offload
| Class | Code | Visibility | Meaning |
|---|---|---|---|
OffloadBudgetExceededError | OFFLOAD_BUDGET_EXCEEDED | Public | The worker exceeded its budget and was terminated. Reference. |
OffloadAbortedError | OFFLOAD_ABORTED | Public | Cancellation or shutdown terminated the worker. Reference. |
OffloadUnsupportedRuntimeError | OFFLOAD_UNSUPPORTED_RUNTIME | Internal | Worker threads require Node. Reference. |
InvalidOffloadCallError | INVALID_OFFLOAD_CALL | Internal | Invalid function reference or offload options. Reference. |
OffloadNotCloneableError | OFFLOAD_NOT_CLONEABLE | Internal | Arguments or result cannot cross structured clone. Reference. |
OffloadWorkerError | OFFLOAD_WORKER_FAILED | Internal | A worker crashed or exited before answering. Reference. |
Persistent questions
| Class | Code | Visibility | Meaning |
|---|---|---|---|
QuestionPendingError | QUESTION_PENDING | Public | The question remains in the inbox; call again for its answer. Reference. |
QuestionSupersededError | QUESTION_SUPERSEDED | Public | A newer call waits for this caller's same question. Reference. |
QuestionNotFoundError | QUESTION_NOT_FOUND | Public | No question with that id is waiting for this person. Reference. |
QuestionAlreadyAnsweredError | QUESTION_ALREADY_ANSWERED | Public | The first answer has already been recorded. Reference. |
QuestionStoreBusyError | QUESTION_STORE_BUSY | Internal | Concurrent writes prevented the question update. Reference. |
InvalidQuestionStoreError | INVALID_QUESTION_STORE | Internal | The persistent-question store is unavailable or unsupported. Reference. |
HTTP routes and people auth
| Class | Code | Visibility | Meaning |
|---|---|---|---|
InvalidHttpRouteError | INVALID_HTTP_ROUTE | Internal | A duplicate route, an unusable path returned by a path function, an SSE route on the MCP path, a class that isn't an @HttpRoute, or a signed-in (people/subject) route with no http.auth.people. A reserved path fails with ReservedRouteCollisionError instead, and a bad literal path fails at the decorator with INVALID_DECORATOR_METADATA. Reference. |
InvalidPeopleAuthOptionsError | INVALID_PEOPLE_AUTH_OPTIONS | Internal | Correct the named http.auth.people fields. Reference. |
PersonNotSignedInError | PERSON_NOT_SIGNED_IN | Public | Sign in with a code for this route's auth kind. Reference. |
CrossOriginRequestError | CROSS_ORIGIN_REQUEST | Public | A mutating route request came from another origin. Reference. |
SignInRefusedError | SIGN_IN_REFUSED | Public | The sign-in token or code is wrong, used or expired. Reference. |
SignInLockedError | SIGN_IN_LOCKED | Public | Too many failed sign-in attempts; wait a minute, then try again. Reference. |
Lifecycle, local processes and builds
| Class | Code | Visibility | Meaning |
|---|---|---|---|
ProviderBootstrapError | PROVIDER_BOOTSTRAP_FAILED | Internal | A provider failed in onBootstrap(). Reference. |
DutyNameConflictError | DUTY_NAME_CONFLICT | Internal | Two duty classes share a name within one server. Reference. |
WorkerNameConflictError | WORKER_NAME_CONFLICT | Internal | Two worker classes share a name within one server. Reference. |
InvalidDutyCronError | INVALID_DUTY_CRON | Internal | Unreadable duty cron expression. Reference. |
ClusterScopeNeedsRedisError | CLUSTER_SCOPE_NEEDS_REDIS | Internal | A cluster duty or worker has no usable Redis. Reference. |
WorkflowTriggerConfigError | INVALID_WORKFLOW_TRIGGER | Internal | Invalid webhook, event or schedule trigger. Reference. |
UnsafeDutyStoreError | UNSAFE_DUTY_STORE | Internal | Duty lease storage has unsafe ownership or permissions. Reference. |
InvalidSharedServerOptionsError | INVALID_SHARED_SERVER_OPTIONS | Internal | Correct the named runShared() options. Reference. |
UnsafeSharedServerDirectoryError | UNSAFE_SHARED_SERVER_DIRECTORY | Internal | Use owner-only shared-server files and directories. Reference. |
SharedServerStartError | SHARED_SERVER_START_FAILED | Internal | The shared server could not start or prove its identity in time. Reference. |
SharedServerIdentityError | SHARED_SERVER_IDENTITY_REFUSED | Internal | The endpoint failed shared-server identity verification. Reference. |
BrowserStoreUnavailableError | BROWSER_STORE_UNAVAILABLE | Internal | A browser cannot open the listed Redis or SQLite stores. Reference. |
BrowserEntryPointUnavailableError | BROWSER_ENTRY_POINT_UNAVAILABLE | Internal | runShared() and runUnixSocket() require Node. Reference. |
StoreNotOpenedInBuildError | STORE_NOT_OPENED_IN_BUILD | Internal | A manifest build tried to use a store stand-in. Reference. |
CallRecorderConfigurationError | CALL_RECORDER_CONFIGURATION_ERROR | Internal | Correct invalid recorder options. Reference. |
SecureStoreConfigError | SECURE_STORE_CONFIG_INVALID | Auth internal | An auth.secureStore backing cannot be used. Reference. |
ObservabilityConfigurationError | OBSERVABILITY_CONFIGURATION | Internal | Correct invalid stalls or devEvents options. Reference. |
Result handles
| Class | Code | Visibility | Meaning |
|---|---|---|---|
ResultHandleNotFoundError | RESULT_HANDLE_NOT_FOUND | Public | A handle is unknown, expired or belongs to another caller. Reference. |
ResultPathNotFoundError | RESULT_PATH_NOT_FOUND | Public | Choose a dot path or JSON pointer listed in the result shape. Reference. |
ResultSliceTooLargeError | RESULT_SLICE_TOO_LARGE | Public | Request fewer items, fields or a deeper path. Reference. |
ResultHandlesConfigurationError | RESULT_HANDLES_CONFIGURATION | Internal | Correct invalid plugin options. Reference. |
Events, duties and workers
New in 1.12.0. @frontmcp/sdk exports these classes. Error codes has the same list by code, with the messages.
Events requests
The five extend EventProtocolError, an abstract PublicMcpError with jsonRpcCode, data and toJsonRpcError(). FrontMCP's events flows throw them. Each constructor takes the codes of the caller's dialect first, so your code doesn't build one: to refuse a caller from an event's authorize(), throw a PublicMcpError.
| Class | code | JSON-RPC | statusCode | data |
|---|---|---|---|---|
EventNotFoundError(codes, kind, name) | EVENT_NOT_FOUND | own: -32023, or -32011 | 404 | { kind, name }, kind being "event" or "subscription" |
EventForbiddenError(codes, name, reason) | EVENT_FORBIDDEN | own: -32024, or -32012 | 403 | { reason } |
EventResourceExhaustedError(codes, limit, max) | EVENT_RESOURCE_EXHAUSTED | own: -32025, or -32013 | 429 | { limit, max }, limit being "subscriptions", "pollLeases", "streams" or "verifications" |
EventUnsupportedError(codes, feature, value, supported) | EVENT_UNSUPPORTED | own: -32026, or -32014 | 400 | { feature, value, supported } |
EventCallbackEndpointError(codes, reason) | EVENT_CALLBACK_ENDPOINT_ERROR | own: -32027, or -32015 | 400 | { reason }, a category like challenge_failed |
The statusCode isn't the HTTP status: over HTTP these errors arrive with 200. EventErrorCodes is the type of codes.
Publishing, clients and background work
| Class | code | Production | Who throws it |
|---|---|---|---|
EventNameConflictError(eventName) | EVENT_NAME_CONFLICT | Hidden | FrontMCP, at startup, for two events with one name on an endpoint. |
EventsNotEnabledError() | EVENTS_NOT_ENABLED | Hidden | publish(), on a server without events. From server.events.publish() it's what the promise rejects with. |
EventNotRegisteredError(eventName) | EVENT_NOT_REGISTERED | Hidden | publish(), for an event no app lists in this environment. |
InvalidEventPublishError(eventName, problem) | INVALID_EVENT_PUBLISH | Hidden | publish(), for data that doesn't match payloadSchema; a poll, for a check() that returned more events than asked for. |
EventSubscriptionStoreError(message) | EVENT_SUBSCRIPTION_STORE | Hidden | FrontMCP, at startup, when events.store can't be opened or has no secret to encrypt with. |
EventPublishEndpointError(message) | EVENT_PUBLISH_ENDPOINT | Hidden | FrontMCP, at startup, when events.publishEndpoint can't be served as configured. |
EventRequestError(method, rpcCode, message, data?) | EVENT_REQUEST_FAILED | Kept | An events client, for a request the server refused. statusCode 400. |
NoCompatibleDeliveryModeError(eventName, offered, usable) | NO_COMPATIBLE_DELIVERY_MODE | Kept | An events client's subscribe(). statusCode 400. |
DuplicateEventSubscriptionError(eventName, url) | DUPLICATE_EVENT_SUBSCRIPTION | Kept | An events client's subscribe(), for a second webhook subscription to one event and arguments. statusCode 409. |
EventSubscriptionTerminatedError(eventName, error) | EVENT_TERMINATED | Kept | The iteration of an events client's subscription that the server ended. statusCode 410; error is the server's. |
InvalidDutyCronError(dutyName, expression, reason) | INVALID_DUTY_CRON | Hidden | A @Duty with a cron that can't be read, as it starts. Startup rejects with a ProviderBootstrapError whose originalError is this one. |
ClusterScopeNeedsRedisError(subject) | CLUSTER_SCOPE_NEEDS_REDIS | Hidden | A duty or a @Worker with scope: "cluster" on a server without a top-level redis. Wrapped in a ProviderBootstrapError, like the one above. |
WorkerNameConflictError(workerName, serverName, firstClass, secondClass) | WORKER_NAME_CONFLICT | Hidden | The second of two @Worker classes with one name in a server, whatever their scopes, in its onReady(). The server logs it and keeps running; createContainer() rejects with it. DutyNameConflictError is the same for a @Duty. |
A tool that throws one of the hidden classes, by not catching a failed this.events.publish(), answers TOOL_EXECUTION_ERROR, like any internal error it throws. Each class was checked by provoking it on FrontMCP 1.12, in Node, except EventSubscriptionTerminatedError, which was built by hand.
Helper functions
| Function | What it does |
|---|---|
isPublicError(error) | true for an McpError with isPublic. false for guard errors and AuthorityDeniedError, which FrontMCP still sends as public. |
isClientFacingError(error) | isPublicError(), or an AuthorityDeniedError. |
toMcpError(error) | The McpError FrontMCP would send for error: an McpError as it is, a guard error as a public GuardLimitMcpError with the same code, anything else as a GenericServerError. |
formatMcpErrorResponse(error, isDevelopment?) | The isError tool result for error. isDevelopment defaults to NODE_ENV !== "production". |
createErrorHandler({ isDevelopment?, logger?, errorTransformer? }) | An ErrorHandler: handle(error, context?) formats a tool result as tools/call does (and logs it with logger); wrap(fn) makes a function throw McpErrors only. |
extractPublicMessage(error) | The most specific message in an error's cause chain. FrontMCP doesn't use it. |
shouldStopExecution(error) | Whether an error ends a flow: true except for a FlowControl that responds or continues. |
MCP_ERROR_CODES | The JSON-RPC codes: UNAUTHORIZED -32001, RESOURCE_NOT_FOUND -32002, FORBIDDEN -32003, INVALID_REQUEST -32600, METHOD_NOT_FOUND -32601, INVALID_PARAMS -32602, INTERNAL_ERROR -32603, PARSE_ERROR -32700. |
The classes
The tables give each class's code, the JSON-RPC code a resource or prompt gets for it (a tool gets the code in _meta.code, as above), whether its message is kept in production, and who throws it. Unless a table says otherwise, a class's constructor takes what its message needs, in the order the message uses it.
Base classes
| Class | code | JSON-RPC | Production | Who throws it |
|---|---|---|---|---|
PublicMcpError(message, code?, statusCode?) | PUBLIC_ERROR, or code | by statusCode (-32602 by default) | Kept | You, for anything the model should read. FrontMCP, for skill and channel requests it can't serve. |
InternalMcpError(message, code?) | INTERNAL_ERROR, or code | -32603 | Hidden | You, for failures to keep in the log. FrontMCP, for its own failures. |
GenericServerError(message, originalError?) | SERVER_ERROR | -32603 | Hidden | FrontMCP, for any other Error passed to this.fail(). |
Tools and prompts
| Class | code | JSON-RPC | Production | Who throws it |
|---|---|---|---|---|
ToolNotFoundError(name) | TOOL_NOT_FOUND | -32602 | Kept: Tool "x" not found | FrontMCP, for a name no tool has, or an internal tool called by a client. |
ToolExecutionError(name, cause?) | TOOL_EXECUTION_ERROR | -32603 | Hidden | FrontMCP, around an error thrown from execute() that isn't public. |
EntryUnavailableError(type, name, …) | ENTRY_UNAVAILABLE | -32003 (own) | Kept. It describes the server's environment: OS, runtime, deployment. | FrontMCP, for a tool, resource, resource template or prompt whose availableWhen doesn't match where the server runs. One whose surface leaves out "mcp" gets the not-found error instead. |
PromptNotFoundError(name) | PROMPT_NOT_FOUND | -32602 | Kept: Prompt not found: x | FrontMCP, for an unknown prompt. |
PromptExecutionError(name, cause?) | PROMPT_EXECUTION_FAILED | -32603 | Hidden | FrontMCP, around an error thrown from a prompt that isn't public. |
MissingPromptArgumentError(name) | MISSING_PROMPT_ARGUMENT | -32602 | Kept: Missing required argument: id | FrontMCP, for a required prompt argument that wasn't sent. |
ToolCallError(toolName, result) | TOOL_CALL_ERROR | Kept | FrontMCP's in-process clients with an LLM format, like connectClaude(): their callTool() rejects with it when the tool fails. message is the tool's error text, and result the MCP result, isError and _meta.code included. It never reaches a client over MCP. New in 1.9.2. |
Resources
| Class | code | JSON-RPC | Production | Who throws it |
|---|---|---|---|---|
ResourceNotFoundError(uri) | RESOURCE_NOT_FOUND | -32602 (own, data: { uri }). -32002 for clients before MCP 2026-07-28. | Kept: Resource not found: tickets://T-9 | FrontMCP, for a URI nothing serves. You, for a template whose item doesn't exist, so the client gets the same error as for an unknown URI. |
ResourceReadError(uri, cause?) | RESOURCE_READ_ERROR | -32603 | Hidden | FrontMCP, around an error thrown from a resource that isn't public. |
InvalidResourceUriError(uri, reason?) | INVALID_RESOURCE_URI | -32602 | Kept | You. FrontMCP never throws it. |
Unix socket startup
These internal errors are exported from @frontmcp/sdk and thrown during startup, before any MCP response. Their messages stay in the server log. See Node troubleshooting.
| Class | code | Constructor | Thrown when |
|---|---|---|---|
UnsafeSocketDirectoryError | UNSAFE_SOCKET_DIRECTORY | (directory: string, mode: number, ownerUid?: number) | The socket directory or an ancestor has unsafe ownership or permissions. |
SocketInUseError | SOCKET_IN_USE | (socketPath) | A listener already answers on the path. |
SocketPathConflictError | SOCKET_PATH_CONFLICT | (socketPath, reason) | The path isn't a stale socket owned by this user, or probing it failed unexpectedly. |
SocketPermissionError | SOCKET_PERMISSION | (socketPath, detail) | Owner-only binding or mode verification failed. |
Validation
| Class | code | JSON-RPC | Production | Who throws it |
|---|---|---|---|---|
InvalidInputError(message?, details?) | INVALID_INPUT | -32602 | Kept, with details appended as Details: and JSON | FrontMCP, for arguments that don't match inputSchema (Invalid tool input, then the Zod issues). You, for rules a schema can't express; see this.fail. |
InvalidOutputError(details?) | INVALID_OUTPUT | -32603 | Hidden: Output validation failed. Please contact support. | FrontMCP, for a result that doesn't match outputSchema, holds NaN, or has undeclared keys under output.undeclaredKeys: "fail" (or keys "keep" cannot restore), and since 1.8.7 for an agent's answer that doesn't match. In development the text is Tool output validation failed (output does not match outputSchema at status), naming the first field that didn't match. |
InvalidMethodError(method, expected) | INVALID_METHOD | -32602 | Kept | FrontMCP, inside its own request handling. Clients don't normally see it. |
Auth
| Class | code | JSON-RPC | Production | Who throws it |
|---|---|---|---|---|
UnauthorizedError(message?, wwwAuthenticate?) | UNAUTHORIZED | -32001 | Kept (default Unauthorized) | You, when the caller must sign in again. FrontMCP, for an older client's session that can't be restored from its token. |
AuthorizationRequiredError({ appId, toolId, authUrl?, requiredScopes?, … }) | AUTHORIZATION_REQUIRED | -32003 | Kept; production adds To authorize, click: and authUrl | FrontMCP, when the caller hasn't authorized the tool's app yet. See Progressive auth. |
ToolNotConsentedError(name) | TOOL_NOT_CONSENTED | -32003 (own) | Kept | FrontMCP, for a tool the user didn't select when consenting. See Tools: consent. |
ToolCredentialsRequiredError({ toolId, providers, authUrl?, signInRequired?, message? }) | TOOL_CREDENTIALS_REQUIRED | -32001 (own), also in tools/call | Kept | FrontMCP, for a tool whose required authProviders credential isn't connected. authUrl goes in data, not the message. For a caller who isn't signed in, FrontMCP sends signInRequired: true and no authUrl, and the message asks them to sign in first. It sets either one only from the caller's credential vault, this.credentials; a server with credential providers alone gives neither. See Progressive auth. |
AuthConfigurationError(message, { errors?, suggestion? }) | AUTH_CONFIGURATION_ERROR | -32603 | Kept; production adds To fix this issue: and suggestion | FrontMCP, at startup, for an auth or authorities configuration that can't work, including an authorities rule that checks nothing. |
UnsupportedClientVersionError(version) | UNSUPPORTED_CLIENT_VERSION | Kept | FrontMCP, for an older client's initialize whose protocol version isn't a date. | |
SessionMissingError(message?) | SESSION_MISSING | -32001 | Kept | Nobody: FrontMCP never throws it. |
PublicAccessDeniedError(kind, name) | PUBLIC_ACCESS_DENIED | -32003 (own) | Kept: The tool "help-desk:close_ticket" is not available to anonymous callers | FrontMCP, for an anonymous caller's call to a tool or prompt that the server's publicAccess doesn't list. New in 1.9.2. |
SessionIdentityRequiredError(what?) | SESSION_IDENTITY_REQUIRED | -32003 | Kept: The secure store's session scope needs a verified session or a signed-in caller. Authenticate the request, or use a session transport (an MCP revision before 2026-07-28). | FrontMCP, when this.secureStore with scope: "session" is used by a caller with neither a verified session nor a sign-in, like an anonymous MCP 2026-07-28 caller. New in 1.8.5. |
AuthorityDeniedError (@frontmcp/auth) | AUTHORITY_DENIED | -32003 (own, data: { entryType, entryName, deniedBy, denial }) | Kept: Access denied to Tool "help-desk:close_ticket": … | FrontMCP, when a caller fails an authorities rule. Not exported by @frontmcp/sdk. |
@frontmcp/sdk also re-exports @frontmcp/auth's internal errors, which FrontMCP throws while starting up or handling tokens. Clients keep their own error codes; non-public messages are hidden in production; the server log has the real code. The ones you're most likely to meet: JwtSecretRequiredError (JWT_SECRET_REQUIRED: production with auth.mode: "local" and no JWT_SECRET), JwtSecretWeakError (JWT_SECRET_INVALID: a secret under 32 bytes), SessionSecretRequiredError (SESSION_SECRET_REQUIRED), ElicitationSecretRequiredError, TokenNotAvailableError, TokenStoreRequiredError, TokenLeakDetectedError, EncryptionKeyNotConfiguredError, EncryptionContextNotSetError, VaultLoadError, VaultNotFoundError, SessionIdEmptyError, CredentialProviderAlreadyRegisteredError, OrchestratedAuthNotAvailableError, OrchestratorJwksNotAvailableError and NoProviderIdError. AuthProvidersNotConfiguredError (AUTH_PROVIDERS_NOT_CONFIGURED) is thrown by this.authProviders on a server without authProvidersVault, and CredentialProviderAlreadyRegisteredError when two of its providers share a name (both since 1.11.1; before, neither was thrown). SigningKeyInvalidError (SIGNING_KEY_INVALID) refuses invalid signing keys; UpstreamClientRegistrationError (UPSTREAM_CLIENT_REGISTRATION_FAILED) refuses failed upstream registration. ScopeDeniedError and InMemoryStoreRequiredError are never thrown.
Rate limits and the guard
| Class | code | JSON-RPC | Production | Who throws it |
|---|---|---|---|---|
RateLimitError(retryAfter?) | RATE_LIMIT_EXCEEDED | -32602 | Kept: Rate limit exceeded. Retry after 30 seconds | FrontMCP, for a tool's rateLimit. You, for limits of your own. |
QuotaExceededError(quotaType?) | QUOTA_EXCEEDED | -32602 | Kept: export quota exceeded (usage by default) | You. FrontMCP never throws it. |
ExecutionTimeoutError(name, ms) | EXECUTION_TIMEOUT | -32602 through this.fail() | Kept | FrontMCP, for a tool's timeout. |
ConcurrencyLimitError(name, max) | CONCURRENCY_LIMIT | -32602 through this.fail() | Kept | FrontMCP, for concurrency and globalConcurrency. |
QueueTimeoutError(name, ms) | QUEUE_TIMEOUT | -32602 through this.fail() | Kept | FrontMCP, when a queued call waits longer than queueTimeoutMs. |
IpBlockedError(ip), IpNotAllowedError(ip) | IP_BLOCKED, IP_NOT_ALLOWED | -32003 through this.fail() | Kept | Nobody: ipFilter answers the request itself. |
GuardStorageUnavailableError(storageType, cause?) | GUARD_STORAGE_UNAVAILABLE | Replaced, since 1.9: Service temporarily unavailable: the rate-limit store cannot be reached. Retry shortly., with status 503 | FrontMCP, when throttle.storage can't be reached and its fallback isn't "memory": while the server starts, where it stops the server (new in 1.8.6), and since 1.8.7 on a call whose limit check or concurrency slot the store can't serve, where the client gets it. See Guard troubleshooting and while the server runs. | |
GuardStorageUnsupportedError(cause?) | GUARD_STORAGE_UNSUPPORTED | -32603 through this.fail() | Kept; status 500 | FrontMCP, when concurrency storage lacks atomic compare-and-delete or compare-and-expire. Global/default concurrency checks at startup; a tool's own concurrency checks on its first call. See Guard troubleshooting. New in 1.9.7. |
GuardError(message, code, statusCode) | as given | The base of the guard errors above. | ||
GuardLimitMcpError(guardError) | the guard error's | by status | Kept | FrontMCP, when it turns a guard error into an McpError. |
See Guard options for when each limit trips.
Agents
| Class | code | Production | Who throws it |
|---|---|---|---|
AgentNotFoundError(id) | AGENT_NOT_FOUND | Kept | FrontMCP, for an unknown agent, like a name this.invokeAgent() doesn't know: Agent not found: …. |
AgentVisibilityError | AGENT_VISIBILITY_DENIED | Kept | FrontMCP, when invokeAgent() names an agent this one can't see, like one with swarm.isVisible: false. New in 1.9. |
AgentCallDepthExceededError | AGENT_CALL_DEPTH_EXCEEDED | Kept | FrontMCP, for a call from one agent to another past swarm.maxCallDepth. New in 1.9. |
AgentConfigurationError | AGENT_CONFIGURATION_ERROR | FrontMCP, at startup, for an agent's exports that names something the agent doesn't have. New in 1.9. | |
AgentExecutionError(id, cause?) | AGENT_EXECUTION_FAILED | Hidden | FrontMCP, around an agent's failures. |
AgentNotConfiguredError(name), AgentToolNotFoundError(agent, tool, available) | AGENT_NOT_CONFIGURED, AGENT_TOOL_NOT_FOUND | Hidden | FrontMCP, for an agent without an LLM adapter, or asking for a tool it doesn't have. |
AgentLoopExceededError, AgentTimeoutError | AGENT_LOOP_EXCEEDED, AGENT_TIMEOUT | Kept | FrontMCP, when the model loop exhausts its turns or times out. |
AgentLlmError | AGENT_LLM_ERROR | Hidden; wrapped as TOOL_EXECUTION_ERROR for a tool call | FrontMCP, when a model request fails. |
A client calling an agent gets public AGENT_LOOP_EXCEEDED or AGENT_TIMEOUT when its loop runs out of turns or time. Changed in 1.11.3: before, these were TOOL_EXECUTION_ERROR. Model failures use internal AgentLlmError, wrapped as TOOL_EXECUTION_ERROR; an answer that does not match outputSchema remains INVALID_OUTPUT.
Elicitation and multi-round-trip requests
| Class | code | JSON-RPC | Production | Who throws it |
|---|---|---|---|---|
ElicitationDisabledError() | ELICITATION_DISABLED | -32602 | Kept, shorter: Elicitation is disabled on this server. Development: Elicitation is disabled in server configuration. Enable it via @FrontMcp({ elicitation: { enabled: true } }) | FrontMCP, for this.elicit() on a server without elicitation.enabled. |
ElicitationNotSupportedError(message?) | ELICITATION_NOT_SUPPORTED | -32602 | Kept | FrontMCP, when an older client has no session or transport to ask through. |
ElicitationNotOwnedError(elicitId) | ELICITATION_NOT_OWNED | -32003 (own, data: { elicitId }) | Kept: Elicitation "elicit-…" was not requested by this caller | FrontMCP, when sendElicitationResult answers a question that another caller was asked. See this.elicit(). |
ElicitationTimeoutError(id, ttl) | ELICITATION_TIMEOUT | -32602 | Kept, reworded: … The user did not respond within the allowed time (300 seconds). | FrontMCP, when an older client's user doesn't answer in time. |
ElicitationFallbackRequired(…) | ELICITATION_FALLBACK | FrontMCP, internally, for clients that can't show forms. The call answers with instructions instead of an error. | ||
ElicitationStoreNotInitializedError, ElicitationEncryptionError, ElicitationSubscriptionError | ELICITATION_STORE_NOT_INITIALIZED, ELICITATION_ENCRYPTION_ERROR, ELICITATION_SUBSCRIPTION_ERROR | -32603 | Hidden | FrontMCP, for failures of its elicitation store. |
SamplingNotAvailableError(feature?) | MRTR_REQUIRED | -32602 | Kept | FrontMCP, for sampling or roots/list from a client older than MCP 2026-07-28. |
InputRequiredSignal, MissingClientCapabilityError | INPUT_REQUIRED, MISSING_REQUIRED_CLIENT_CAPABILITY | FrontMCP, under MCP 2026-07-28: the first becomes an input_required result, the second HTTP 400 with -32021. isMrtrSignal(error) recognizes both. |
Tasks
| Class | code | JSON-RPC | Who throws it |
|---|---|---|---|
TaskConcurrencyLimitError(maxConcurrent) | CONCURRENCY_LIMIT | Tool isError result | FrontMCP, when the caller reaches tasks.maxConcurrentPerSession. maxConcurrent is also available on the error. |
TaskNotFoundError(taskId) | TASK_NOT_FOUND | -32602 (own) | FrontMCP, for an unknown task id: Failed to retrieve task: Task not found. |
TaskAlreadyTerminalError(status) | TASK_ALREADY_TERMINAL | -32602 (own) | FrontMCP, when cancelling a task that has completed, failed or been cancelled. |
TaskAugmentationNotSupportedError(tool), TaskAugmentationRequiredError(tool) | TASK_AUGMENTATION_NOT_SUPPORTED, TASK_AUGMENTATION_REQUIRED | -32601 (own), also in tools/call | FrontMCP, for a client before MCP 2026-07-28 that asks for a task on a tool with taskSupport: "forbidden", or doesn't on one with "required". Under 2026-07-28 the second is a -32602. |
TaskStoreNotInitializedError() | TASK_STORE_NOT_INITIALIZED | -32603 | FrontMCP, for its own task store. Hidden in production. |
All but the last are public.
Jobs and workflows
| Class | code | Production | Who throws it |
|---|---|---|---|
JobNotAuthorizedError(name) | JOB_NOT_AUTHORIZED | Kept: Job or workflow "x" not found or not permitted | FrontMCP's job tools, for a job that doesn't exist or that the caller may not run. See @Job. |
DynamicJobRegistrationDisabledError(kind?) | DYNAMIC_REGISTRATION_DISABLED | Kept | FrontMCP's register_job and register_workflow, without jobs.allowDynamicRegistration. |
WorkflowTimeoutError, WorkflowJobTimeoutError, WorkflowStepNotFoundError, WorkflowDagValidationError | WORKFLOW_TIMEOUT, WORKFLOW_JOB_TIMEOUT, WORKFLOW_STEP_NOT_FOUND, WORKFLOW_DAG_VALIDATION | Hidden | FrontMCP, while running a workflow. Clients get TOOL_EXECUTION_ERROR from execute_workflow; see @Workflow. |
DynamicJobDirectExecutionError(name?) | DYNAMIC_JOB_DIRECT_EXECUTION | Hidden | FrontMCP, for a dynamic job run outside its sandbox. |
Remote apps
Remote servers covers how a remote app fails, and what each failure looks like.
For App.remote(). The public ones tell the model which remote server failed.
| Class | code | Production | Who throws it |
|---|---|---|---|
RemoteTimeoutError(app, operation, ms) | REMOTE_TIMEOUT_ERROR | Kept | FrontMCP, when a remote tool call takes too long (30 seconds by default) on every try. |
RemoteToolNotFoundError, RemoteResourceNotFoundError, RemotePromptNotFoundError | REMOTE_TOOL_NOT_FOUND, REMOTE_RESOURCE_NOT_FOUND, REMOTE_PROMPT_NOT_FOUND | Kept | FrontMCP, when the remote server doesn't have it. |
RemoteToolExecutionError, RemoteResourceReadError, RemotePromptGetError | REMOTE_TOOL_EXECUTION_ERROR, REMOTE_RESOURCE_READ_ERROR, REMOTE_PROMPT_GET_ERROR | Kept, with the remote error's message | FrontMCP, when the remote call fails. |
RemoteCircuitOpenError | REMOTE_CIRCUIT_OPEN | Kept, including the retry delay | FrontMCP, while a remote app's circuit breaker is open. |
RemoteAuthError(app, details?) | REMOTE_AUTH_ERROR | Kept: Authentication failed for remote server "status": the remote server refused the credentials (HTTP 401) | FrontMCP, when the remote answers a tool call, resource read or prompt request with 401, or a remoteAuth: { mode: "mapped" } mapper throws. A remote that refuses the connection while the server starts is a RemoteConnectionError instead. (Changed in 1.9.3: before, it was effectively never thrown.) |
RemoteNotConnectedError(app) | REMOTE_NOT_CONNECTED | Kept | FrontMCP, before the remote app has connected. |
RemoteConnectionError, RemoteCapabilityDiscoveryError | REMOTE_CONNECTION_ERROR, REMOTE_CAPABILITY_DISCOVERY_ERROR | Hidden | FrontMCP, when connecting or listing the remote server's capabilities fails. |
InvalidRetryOptionsError | INVALID_RETRY_OPTIONS | Hidden | FrontMCP, for bad retry options. |
RemoteDisconnectError, RemoteAuthorizationError, RemoteTransportError, RemoteUnsupportedTransportError, RemoteCapabilityNotSupportedError, RemoteConfigurationError | Nobody: FrontMCP never throws them. |
The remote errors also have an mcpErrorCode field. FrontMCP doesn't use it for tools/call, resources/read or prompts/get: the JSON-RPC code follows statusCode like any other public error, so a remote "not found" is -32602.
Providers
All internal (-32603, hidden in production), thrown by FrontMCP while building or looking up providers: ProviderNotAvailableError (PROVIDER_NOT_AVAILABLE: what this.get() throws for a provider it can't find), ProviderNotRegisteredError, ProviderNotInstantiatedError, ProviderScopeMismatchError, ProviderScopedAccessError, ProviderConstructionError (Failed to construct provider "…"), ProviderDependencyError, DependencyCycleError (Circular dependency detected: A -> B -> A), InvalidDependencyScopeError, PluginDependencyError, InvalidPluginScopeError and DependencyNotFoundError.
Registries, decorators and normalization
All internal, thrown by FrontMCP, most of them while the server starts:
- Registries:
DuplicateAppIdError(DUPLICATE_APP_ID,Two apps share the id "status": …, for twoApp.remote()orApp.esm()apps with one id; new in 1.9.3),RegistryDefinitionNotFoundError,RegistryGraphEntryNotFoundError,RegistryDependencyNotRegisteredError(Tool "X" depends on "Db", which is not registered),InvalidRegistryKindError,NameDisambiguationError,EntryValidationError,FlowNotRegisteredError,UnsupportedHookOwnerKindError,InvalidHookFlowErrorandRegistryNotInitializedError. - Decorators:
InvalidDecoratorMetadataError(@FrontMcp invalid metadata for "apps": …, see@FrontMcp) andHookTargetNotDefinedError. - Normalization, for an entry in a
providers,plugins,toolsor other list that isn't what FrontMCP expects:MissingProvideError,InvalidUseClassError,InvalidUseFactoryError,InvalidUseValueErrorandInvalidEntityError(Invalid Tool 'X'. Expected a class or function.).
FlowNotRegisteredError uses FLOW_NOT_REGISTERED and says Flow "…" is not registered. Changed in 1.10.0: before, create(), createDirect() and connect() registered http:* flows and the default public auth's flows. They now omit http:* flows and, without explicit auth, OAuth, OAuth discovery and session:verify flows (connect()'s CLI mode keeps its existing initialization). Calling an omitted flow throws this error: see what an in-process server initializes.
Transport
Internal, thrown by FrontMCP's transports: MethodNotImplementedError, UnsupportedTransportTypeError, InvalidTransportSessionError, TransportNotConnectedError, TransportAlreadyStartedError, TransportServiceNotAvailableError and SessionClaimConflictError. TransportBusRequiredError is never thrown. Two are public: UnsupportedContentTypeError (UNSUPPORTED_CONTENT_TYPE, for an older client's SSE message with the wrong content type) and PayloadTooLargeError (PAYLOAD_TOO_LARGE, HTTP 413).
ESM packages
Loading apps from npm covers how a package fails to load. For an App.esm() package, FrontMCP throws these while the server starts, so each one stops it:
| Class | code | When |
|---|---|---|
EsmVersionResolutionError | ESM_VERSION_RESOLUTION_ERROR | No version matches the range, or the registry doesn't have the package: Failed to resolve version for "@acme/nope@1.0.0": Package "@acme/nope" not found in registry at …. |
EsmRegistryAuthError | ESM_REGISTRY_AUTH_ERROR | The registry answered 401 or 403. |
EsmPackageLoadError | ESM_PACKAGE_LOAD_ERROR | The package's bundle couldn't be fetched or run: Failed to load ESM package "@acme/status-tools"@1.0.0: …. |
EsmManifestInvalidError | ESM_MANIFEST_INVALID | The package loaded, but doesn't export a FrontMCP package: Invalid manifest in ESM package "…": ESM module does not export a valid FrontMcpPackageManifest. … |
EsmCacheError | ESM_CACHE_ERROR | The bundle couldn't be cached. |
EsmInvalidSpecifierError | ESM_INVALID_SPECIFIER | Thrown by App.esm() itself, as soon as it is called, for a specifier that isn't a package name with an optional range. |
Changed in 1.9.2: before, these were exported but never thrown, and a package that failed to load failed with a plain Error.
Since 1.9.1, for a single tool, resource or prompt loaded with Tool.esm(), Tool.remote() and the like: ExternalEntryLoadError, when its package doesn't load or its server can't be reached, ExternalEntryNotFoundError, when the package or server has no entry by that name, and ExternalEntryNotSupportedError, for an agent, skill or job loaded that way, which FrontMCP refuses. All three stop the server from starting.
Everything else
Internal, thrown by FrontMCP: FlowExitedWithoutOutputError (Flow exited without producing output: a tool's execute() returned undefined), RequestContextNotAvailableError (this.context used outside a request), ContextExtensionNotAvailableError, ServerNotFoundError, ConfigNotFoundError, RequiredConfigUndefinedError, SessionVerificationFailedError, ScopeConfigurationError, HaConfigurationError, InvokeStateMissingKeyError, FlowInputMissingError, DynamicAdapterNameError, ServerlessHandlerNotInitializedError, VercelKvNotSupportedError, the skill errors InvalidSkillError, SkillInstructionFetchError, InvalidInstructionSourceError, SkillSessionError and SkillContextNotImplementedError, the agent errors AgentConfigKeyNotFoundError, AgentToolExecutionError and AgentMethodNotAvailableError, and ToolNameConflictError, for a tool added with registerTool() under a name the server already has (new in 1.9). SkillValidationError is public: it stops the server from starting when a skill with toolValidation: "strict" names a tool the server doesn't have (Skill '…' failed tool validation: missing tools […], since 1.9; see @Skill). GlobalConfigNotFoundError (Plugin "cache" requires global "redis" configuration) is public, and so is UnenforcedMetadataError (UNENFORCED_METADATA), which stops the server from starting when an entry declares a plugin's option, like approval, and no plugin that enforces it covers the entry: see @Plugin. So are three that stop the server from starting when a plugin is installed twice (new in 1.11.1): DuplicatePluginEntryError (DUPLICATE_PLUGIN_ENTRY), one plugins list naming it twice; DuplicatePluginError (DUPLICATE_PLUGIN), a oncePerServer plugin installed twice; and PluginConfiguredTwiceError (PLUGIN_CONFIGURED_TWICE), observability set with ObservabilityPlugin in plugins. VercelKvAsyncInitRequiredError and EnclaveExecutionError are never thrown.
FlowControl isn't an error to report: it's how this.fail() and this.respond() end a call, and its message is empty. See A tool call succeeds after this.fail().
Caveats
- Fail with a public class for anything the model should read.
PublicMcpError, or one ofInvalidInputError,RateLimitError,QuotaExceededError,UnauthorizedErrorandResourceNotFoundError, or a subclass of your own. - Throwing and failing differ for internal errors other than auth errors:
TOOL_EXECUTION_ERRORwhen thrown, the error's own code throughthis.fail(). Production hides both. - In a resource or prompt,
statusCodepicks the JSON-RPC code. APublicMcpErrorwith status404is-32602, like any other client error;401and403are the ones that change it. - A development client reads more than a production one: the stack, an internal error's message, and for a few classes, a longer developer message. Test what production sends with
createErrorHandler({ isDevelopment: false }). - Some exported classes are never thrown, as the tables say. Don't wait for them in a client.
Usage
Failing with a built-in class
Each sample below is a class you might fail a tool with. fail_with fails with the one you name; the test checks what a client reads for each, in development. Try other samples in the Call tab.
import {
ConcurrencyLimitError,
ElicitationDisabledError,
InternalMcpError,
InvalidInputError,
PublicMcpError,
QuotaExceededError,
RateLimitError,
SessionSecretRequiredError,
UnauthorizedError,
} from "@frontmcp/sdk";
export const samples: Record<string, Error> = {
public: new PublicMcpError("There's no ticket T-9."),
publicWithCode: new PublicMcpError("Ticket T-2 is archived. Ask a lead to restore it.", "TICKET_ARCHIVED", 409),
invalidInput: new InvalidInputError("`due` must be in the future.", { field: "due" }),
rateLimit: new RateLimitError(3600),
quota: new QuotaExceededError("export"),
unauthorized: new UnauthorizedError("Sign in again to export tickets."),
internal: new InternalMcpError("replica lag 12s on tickets-db-2", "DB_LAG"),
plain: new Error("connect ECONNREFUSED 10.0.4.12:5432"),
guard: new ConcurrencyLimitError("export_tickets", 1),
elicitationOff: new ElicitationDisabledError(),
authInternal: new SessionSecretRequiredError("sessions"),
};Starting FrontMCP in your browser…
FrontMCP starts when this example comes into view.
What production sends
The same samples, formatted by an ErrorHandler with isDevelopment: false, which is what tools/call uses when NODE_ENV=production. Public errors keep their message; internal ones, plain errors and @frontmcp/auth's errors become an error ID; ElicitationDisabledError switches to its shorter message:
import { test, expect } from "@frontmcp/testing";
import { createErrorHandler, isPublicError, toMcpError } from "@frontmcp/sdk";
import { samples } from "./samples";
const production = createErrorHandler({ isDevelopment: false });
const hidden = /^Internal FrontMCP error\. Please contact support with error ID: err_[0-9a-f]{16}$/;
const expected: Record<string, [code: string, text: string | RegExp]> = {
public: ["PUBLIC_ERROR", "There's no ticket T-9."],
invalidInput: ["INVALID_INPUT", '`due` must be in the future.\nDetails: {\n "field": "due"\n}'],
rateLimit: ["RATE_LIMIT_EXCEEDED", "Rate limit exceeded. Retry after 3600 seconds"],
guard: ["CONCURRENCY_LIMIT", 'Concurrency limit reached for "export_tickets" (max: 1)'],
elicitationOff: ["ELICITATION_DISABLED", "Elicitation is disabled on this server."],
internal: ["DB_LAG", hidden],
plain: ["SERVER_ERROR", hidden],
authInternal: ["SESSION_SECRET_REQUIRED", hidden],
};
for (const [sample, [code, text]] of Object.entries(expected)) {
test(`${sample} in production`, () => {
const result = production.handle(samples[sample]);
expect(result._meta?.code).toBe(code);
if (typeof text === "string") expect(result.content[0].text).toBe(text);
else expect(result.content[0].text).toMatch(text);
expect(result._meta).not.toHaveProperty("stack");
});
}
test("the error ID is the one in the server's log", () => {
const result = production.handle(samples.internal);
expect(result._meta?.errorId).toBe((samples.internal as { errorId?: string }).errorId);
});
test("guard errors aren't McpErrors, but are sent as public ones", () => {
expect(isPublicError(samples.guard)).toBe(false);
expect(toMcpError(samples.guard)).toMatchObject({ code: "CONCURRENCY_LIMIT", isPublic: true });
});Starting FrontMCP in your browser…
FrontMCP starts when this example comes into view.
Failing vs throwing
A public error reads the same thrown or failed. The others don't: thrown from a tool's execute(), an InternalMcpError or a guard error other than a timeout is wrapped as TOOL_EXECUTION_ERROR, and a ToolCredentialsRequiredError becomes a JSON-RPC error rather than a tool result. Thrown from a resource, every guard error is wrapped, the timeout too:
import {
ConcurrencyLimitError,
ExecutionTimeoutError,
GuardStorageUnsupportedError,
InternalMcpError,
PublicMcpError,
ResourceContext,
ResourceTemplate,
Tool,
ToolContext,
ToolCredentialsRequiredError,
z,
} from "@frontmcp/sdk";
const make: Record<string, () => Error> = {
public: () => new PublicMcpError("There's no ticket T-9.", "TICKET_NOT_FOUND", 404),
internal: () => new InternalMcpError("replica lag 12s", "DB_LAG"),
concurrency: () => new ConcurrencyLimitError("export", 1),
timeout: () => new ExecutionTimeoutError("export", 500),
unsupported: () => new GuardStorageUnsupportedError(),
credentials: () => new ToolCredentialsRequiredError({ toolId: "sync_crm", providers: ["crm"], authUrl: "https://desk.example.com/connect/crm" }),
};
const input = { sample: z.enum(["public", "internal", "concurrency", "timeout", "unsupported", "credentials"]) };
type Input = { sample: "public" | "internal" | "concurrency" | "timeout" | "unsupported" | "credentials" };
@Tool({ name: "throw_it", description: "Throw a sample error", inputSchema: input })
export class ThrowIt extends ToolContext {
async execute({ sample }: Input): Promise<{ ok: boolean }> {
throw make[sample]();
}
}
@Tool({ name: "fail_it", description: "Fail with a sample error", inputSchema: input })
export class FailIt extends ToolContext {
async execute({ sample }: Input): Promise<{ ok: boolean }> {
this.fail(make[sample]());
}
}
@ResourceTemplate({ name: "thrown", uriTemplate: "thrown://{sample}", mimeType: "text/plain" })
export class Thrown extends ResourceContext<{ sample: string }> {
async execute(uri: string, { sample }: { sample: string }): Promise<{ contents: { uri: string; text: string }[] }> {
throw make[sample]();
}
}Starting FrontMCP in your browser…
FrontMCP starts when this example comes into view.
Failing in a resource or a prompt
In a resource or a prompt, the class's statusCode picks the JSON-RPC code. TicketLockedError is a public error of this server's own, with status 403:
import { InternalMcpError, PublicMcpError, ResourceContext, ResourceNotFoundError, ResourceTemplate, UnauthorizedError } from "@frontmcp/sdk";
export class TicketLockedError extends PublicMcpError {
constructor(id: string) {
super(`Ticket ${id} is under legal hold.`, "TICKET_LOCKED", 403);
}
}
@ResourceTemplate({ name: "ticket", uriTemplate: "tickets://{id}", mimeType: "application/json" })
export class Ticket extends ResourceContext<{ id: string }> {
async execute(uri: string, { id }: { id: string }) {
if (id === "T-3") this.fail(new TicketLockedError(id));
if (id === "T-4") this.fail(new UnauthorizedError("Sign in to read archived tickets."));
if (id === "T-5") this.fail(new PublicMcpError("The ticket store is down for maintenance.", "STORE_DOWN", 503));
if (id === "T-6") this.fail(new InternalMcpError("replica lag 12s", "DB_LAG"));
if (id !== "T-1") this.fail(new ResourceNotFoundError(uri));
return { contents: [{ uri, mimeType: "application/json", text: JSON.stringify({ id, title: "Cannot log in" }) }] };
}
}Starting FrontMCP in your browser…
FrontMCP starts when this example comes into view.
Errors FrontMCP raises for you
Most errors a client sees come from FrontMCP, before or around your code. Here each test makes FrontMCP raise one:
import { App, FrontMcp, Job, JobContext, Prompt, PromptContext, Resource, ResourceContext, Tool, ToolContext, z } from "@frontmcp/sdk";
@Tool({ name: "search_tickets", description: "Search tickets by title", inputSchema: { query: z.string().min(1) } })
class SearchTickets extends ToolContext {
async execute({ query }: { query: string }) {
return { query, tickets: [] };
}
}
@Tool({ name: "close_ticket", description: "Close a ticket", inputSchema: { id: z.string() }, authorities: "admin" })
class CloseTicket extends ToolContext {
async execute({ id }: { id: string }) {
return { id, closed: true };
}
}
@Tool({ name: "run_on_deno", description: "Only on Deno", inputSchema: {}, availableWhen: { runtime: ["deno"] } })
class RunOnDeno extends ToolContext {
async execute() {
return { ok: true };
}
}
@Tool({ name: "export_archive", description: "Export the ticket archive", inputSchema: {}, execution: { taskSupport: "required" } })
class ExportArchive extends ToolContext {
async execute() {
return { rows: 18_000 };
}
}
@Prompt({ name: "summarize_ticket", description: "Summarize a ticket", arguments: [{ name: "id", required: true }] })
class SummarizeTicket extends PromptContext {
async execute({ id }: Record<string, string>) {
return { messages: [{ role: "user" as const, content: { type: "text" as const, text: `Summarize ticket ${id}.` } }] };
}
}
@Resource({ name: "audit-log", uri: "desk://audit-log", mimeType: "text/plain", authorities: "admin" })
class AuditLog extends ResourceContext {
async execute(uri: string) {
return { contents: [{ uri, text: "T-1 closed by nour" }] };
}
}
@Resource({ name: "deploy-notes", uri: "desk://deploy-notes", mimeType: "text/plain", availableWhen: { runtime: ["deno"] } })
class DeployNotes extends ResourceContext {
async execute(uri: string) {
return { contents: [{ uri, text: "Deploy with deployctl." }] };
}
}
@Job({ name: "nightly_cleanup", description: "Close stale tickets", inputSchema: {}, outputSchema: {} })
class NightlyCleanup extends JobContext {
async execute() {
return {};
}
}
@App({
id: "help-desk",
name: "Help Desk",
tools: [SearchTickets, CloseTicket, RunOnDeno, ExportArchive],
resources: [AuditLog, DeployNotes],
prompts: [SummarizeTicket],
jobs: [NightlyCleanup],
})
class HelpDeskApp {}
@FrontMcp({
info: { name: "help-desk", version: "1.0.0" },
apps: [HelpDeskApp],
authorities: { profiles: { admin: { roles: { any: ["admin"] } } } },
})
export default class Server {}Starting FrontMCP in your browser…
FrontMCP starts when this example comes into view.
ENTRY_UNAVAILABLE's message lists the server's OS, runtime and deployment, in production too, for tools, resources and prompts alike. If that's more than callers should know, leave the entry out of the server instead of relying on availableWhen.
Troubleshooting
Internal FrontMCP error. Please contact support with error ID: err_…
The server runs with NODE_ENV=production, and the call failed with an internal error: an InternalMcpError or one of FrontMCP's, a plain Error, or one of @frontmcp/auth's. Search the server's log for the error ID: FrontMCP logs the original message and stack with it. If the model should read the message, fail with a public class. See this.fail.
My error's code arrives as TOOL_EXECUTION_ERROR
It was thrown from execute() and isn't public: an InternalMcpError, a guard error, or an Error with a code property of its own. Throw a PublicMcpError subclass, or pass the error to this.fail(), which keeps an McpError's code. See Failing vs throwing.
My error's code arrives as SERVER_ERROR
It isn't an McpError: a plain Error, or one of @frontmcp/auth's internal errors, passed to this.fail(). Only McpErrors and guard errors keep their code. Wrap it: this.fail(new InternalMcpError(error.message, "CRM_SYNC_FAILED")) keeps the message out of production, with a code clients can tell apart.
A resource error arrives as -32602 when I meant "not found"
Under MCP 2026-07-28, every client error from a resource is -32602, including ResourceNotFoundError; -32002 is only for older clients. Tell errors apart by data.code, which is your class's code. ResourceNotFoundError is the exception: its data is { uri }, so check the message.
The client sees a long developer message, like Elicitation is disabled in server configuration. Enable it via …
In development, a tool's error text is the internal message, written for you. Production sends the public one: here, Elicitation is disabled on this server. Resources and prompts send the public one in both. See What production sends.
I'm waiting for QuotaExceededError (or SessionMissingError, an ESM error…) and it never comes
FrontMCP exports some classes without throwing them. The tables distinguish them from errors the runtime uses.