fix: schema builder input_schema not persisting and dark mode missing styles
๐ Bug-fix PR
๐ Summary
Two bugs in the REST tool creation schema builder in the Admin UI:
- Schema not persisting โ tools created via the Schema Builder (UI mode) were saved with an empty
input_schemaevery time. JSON Input mode worked correctly. - Dark mode not applied โ the schema builder panel, parameter cards, and all their input fields rendered with white backgrounds and unstyled controls when dark mode was active.
Closes #4887
๐ Reproduction Steps
Bug 1 โ schema not persisting:
- Admin UI โ Tools โ "Add New Tool from REST API"
- Select Schema Builder mode (default)
- Add a parameter, fill in name/type/description
- Submit โ tool is created with
input_schema: {}
Bug 2 โ dark mode:
- Toggle dark mode in the Admin UI
- Navigate to Tools โ "Add New Tool from REST API"
- The schema builder section (#ui-builder, parameter cards, inputs) renders white
๐ Root Cause
Bug 1: In handleToolFormSubmit (mcpgateway/admin_ui/formSubmitHandlers.js), new FormData(form) was called at the top of the handler โ before window.schemaEditor.save(). CodeMirror only syncs its internal state to the underlying <textarea name="input_schema"> when .save() is explicitly called. The Schema Builder path injects the generated schema via schemaEditor.setValue() and then flushes via schemaEditor.save(), but FormData had already snapshotted the empty textarea. The JSON Input path appeared to work because typing in CodeMirror can trigger auto-sync events, but it had the same latent ordering bug.
Bug 2: The schema builder container (#ui-builder), passthrough fieldset (#passthrough-container), dynamically-created parameter card divs, and all their child inputs/select/textarea elements were missing Tailwind dark: variants entirely.
๐ก Fix Description
Bug 1 (mcpgateway/admin_ui/formSubmitHandlers.js):
Moved new FormData(form) to after all editor .save() calls (headersEditor, schemaEditor, outputSchemaEditor) and after the schema builder setValue() call. Validation still runs first using form.elements["name"].value / form.elements["url"].value directly from the DOM, so no functionality is lost.
Bug 2 (mcpgateway/admin_ui/formFieldHandlers.js, mcpgateway/templates/admin.html):
#ui-builderdiv: addeddark:border-gray-600 dark:bg-gray-800#passthrough-containerfieldset: addeddark:border-gray-600 dark:bg-gray-700handleAddParameterparameter card: addeddark:bg-gray-700 dark:border-gray-600createParameterFormname input, type select, description textarea: addeddark:border-gray-600 dark:bg-gray-800 dark:text-gray-200 dark:placeholder-gray-400
Bundle rebuilt after both source changes.
๐งช Verification
| Check | Command | Status |
|---|---|---|
| Lint suite | make lint |
|
| Unit tests | make test |
|
| Coverage โฅ 80 % | make coverage |
|
| Schema builder persists on submit | manual โ create tool via UI mode, verify input_schema non-empty |
|
| Dark mode renders correctly | manual โ toggle dark mode, open schema builder, add parameter |
๐ MCP Compliance (if relevant)
- [x] No breaking change to MCP clients
โ Checklist
- [ ] Code formatted (
make black isort pre-commit) - [ ] No secrets/credentials committed
Hi, @madhav165, thanks for the PR! Could you please resolve the conflicts on it at your convenience?