-
Notifications
You must be signed in to change notification settings - Fork 244
Description
🧭 Type of Feature
Please select the most appropriate category:
- Enhancement to existing functionality
- New feature or capability
- New MCP-compliant server
- New component or integration
- Developer tooling or test improvement
- Packaging, automation and deployment (ex: pypi, docker, quay.io, kubernetes, terraform)
- Other (please describe below)
🧭 Epic
Title: Bulk Tool Import
Goal: Enable administrators to import many Tools in a single request, with per-item validation and error reporting, to rapidly seed or migrate environments.
Why now: Teams are onboarding multiple REST/MCP tools; creating them one-by-one is slow and error-prone. A bulk importer reduces friction, supports reproducible setups across environments, and accelerates adoption.
🙋♂️ User Story 1
As a: Gateway administrator
I want: to POST a JSON array of tool definitions to a protected endpoint
So that: I can seed dozens of tools quickly and get a clear success/error summary per item
✅ Acceptance Criteria
Scenario: Bulk import succeeds for valid tools
Given I have a valid admin JWT
And a JSON array of valid ToolCreate objects
When I POST to /admin/tools/import with Content-Type application/json
Then the response status is 200
And the body contains success:true and created_count equal to the number of tools
And failed_count is 0
Scenario: Mixed valid/invalid items return partial success
Given I have a valid admin JWT
And a JSON array with some invalid ToolCreate objects
When I POST to /admin/tools/import
Then the response status is 200
And the body lists created items under "created"
And invalid items under "errors" with index, name, and a validation or integrity message
And success is false if any items failed
Scenario: Missing or malformed JSON
Given I POST to /admin/tools/import with malformed JSON
Then the response status is 422
And the body explains the JSON parsing or shape error
Scenario: Too large a batch
Given a JSON array with more than 200 items
When I POST to /admin/tools/import
Then the response status is 413
And the body states the max batch size
Scenario: Rate limit exceeded
Given I make more than 10 requests within one minute from the same client
When I POST again to /admin/tools/import
Then the response status is 429
Scenario: Unauthorized access
Given I do not provide a valid admin JWT
When I POST to /admin/tools/import
Then the response status is 401
🙋♂️ User Story 2
As a: Gateway administrator
I want: a simple Admin UI affordance to paste/upload JSON and trigger the same bulk import
So that: I can perform imports without crafting curl commands
✅ Acceptance Criteria
Scenario: UI affordance (follow-up PR)
Given I am on the Admin UI "Tools" tab
When I click "Import Tools"
Then I see a modal with a textarea (paste JSON) and optional file upload
And upon submit, the UI calls POST /admin/tools/import with the admin JWT
And shows a success toast with created_count and failed_count
And renders per-item errors inline or as a downloadable report
📐 Design Sketch (optional)
Include a diagram, sketch, or flow (use Mermaid if desired):
flowchart TD
A[Admin (Basic Auth)] -->|GET /admin| B[Admin UI]
B -->|JWT cookie (httponly)| A
A -->|POST JSON array| C[/admin/tools/import/]
C --> D[Validate each ToolCreate]
D --> E{OK?}
E -- yes --> F[tool_service.register_tool]
E -- no --> G[Collect validation/integrity error]
F --> H[Aggregate results]
G --> H[Aggregate results]
H -->|200 Summary| A
🔗 MCP Standards Check
- Change adheres to current MCP specifications
- No breaking changes to existing MCP-compliant integrations
- If deviations exist, please describe them below:
🔄 Alternatives Considered
Manual creation via Admin UI / single POST per tool
Rejected: too slow and error-prone at scale.
Database seeding scripts / fixtures
Rejected: bypasses validation/business logic; brittle across versions; harder for admins to use.
CLI wrapper around existing APIs
Considered: useful later; API-first solves broader automation needs.