Skip to content

Commit 6f071a4

Browse files
Merge branch 'resolve-ticket' into resolve-ticket
2 parents 47bd78e + 2e49983 commit 6f071a4

File tree

5 files changed

+152
-0
lines changed

5 files changed

+152
-0
lines changed

cookies.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Netscape HTTP Cookie File
2+
# https://curl.se/docs/http-cookies.html
3+
# This file was generated by libcurl! Edit at your own risk.

headers.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
HTTP/1.1 307 Temporary Redirect
2+
date: Wed, 13 Aug 2025 05:39:40 GMT
3+
server: uvicorn
4+
content-length: 0
5+
location: http://localhost:4444/admin/

mcpgateway/static/admin.js

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7133,3 +7133,73 @@ function setupBulkImportModal() {
71337133
});
71347134
}
71357135
}
7136+
7137+
// BULK IMPORT MODAL WIRING
7138+
// ===================================================================
7139+
7140+
function clearBulkImportResult() {
7141+
const resultEl = safeGetElement("import-result", true);
7142+
if (resultEl) {
7143+
resultEl.innerHTML = "";
7144+
}
7145+
const indicator = safeGetElement("import-indicator", true);
7146+
if (indicator) {
7147+
indicator.classList.add("hidden");
7148+
}
7149+
}
7150+
7151+
function setupBulkImportModal() {
7152+
const openBtn = safeGetElement("open-bulk-import", true);
7153+
const modal = safeGetElement("bulk-import-modal", true);
7154+
const backdrop = safeGetElement("bulk-import-backdrop", true);
7155+
const closeBtn = safeGetElement("close-bulk-import", true);
7156+
7157+
if (!openBtn || !modal) {
7158+
return;
7159+
}
7160+
if (openBtn.dataset.wired === "1") {
7161+
return; // prevent double wiring
7162+
}
7163+
openBtn.dataset.wired = "1";
7164+
7165+
// OPEN → clear results, open modal, focus JSON/FILE
7166+
openBtn.addEventListener("click", (e) => {
7167+
e.preventDefault();
7168+
clearBulkImportResult();
7169+
openModal("bulk-import-modal");
7170+
setTimeout(() => {
7171+
const ta = modal.querySelector('textarea[name="tools_json"]');
7172+
const file = modal.querySelector('input[type="file"]');
7173+
(ta || file)?.focus?.();
7174+
}, 0);
7175+
});
7176+
7177+
// CLOSE BUTTON → close & clear
7178+
if (closeBtn) {
7179+
closeBtn.addEventListener("click", (e) => {
7180+
e.preventDefault();
7181+
closeModal("bulk-import-modal", "import-result");
7182+
});
7183+
}
7184+
7185+
// BACKDROP → close & clear
7186+
if (backdrop) {
7187+
backdrop.addEventListener("click", () => {
7188+
closeModal("bulk-import-modal", "import-result");
7189+
});
7190+
}
7191+
7192+
// ESC → close & clear
7193+
document.addEventListener("keydown", (e) => {
7194+
if (e.key === "Escape" && AppState.isModalActive("bulk-import-modal")) {
7195+
closeModal("bulk-import-modal", "import-result");
7196+
}
7197+
});
7198+
}
7199+
7200+
document.addEventListener("DOMContentLoaded", () => {
7201+
try {
7202+
setupBulkImportModal();
7203+
} catch (_) {}
7204+
});
7205+

mcpgateway/templates/admin.html

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1324,6 +1324,61 @@ <h3 class="text-lg font-bold dark:text-gray-200">Add New Tool</h3>
13241324
</div>
13251325
</form>
13261326
</div>
1327+
<!-- Modal -->
1328+
<div id="bulk-import-modal" class="fixed inset-0 z-[60] hidden">
1329+
<div id="bulk-import-backdrop" class="absolute inset-0 bg-black/50"></div>
1330+
<div role="dialog" aria-modal="true"
1331+
class="relative mx-auto my-12 w-full max-w-2xl rounded-xl bg-white p-0 shadow-xl dark:bg-gray-900">
1332+
<div class="flex items-center justify-between border-b px-5 py-3 dark:border-gray-700">
1333+
<h3 class="text-base font-semibold dark:text-gray-100">Bulk Import Tools</h3>
1334+
<button id="close-bulk-import" data-close-bulk-import
1335+
class="rounded p-1 text-gray-500 hover:bg-gray-100 dark:text-gray-300 dark:hover:bg-gray-800"
1336+
aria-label="Close"></button>
1337+
</div>
1338+
1339+
<form id="bulk-import-form"
1340+
hx-post="{{ root_path }}/admin/tools/import"
1341+
hx-target="#bulk-import-result"
1342+
hx-swap="innerHTML"
1343+
hx-indicator="#bulk-import-indicator"
1344+
enctype="multipart/form-data"
1345+
class="space-y-4 p-5">
1346+
<p class="text-sm text-gray-600 dark:text-gray-400">
1347+
Paste a JSON array or upload a <code>.json</code> file. Max 200 tools.
1348+
</p>
1349+
1350+
<label class="block text-sm font-medium dark:text-gray-300" for="tools_json">JSON Data</label>
1351+
<textarea id="tools_json" name="tools_json" rows="8"
1352+
class="mt-1 block w-full rounded-md border border-gray-300 font-mono text-sm shadow-sm
1353+
focus:border-indigo-500 focus:ring-indigo-500 dark:border-gray-700 dark:bg-gray-900 dark:text-gray-300"
1354+
placeholder="[{&quot;name&quot;:&quot;tool_name&quot;,&quot;url&quot;:&quot;https://...&quot;,&quot;integration_type&quot;:&quot;REST&quot;,&quot;request_type&quot;:&quot;GET&quot;}]"></textarea>
1355+
1356+
<div>
1357+
<label class="block text-sm font-medium dark:text-gray-300" for="tools_file">Or upload JSON file</label>
1358+
<input id="tools_file" name="tools_file" type="file" accept="application/json,.json"
1359+
class="mt-1 block w-full text-sm dark:text-gray-300" />
1360+
</div>
1361+
1362+
<div class="flex items-center gap-3 pt-1">
1363+
<button type="submit"
1364+
class="inline-flex justify-center rounded-md bg-indigo-600 px-4 py-2 text-sm font-medium text-white
1365+
hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-indigo-500">
1366+
Import Tools
1367+
</button>
1368+
<span id="bulk-import-indicator" class="htmx-indicator items-center text-sm text-gray-500 dark:text-gray-400" style="display: none;">
1369+
<svg class="mr-2 h-4 w-4 animate-spin" viewBox="0 0 24 24" fill="none">
1370+
<circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"/>
1371+
<path class="opacity-75" fill="currentColor"
1372+
d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"/>
1373+
</svg>
1374+
Processing...
1375+
</span>
1376+
</div>
1377+
1378+
<div id="bulk-import-result" class="pt-2"></div>
1379+
</form>
1380+
</div>
1381+
</div>
13271382
</div>
13281383

13291384
<!-- Bulk Import Modal -->

tools.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
[
2+
{
3+
"name": "list_users",
4+
"url": "https://api.example.com/users",
5+
"integration_type": "REST",
6+
"request_type": "GET"
7+
},
8+
{
9+
"name": "create_user",
10+
"url": "https://api.example.com/users",
11+
"integration_type": "REST",
12+
"request_type": "POST",
13+
"input_schema": {
14+
"type": "object",
15+
"properties": { "body": { "type": "object" } },
16+
"required": ["body"]
17+
}
18+
}
19+
]

0 commit comments

Comments
 (0)