mcp-context-forge icon indicating copy to clipboard operation
mcp-context-forge copied to clipboard

fix: schema builder input_schema not persisting and dark mode missing styles

Open madhav165 opened this issue 6 months ago โ€ข 1 comments

๐Ÿ› Bug-fix PR


๐Ÿ“Œ Summary

Two bugs in the REST tool creation schema builder in the Admin UI:

  1. Schema not persisting โ€” tools created via the Schema Builder (UI mode) were saved with an empty input_schema every time. JSON Input mode worked correctly.
  2. 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:

  1. Admin UI โ†’ Tools โ†’ "Add New Tool from REST API"
  2. Select Schema Builder mode (default)
  3. Add a parameter, fill in name/type/description
  4. Submit โ€” tool is created with input_schema: {}

Bug 2 โ€” dark mode:

  1. Toggle dark mode in the Admin UI
  2. Navigate to Tools โ†’ "Add New Tool from REST API"
  3. 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-builder div: added dark:border-gray-600 dark:bg-gray-800
  • #passthrough-container fieldset: added dark:border-gray-600 dark:bg-gray-700
  • handleAddParameter parameter card: added dark:bg-gray-700 dark:border-gray-600
  • createParameterForm name input, type select, description textarea: added dark: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

madhav165 avatar May 26 '26 04:05 madhav165

Hi, @madhav165, thanks for the PR! Could you please resolve the conflicts on it at your convenience?

gcgoncalves avatar Jun 11 '26 14:06 gcgoncalves