SIGN IN SIGN UP

fix(mcp): guard malformed form option metadata in chatflow MCP schema generation (#6233)

* Reject malformed MCP form option metadata before schema generation crashes

Chatflow-as-MCP-server assumes addOptions is always an array for form fields of type 'options'. Imported or malformed configs can carry '', null, or undefined instead, which throws during schema generation. This change fails fast with a controlled validation path and adds coverage for those cases.

Constraint: Fix should stay inside the server-side MCP endpoint path

Rejected: Normalize all malformed values silently | hides bad config state and weakens feedback

Confidence: high

Scope-risk: narrow

Reversibility: clean

Directive: Keep MCP schema generation defensive around imported flow JSON shapes

Tested: Added unit coverage for string, undefined, and null addOptions cases; local runtime repro confirms prior crash modes

Not-tested: Full end-to-end MCP initialize/tools-list call against a running server

* Keep malformed MCP option metadata from taking down form tool schemas

The maintainer follow-up on the MCP schema fix asked for malformed or empty
options metadata to be ignored rather than treated as a fatal configuration
error. This updates the schema builder to skip unusable enum fields, adds test
coverage for those cases, and narrows the start-node shape locally so the
server-side test can compile against the current interface types.

Constraint: Maintainer requested skip semantics for invalid/empty addOptions instead of hard failure
Rejected: Preserve throw-on-invalid behavior | conflicts with upstream maintainer direction
Confidence: high
Scope-risk: narrow
Reversibility: clean
Directive: Keep malformed or empty options metadata non-fatal; omit that field rather than breaking the whole MCP tool schema
Tested: pnpm --dir packages/components build; pnpm --dir packages/server test -- src/services/mcp-endpoint/index.test.ts --runInBand
Not-tested: End-to-end MCP initialize/tools/list flow against a live server

* add schema checks for input.addOptions

---------

Co-authored-by: Henry Heng <henryheng@flowiseai.com>
J
Junghwan committed
42b9157f8ca540ec67678ab7eb76b57327279210
Parent: 19b64e5
Committed by GitHub <noreply@github.com> on 4/17/2026, 8:48:47 PM