different-ai/openwork · error · EnterpriseMcpClientError
MCP_CONFIGURATION_FAILED
MCP_CONFIGURATION_FAILED
Error message
Enterprise MCP failed during ${phaseLabel[input.operationPhase]}${request}. What it means
configurationValue in packages/enterprise-mcp-client/src/enterprise-mcp-client.ts wraps any throw from option/configuration parsing (zod schemas for client options, oauth configuration, connection fields, authorization ids, tool names, resource URIs) into an EnterpriseMcpClientError with operationPhase "configuration" and code MCP_CONFIGURATION_FAILED. The original validation error is attached as cause; the message is rendered as "Enterprise MCP failed during configuration...". It means setup inputs were invalid before any network call was made.
Source
Thrown at packages/enterprise-mcp-client/src/enterprise-mcp-client.ts:130
}
function validateRedirectUri(redirectUri: string): string {
const parsed = redirectUriSchema.parse(redirectUri)
const url = new URL(parsed)
if (url.protocol !== "https:" && url.protocol !== "http:") {
throw new Error("An enterprise MCP OAuth redirect URI must use HTTP or HTTPS.")
}
if (url.username || url.password || url.hash) {
throw new Error("An enterprise MCP OAuth redirect URI cannot contain credentials or a fragment.")
}
return parsed
}
function configurationValue<T>(parse: () => T): T {
try {
return parse()
} catch (error) {
throw new EnterpriseMcpClientError({
operationPhase: "configuration",
requestPhase: null,
cause: error,
})
}
}
async function closeWithinDeadline(close: () => Promise<void>, timeoutMs: number): Promise<void> {
let timer: ReturnType<typeof setTimeout> | undefined
try {
await Promise.race([
close(),
new Promise<never>((_resolve, reject) => {
timer = setTimeout(() => reject(new Error("The MCP client did not close before its deadline.")), timeoutMs)
}),
])
} finally {
if (timer) clearTimeout(timer)View on GitHub (pinned to 2b7df46e8a)
Solutions
- Inspect error.cause (the zod issue) to see exactly which field failed validation.
- Fix the offending configuration value at its source (env var, config file, caller argument).
- Provide defaults for optional numeric options or ensure they parse to positive integers.
- For clientMetadataUrl, use an https URL that includes a path (e.g. https://example.com/.well-known/oauth-client).
Example fix
// before
createEnterpriseMcpClient({ operationTimeoutMs: Number(process.env.TIMEOUT_MS) })
// after
const timeout = Number(process.env.TIMEOUT_MS)
createEnterpriseMcpClient({ operationTimeoutMs: Number.isFinite(timeout) && timeout > 0 ? timeout : undefined }) Defensive patterns
Strategy: try-catch
Validate before calling
import { z } from "zod"
const preflight = z.object({
operationTimeoutMs: z.number().int().positive().optional(),
clientMetadataUrl: z.string().url().optional(),
authorizationServerIssuer: z.string().url().optional(),
})
preflight.parse(suppliedOptions) // surfaces zod issues before the library does Try / catch
try {
const client = createEnterpriseMcpClient(options)
} catch (error) {
if (error instanceof EnterpriseMcpClientError && error.operationPhase === "configuration") {
console.error("invalid MCP client config:", error.cause)
} else throw error
} Prevention
- Validate env-derived numbers (NaN/negative) before passing them as timeouts
- Ensure clientMetadataUrl is https and includes a path
- Log error.cause (the zod issue list) to pinpoint the bad field
When it happens
Trigger: createEnterpriseMcpClient with invalid options (e.g. negative operationTimeoutMs, empty clientName), malformed oauthConfiguration (bad clientMetadataUrl, non-URL issuer), invalid authorizationId/authorizationCode lengths, empty toolName, or oversized/malformed resource URIs — any input failing its zod schema.
Common situations: Env-derived config like operationTimeoutMs: Number(process.env.TIMEOUT) yielding NaN; clientMetadataUrl pointing at a bare https origin with no path (violates the https+path refine); passing an empty tool name after trimming.
Understand the failure class
Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.
Related errors
- DEN_API_PUBLIC_URL cannot contain credentials, a query strin
- Manual OIDC configuration requires authorization, token, and
- Invalid IANA timezone: ${timezone}
- ${name} must be a safe integer greater than or equal to ${mi
- An enterprise MCP server URL must use HTTP or HTTPS.
AI-assisted analysis of different-ai/openwork@2b7df46e8a (2026-09-01).
Data as JSON: /api/errors/fca26337dd836c94.
Report an issue: GitHub.