FlowiseAI/Flowise · warning · InternalFlowiseError

Error: customMcpServersController.createCustomMcpServer - bo

Error message

Error: customMcpServersController.createCustomMcpServer - body not provided!

What it means

Thrown by createCustomMcpServer when req.body is falsy — the first guard in the handler. Same shape as the credentials body-not-provided error: fires for an empty POST body, a missing Content-Type: application/json header, or a body-parser misconfiguration. Returns HTTP 412 PRECONDITION_FAILED.

Source

Thrown at packages/server/src/controllers/custom-mcp-servers/index.ts:26

const MAX_PAGE_LIMIT = 500
const DEFAULT_PAGE = 1
const DEFAULT_LIMIT = 50

const assertValidAuthType = (authType: unknown, endpoint: string): void => {
    if (authType === undefined) return
    const allowed = Object.values(CustomMcpServerAuthType) as string[]
    if (typeof authType !== 'string' || !allowed.includes(authType)) {
        throw new InternalFlowiseError(
            StatusCodes.BAD_REQUEST,
            `Error: customMcpServersController.${endpoint} - invalid authType "${String(authType)}"`
        )
    }
}

const createCustomMcpServer = async (req: Request, res: Response, next: NextFunction) => {
    try {
        if (!req.body) {
            throw new InternalFlowiseError(
                StatusCodes.PRECONDITION_FAILED,
                `Error: customMcpServersController.createCustomMcpServer - body not provided!`
            )
        }
        const orgId = req.user?.activeOrganizationId
        if (!orgId) {
            throw new InternalFlowiseError(
                StatusCodes.NOT_FOUND,
                `Error: customMcpServersController.createCustomMcpServer - organization not found!`
            )
        }
        const workspaceId = req.user?.activeWorkspaceId
        if (!workspaceId) {
            throw new InternalFlowiseError(
                StatusCodes.NOT_FOUND,
                `Error: customMcpServersController.createCustomMcpServer - workspace not found!`
            )
        }

View on GitHub (pinned to abe4a8601a)

Solutions

  1. Confirm the POST has a JSON body containing at least name and serverUrl, with Content-Type: application/json.
  2. On the client, default to an empty object: api.createCustomMcpServer(payload || {}).
  3. Verify express.json() is mounted before the custom-mcp-servers routes.
  4. Check that the body size is under the configured JSON limit.
  5. In tests, pass a real object as the body.

Example fix

// before
await fetch('/api/v1/custom-mcp-servers', { method: 'POST' })

// after
await fetch('/api/v1/custom-mcp-servers', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({ name: '...', serverUrl: '...', authType: 'NONE' })
})
Defensive patterns

Strategy: validation

Validate before calling

function requireCreateBody(body: unknown): Record<string, unknown> {
  if (!body || typeof body !== 'object' || Array.isArray(body)) {
    throw new Error('createCustomMcpServer requires a JSON body')
  }
  return body
}

const body = requireCreateBody(payload)
await api.createCustomMcpServer(body)

Type guard

function isPlainObject(v: unknown): v is Record<string, unknown> {
  return typeof v === 'object' && v !== null && !Array.isArray(v)
}

Try / catch

try {
  await api.createCustomMcpServer(payload)
} catch (e) {
  if (e.status === 412 && /body not provided/.test(e.message)) {
    // ensure Content-Type + non-empty body, then retry once
    return api.createCustomMcpServer(payload ?? {})
  }
  throw e
}

Prevention

When it happens

Trigger: POST /api/v1/custom-mcp-servers sent with no body or without Content-Type: application/json so the JSON parser skips it. A client calling createCustomMcpServer(undefined). Body parser not mounted before this route.

Common situations: Frontend form submitted with no fields, or fetch with no body argument. Wrong/missing Content-Type header. express.json() registered after the MCP routes. Test passing undefined as the body.

Related errors


AI-assisted analysis of FlowiseAI/Flowise@abe4a8601a (2026-08-12). Data as JSON: /api/errors/616c7e0e5be68478. Report an issue: GitHub.