Skip to content

Conversation

vk-playground
Copy link
Contributor

Original ticket PR #739 only delivered modal wiring and documented a draft schema; this PR completes the UI to match the finalized backend. It delivers end-to-end support for importing multiple tools via JSON file upload or paste, enforcing validation rules, and handling partial success cases.

Key Changes

Frontend (admin.html / JS)

Added Bulk Import modal with:

  • Drag-and-drop JSON file upload support.
image - JSON paste input with real-time debounce validation. image

Backend

  • Endpoint: POST /admin/tools/import
  • Authentication: Admin only, JWT-based.
  • Rate limiting: 10 requests/minute.
  • Transaction-safe batch persistence with rollback support.
{
  "success": true,
  "created_count": 2,
  "failed_count": 0,
  "created": [{"index":0,"name":"tool_1"},{"index":1,"name":"tool_2"}],
  "errors": []
}

Configuration

Environment variables required:

export MCPGATEWAY_UI_ENABLED=true
export MCPGATEWAY_ADMIN_API_ENABLED=true
export BASIC_AUTH_USER=admin
export BASIC_AUTH_PASSWORD=admin
export JWT_SECRET_KEY=my-test-key
export MCPGATEWAY_BULK_IMPORT_ENABLED="true"

Validation Rules

  • Tool name must start with a letter and contain only alphanumeric or underscores.
  • Required fields: name, url, description.
  • Optional fields: integration type, request type, tags, headers, auth.
  • Maximum: 200 tools per batch.
  • File format supported: JSON array only.

Testing Scenarios

  • Successful batch import of 10 tools. Ex:
[
  {
    "name": "Tool_A",
    "url": "https://api.example.com/alpha",
    "description": "Alpha test tool for bulk import",
    "integration_type": "REST",
    "request_type": "GET",
    "tags": ["alpha", "test", "api"]
  },
  {
    "name": "Tool_B",
    "url": "https://api.example.com/beta",
    "description": "Beta test tool for bulk import",
    "integration_type": "REST",
    "request_type": "POST",
    "tags": ["beta", "import"]
  },
  {
    "name": "Tool_C",
    "url": "https://service.example.com/gamma",
    "description": "Gamma service integration",
    "integration_type": "MCP",
    "request_type": "GET",
    "headers": { "Accept": "application/json" }
  },
  {
    "name": "Tool_D",
    "url": "http://localhost:8080/delta",
    "description": "Local delta tool for testing",
    "integration_type": "REST",
    "request_type": "POST"
  },
  {
    "name": "Tool_E",
    "url": "https://tools.example.com/epsilon",
    "description": "Epsilon tool description",
    "integration_type": "REST",
    "request_type": "GET",
    "tags": ["epsilon", "utility"]
  },
  {
    "name": "Tool_F",
    "url": "https://api.example.com/zeta",
    "description": "Zeta bulk import test",
    "integration_type": "REST",
    "request_type": "POST",
    "auth": { "type": "basic", "username": "user", "password": "pass" }
  },
  {
    "name": "Tool_G",
    "url": "https://service.example.com/eta",
    "description": "Eta example service",
    "integration_type": "MCP",
    "request_type": "GET"
  },
  {
    "name": "Tool_H",
    "url": "https://tools.example.com/theta",
    "description": "Theta integration tool",
    "integration_type": "REST",
    "request_type": "POST",
    "tags": ["theta", "integration", "api"]
  },
  {
    "name": "Tool_I",
    "url": "https://api.example.com/iota",
    "description": "Iota test API tool",
    "integration_type": "REST",
    "request_type": "GET"
  },
  {
    "name": "Tool_J",
    "url": "https://service.example.com/kappa",
    "description": "Kappa service test tool",
    "integration_type": "REST",
    "request_type": "POST",
    "tags": ["kappa", "test"]
  }
]
  • Invalid JSON syntax error handling.
  • Duplicate name rejection.
  • Partial success when some tools are invalid.
  • Import rate limit enforcement.

Vicky and others added 2 commits August 21, 2025 10:15
@crivetimihai
Copy link
Member

Review and rebase in progress, please do not make further changes.

Signed-off-by: Mihai Criveti <[email protected]>
@rakdutta rakdutta assigned rakdutta and unassigned rakdutta Aug 21, 2025
@crivetimihai crivetimihai requested a review from rakdutta August 21, 2025 11:05
Copy link
Member

@crivetimihai crivetimihai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rebased, merged, tested

Copy link
Collaborator

@rakdutta rakdutta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Testing Summary

  • make serve – ✅ Pass
  • make test – ✅ Pass (75%, 2135 passed, 15 skipped, 599 warnings in 194.55s)
  • make autoflake isort black flake8 – ✅ No errors
  • make pylint – ✅ Pass (Your code has been rated at 10.00/10)
  • make smoketest – ✅ Pass (Smoketest passed!)
  • make doctest – ✅ Pass (45%, 491 passed, 6 skipped, 68 warnings in 29.17s)

Bulk Import functionality is working fine.

Tests Performed

  • Paste JSON option – Verified with example JSON input.
  • Upload file option – Verified with example JSON file.
  • Existing tool name – Tested handling of duplicate tool names.
  • Invalid tool names – Tested cases where the tool name starts with a number, contains only numbers, or includes special characters.

Example JSON contained 10 tools, but only 8 tools were successfully registered.


Observations

  1. Missing Tools – Tools such as Tool_C and Tool_H were not registered, and no error message was displayed.
  2. Error Handling – Integrity errors (e.g., duplicate name) are not surfaced in the UI.
  3. Validation Errors – Validation issues are not consistently shown in the UI or backend logs.
  4. Registration Summary – UI does not display the number of tools successfully registered.
  5. Unregistered Tool Details – Tools that fail to register should provide error details (both in UI and logs) so users can identify which tools failed and why, and developers can analyze the root cause later.
  6. Add Server, Add Gateway, and Add Tool – All functionalities are working as expected.

@crivetimihai crivetimihai merged commit 7edc4fc into IBM:main Aug 21, 2025
36 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants