{"record":{"id":"39af9728841f9892","repo":"FlowiseAI/Flowise","slug":"error-custommcpserverscontroller-endpoint-in","errorCode":null,"errorMessage":"Error: customMcpServersController.${endpoint} - invalid authType \"${String(authType)}\"","messagePattern":"Error: customMcpServersController\\.(.+?) - invalid authType \"(.+?)\"","errorType":"exception","errorClass":"InternalFlowiseError","httpStatus":400,"severity":"warning","filePath":"packages/server/src/controllers/custom-mcp-servers/index.ts","lineNumber":16,"sourceCode":"import { NextFunction, Request, Response } from 'express'\nimport { StatusCodes } from 'http-status-codes'\nimport { InternalFlowiseError } from '../../errors/internalFlowiseError'\nimport { CustomMcpServerAuthType } from '../../Interface'\nimport customMcpServersService from '../../services/custom-mcp-servers'\nimport { getPageAndLimitParams } from '../../utils/pagination'\n\nconst MAX_PAGE_LIMIT = 500\nconst DEFAULT_PAGE = 1\nconst DEFAULT_LIMIT = 50\n\nconst assertValidAuthType = (authType: unknown, endpoint: string): void => {\n    if (authType === undefined) return\n    const allowed = Object.values(CustomMcpServerAuthType) as string[]\n    if (typeof authType !== 'string' || !allowed.includes(authType)) {\n        throw new InternalFlowiseError(\n            StatusCodes.BAD_REQUEST,\n            `Error: customMcpServersController.${endpoint} - invalid authType \"${String(authType)}\"`\n        )\n    }\n}\n\nconst createCustomMcpServer = async (req: Request, res: Response, next: NextFunction) => {\n    try {\n        if (!req.body) {\n            throw new InternalFlowiseError(\n                StatusCodes.PRECONDITION_FAILED,\n                `Error: customMcpServersController.createCustomMcpServer - body not provided!`\n            )\n        }\n        const orgId = req.user?.activeOrganizationId\n        if (!orgId) {\n            throw new InternalFlowiseError(\n                StatusCodes.NOT_FOUND,","sourceCodeStart":1,"sourceCodeEnd":34,"githubUrl":"https://github.com/FlowiseAI/Flowise/blob/abe4a8601a058047b350c260676826e21dd14101/packages/server/src/controllers/custom-mcp-servers/index.ts#L1-L34","documentation":"Thrown by assertValidAuthType when req.body.authType is defined but is not one of the allowed enum values ('NONE' or 'CUSTOM_HEADERS'). The guard skips when authType is undefined, so the error fires only when a client explicitly sent a wrong value. Returns HTTP 400 BAD_REQUEST.","triggerScenarios":"POST /api/v1/custom-mcp-servers or PUT /api/v1/custom-mcp-servers/:id with body.authType set to 'none', 'None', 'BASIC', 'BEARER', 'OAUTH2', or any string that isn't exactly 'NONE' or 'CUSTOM_HEADERS'. The check is case-sensitive and uses Object.values(CustomMcpServerAuthType).","commonSituations":"Client sends a lowercase or differently-cased value ('none' vs 'NONE'). Frontend built against an older or newer API version whose enum had different members. Hand-typed payload with a plausible-but-wrong auth scheme name. Migration from another MCP client that supports more auth types.","solutions":["Set body.authType to exactly 'NONE' (when no auth needed) or 'CUSTOM_HEADERS' (when injecting auth headers via authConfig).","Omit authType entirely from the body if you want the default — assertValidAuthType returns early when authType === undefined.","Update your TypeScript client to use the CustomMcpServerAuthType enum rather than a string literal.","If you genuinely need a new auth scheme, extend CustomMcpServerAuthType in Interface.ts and the service layer; do not send an ad-hoc value."],"exampleFix":"// before — wrong value & casing\n{ name: 'my-mcp', serverUrl: '...', authType: 'Bearer' }\n\n// after — valid enum value\nimport { CustomMcpServerAuthType } from '@flowise/interface'\n{ name: 'my-mcp', serverUrl: '...', authType: CustomMcpServerAuthType.NONE }","handlingStrategy":"type-guard","validationCode":"import { CustomMcpServerAuthType } from '@flowise/interface'\n\nconst ALLOWED = new Set<string>(Object.values(CustomMcpServerAuthType)) // {'NONE','CUSTOM_HEADERS'}\n\nfunction normalizeAuthType(raw: unknown) {\n  if (raw === undefined) return undefined // server allows omission\n  if (typeof raw !== 'string' || !ALLOWED.has(raw)) {\n    throw new Error(`authType must be one of ${[...ALLOWED].join('|')}, got ${String(raw)}`)\n  }\n  return raw\n}\n\nconst body = { ...payload, authType: normalizeAuthType(payload.authType) }\nawait api.createCustomMcpServer(body)","typeGuard":"function isCustomMcpAuthType(v: unknown): v is CustomMcpServerAuthType {\n  return typeof v === 'string'\n    && Object.values(CustomMcpServerAuthType).includes(v as any)\n}","tryCatchPattern":"try {\n  await api.createCustomMcpServer(payload)\n} catch (e) {\n  if (e.status === 400 && /invalid authType/.test(e.message)) {\n    // strip authType and retry with the default, or surface to the user\n    const { authType, ...rest } = payload\n    return api.createCustomMcpServer(rest)\n  }\n  throw e\n}","preventionTips":["Import the CustomMcpServerAuthType enum on the client and reference its members instead of string literals.","Treat authType as optional — omit it rather than guessing, since assertValidAuthType allows undefined.","When the enum changes across versions, regenerate the client types from the server Interface.ts."],"tags":["validation","enum","client-bug","mcp","flowise"],"backgroundTag":null,"analyzedSha":"abe4a8601a058047b350c260676826e21dd14101","analyzedAt":"2026-08-12T16:04:40.823Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}