MonkeyCanCode commented on code in PR #89:
URL: https://github.com/apache/polaris-tools/pull/89#discussion_r2617256191


##########
mcp-server/polaris_mcp/tools/catalog.py:
##########
@@ -111,41 +111,56 @@ def call(self, arguments: Any) -> ToolExecutionResult:
             delegate_args["realm"] = realm
 
         if normalized == "list":
-            delegate_args["method"] = "GET"
-            delegate_args["path"] = "catalogs"
+            self._handle_list(delegate_args)
         elif normalized == "get":
-            catalog_name = encode_path_segment(require_text(arguments, 
"catalog"))
-            delegate_args["method"] = "GET"
-            delegate_args["path"] = f"catalogs/{catalog_name}"
+            self._handle_get(arguments, delegate_args)
         elif normalized == "create":
-            body = arguments.get("body")
-            if not isinstance(body, dict):
-                raise ValueError(
-                    "Create operations require a body matching 
CreateCatalogRequest."
-                )
-            delegate_args["method"] = "POST"
-            delegate_args["path"] = "catalogs"
-            delegate_args["body"] = copy.deepcopy(body)
+            self._handle_create(arguments, delegate_args)
         elif normalized == "update":
-            catalog_name = encode_path_segment(require_text(arguments, 
"catalog"))
-            body = arguments.get("body")
-            if not isinstance(body, dict):
-                raise ValueError(
-                    "Update operations require a body matching 
UpdateCatalogRequest."
-                )
-            delegate_args["method"] = "PUT"
-            delegate_args["path"] = f"catalogs/{catalog_name}"
-            delegate_args["body"] = copy.deepcopy(body)
+            self._handle_update(arguments, delegate_args)
         elif normalized == "delete":
-            catalog_name = encode_path_segment(require_text(arguments, 
"catalog"))
-            delegate_args["method"] = "DELETE"
-            delegate_args["path"] = f"catalogs/{catalog_name}"
+            self._handle_delete(arguments, delegate_args)
         else:  # pragma: no cover
             raise ValueError(f"Unsupported operation: {operation}")
 
         raw = self._rest_client.call(delegate_args)
         return self._maybe_augment_error(raw, normalized)
 
+    def _handle_list(self, delegate_args: JSONDict) -> None:
+        delegate_args["method"] = "GET"
+        delegate_args["path"] = "catalogs"
+
+    def _handle_get(self, arguments: dict, delegate_args: JSONDict) -> None:
+        catalog_name = encode_path_segment(require_text(arguments, "catalog"))
+        delegate_args["method"] = "GET"
+        delegate_args["path"] = f"catalogs/{catalog_name}"
+
+    def _handle_create(self, arguments: dict, delegate_args: JSONDict) -> None:
+        body = arguments.get("body")
+        if not isinstance(body, dict):

Review Comment:
   That is a great idea. Let me do it in a diff PR as well as the additional 
prompt with usage. Tracker: https://github.com/apache/polaris-tools/issues/97



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to