Skip to content

Commit da2e25b

Browse files
authored
Merge pull request #742 from IBM/fix-edit-form
Fix edit tools
2 parents 1212872 + 46840ab commit da2e25b

File tree

3 files changed

+35
-58
lines changed

3 files changed

+35
-58
lines changed

mcpgateway/admin.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2144,8 +2144,6 @@ async def admin_edit_tool(
21442144
"name": form.get("name"),
21452145
"url": form.get("url"),
21462146
"description": form.get("description"),
2147-
"request_type": form.get("requestType", "SSE"),
2148-
"integration_type": form.get("integrationType", "REST"),
21492147
"headers": json.loads(form.get("headers") or "{}"),
21502148
"input_schema": json.loads(form.get("input_schema") or "{}"),
21512149
"jsonpath_filter": form.get("jsonpathFilter", ""),
@@ -2157,6 +2155,12 @@ async def admin_edit_tool(
21572155
"auth_header_value": form.get("auth_header_value", ""),
21582156
"tags": tags,
21592157
}
2158+
# Only include integration_type if it's provided (not disabled in form)
2159+
if "integrationType" in form:
2160+
tool_data["integration_type"] = form.get("integrationType")
2161+
# Only include request_type if it's provided (not disabled in form)
2162+
if "requestType" in form:
2163+
tool_data["request_type"] = form.get("requestType")
21602164
logger.debug(f"Tool update data built: {tool_data}")
21612165
try:
21622166
tool = ToolUpdate(**tool_data) # Pydantic validation happens here

mcpgateway/static/admin.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1994,6 +1994,12 @@ async function editTool(toolId) {
19941994
// Prefill integration type from DB and set request types accordingly
19951995
if (typeField) {
19961996
typeField.value = tool.integrationType || "REST";
1997+
// Disable integration type field for MCP tools (cannot be changed)
1998+
if (tool.integrationType === "MCP") {
1999+
typeField.disabled = true;
2000+
} else {
2001+
typeField.disabled = false;
2002+
}
19972003
updateEditToolRequestTypes(tool.requestType || null); // preselect from DB
19982004
}
19992005

mcpgateway/templates/admin.html

Lines changed: 23 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -963,37 +963,17 @@ <h3 class="text-lg font-bold mb-4 dark:text-gray-200">
963963
</h3>
964964
<form id="add-tool-form">
965965
<div class="grid grid-cols-1 gap-6">
966-
<div class="grid grid-cols-1 md:grid-cols-2 gap-6">
967-
<div>
968-
<label class="block text-sm font-medium text-gray-700 dark:text-gray-400">
969-
Gateway Name
970-
</label>
971-
<input
972-
type="text"
973-
name="gateway_name"
974-
id="add-tool-gateway-name"
975-
placeholder="e.g., local-gateway"
976-
class="mt-1 block w-full rounded-md border border-gray-300 dark:border-gray-700 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 dark:bg-gray-900 dark:placeholder-gray-300 dark:text-gray-300"
977-
/>
978-
<p class="mt-1 text-xs text-gray-500 dark:text-gray-400">
979-
Optional for REST tools; populated for MCP-imported tools.
980-
</p>
981-
</div>
982-
<div>
983-
<label class="block text-sm font-medium text-gray-700 dark:text-gray-400">
984-
Original Name
985-
</label>
986-
<input
987-
type="text"
988-
name="original_name"
989-
id="add-tool-original-name"
990-
placeholder="e.g., list-files"
991-
class="mt-1 block w-full rounded-md border border-gray-300 dark:border-gray-700 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 dark:bg-gray-900 dark:placeholder-gray-300 dark:text-gray-300"
992-
/>
993-
<p class="mt-1 text-xs text-gray-500 dark:text-gray-400">
994-
Tool's name as provided by the gateway.
995-
</p>
996-
</div>
966+
<div>
967+
<label
968+
class="block text-sm font-medium text-gray-700 dark:text-gray-400"
969+
>Name</label
970+
>
971+
<input
972+
type="text"
973+
name="name"
974+
required
975+
class="mt-1 block w-full rounded-md border border-gray-300 dark:border-gray-700 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 dark:bg-gray-900 dark:placeholder-gray-300 dark:text-gray-300"
976+
/>
997977
</div>
998978

999979
<div>
@@ -2656,30 +2636,18 @@ <h3 class="text-lg font-medium text-gray-900 dark:text-gray-100">
26562636
<div class="mt-4">
26572637
<form id="edit-tool-form" method="POST">
26582638
<div class="grid grid-cols-1 gap-6">
2659-
2660-
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
2661-
<div>
2662-
<label class="block text-sm font-medium text-gray-700 dark:text-gray-300">
2663-
Gateway Name
2664-
</label>
2665-
<input
2666-
type="text"
2667-
name="gateway_name"
2668-
id="edit-tool-gateway-name"
2669-
class="mt-1 block w-full rounded-md border border-gray-300 dark:border-gray-600 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 dark:bg-gray-900 dark:placeholder-gray-300 dark:text-gray-300"
2670-
/>
2671-
</div>
2672-
<div>
2673-
<label class="block text-sm font-medium text-gray-700 dark:text-gray-300">
2674-
Original Name
2675-
</label>
2676-
<input
2677-
type="text"
2678-
name="original_name"
2679-
id="edit-tool-original-name"
2680-
class="mt-1 block w-full rounded-md border border-gray-300 dark:border-gray-600 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 dark:bg-gray-900 dark:placeholder-gray-300 dark:text-gray-300"
2681-
/>
2682-
</div>
2639+
<div>
2640+
<label
2641+
class="block text-sm font-medium text-gray-700 dark:text-gray-300"
2642+
>Name</label
2643+
>
2644+
<input
2645+
type="text"
2646+
name="name"
2647+
required
2648+
id="edit-tool-name"
2649+
class="mt-1 block w-full rounded-md border border-gray-300 dark:border-gray-600 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 dark:bg-gray-900 dark:placeholder-gray-300 dark:text-gray-300"
2650+
/>
26832651
</div>
26842652

26852653
<div>
@@ -2717,7 +2685,6 @@ <h3 class="text-lg font-medium text-gray-900 dark:text-gray-100">
27172685
class="mt-1 block w-full rounded-md border border-gray-300 dark:border-gray-600 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 dark:bg-gray-900 dark:placeholder-gray-300 dark:text-gray-300"
27182686
onchange="handleEditIntegrationTypeChange()"
27192687
>
2720-
27212688
<option value="REST">REST</option>
27222689
<option value="MCP">MCP</option>
27232690
</select>

0 commit comments

Comments
 (0)