Copilot commented on code in PR #14893:
URL: https://github.com/apache/gravitino/pull/14893#discussion_r4540265578


##########
docs/gravitino-mcp-server.md:
##########
@@ -193,6 +193,51 @@ an ordered, non-empty `updates` array. Supported `@type` 
values are `rename`,
 `drop_semantic_model` takes the model's catalog, schema, and name and returns 
a JSON boolean
 indicating whether it was dropped. It removes semantic metadata without 
deleting source tables or data.
 
+### Domains (read-only)
+
+Use `--include-tool-tags domain` to expose the five Domain tools.
+All are annotated as read-only and idempotent and issue only GET requests.
+
+| Tool | Arguments | Result |
+|------|-----------|--------|
+| `list_of_domains` | `details=true` | Domain snapshots, or names when false |
+| `get_domain_by_name` | `domain_name` | A complete domain snapshot |
+| `list_subdomains` | `domain_name`, `details=true` | Immediate subdomain 
snapshots or names |
+| `list_domain_members` | `domain_name`, optional `types`, `domains`, 
`name_contains` | Recorded leaf members with all applicable relations |
+| `list_domains_for_metadata` | `metadata_type`, `metadata_full_name`, 
`details=true` | Domains of a leaf object, including all relations when details 
is true |

Review Comment:
   The table is formatted with a leading double pipe (`||`), which typically 
renders as an extra empty column in Markdown. Update it to standard table 
syntax starting with a single `|` so it renders correctly in common Markdown 
renderers.



##########
mcp-server/mcp_server/client/gravitino_operation.py:
##########
@@ -171,3 +172,7 @@ def as_metalake_operation(self) -> MetalakeOperation:
             MetalakeOperation: Interface for metalake-level operations
         """
         pass
+
+    def as_domain_operation(self) -> DomainOperation:
+        """Access the read-only domain operation interface."""
+        raise NotImplementedError

Review Comment:
   `GravitinoOperation` is an ABC and the other `as_*_operation()` accessors 
are abstract; this new accessor should follow the same contract (declare it 
`@abstractmethod` and use `pass`). Leaving it as a concrete method that raises 
`NotImplementedError` makes the abstract interface less enforceable and can 
allow subclasses to omit the method without an immediate error.



##########
mcp-server/mcp_server/tools/domain.py:
##########
@@ -0,0 +1,135 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+from fastmcp import Context, FastMCP
+
+
+def load_domain_tools(mcp: FastMCP):
+    """Register only read-only domain tools."""
+
+    @mcp.tool(
+        tags={"domain"},
+        annotations={
+            "readOnlyHint": True,
+            "destructiveHint": False,
+            "idempotentHint": True,
+        },
+    )

Review Comment:
   The identical `annotations` dict is duplicated across all five tools. 
Consider extracting a shared constant (e.g., `READONLY_TOOL_ANNOTATIONS`) and 
reusing it for each decorator to avoid drift if the annotation set changes 
later.



##########
mcp-server/mcp_server/tools/domain.py:
##########
@@ -0,0 +1,135 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+from fastmcp import Context, FastMCP
+
+
+def load_domain_tools(mcp: FastMCP):
+    """Register only read-only domain tools."""
+
+    @mcp.tool(
+        tags={"domain"},
+        annotations={
+            "readOnlyHint": True,
+            "destructiveHint": False,
+            "idempotentHint": True,
+        },
+    )
+    async def list_of_domains(ctx: Context, details: bool = True) -> str:
+        """List domains; details includes backingTag, status, parent and audit.
+
+        Returns a JSON string; empty lists are returned as [].
+        Authorization and errors are enforced by the Gravitino server.
+        """
+        client = ctx.request_context.lifespan_context.rest_client()
+        return await client.as_domain_operation().list_of_domains(details)
+
+    @mcp.tool(
+        tags={"domain"},
+        annotations={
+            "readOnlyHint": True,
+            "destructiveHint": False,
+            "idempotentHint": True,
+        },
+    )

Review Comment:
   The identical `annotations` dict is duplicated across all five tools. 
Consider extracting a shared constant (e.g., `READONLY_TOOL_ANNOTATIONS`) and 
reusing it for each decorator to avoid drift if the annotation set changes 
later.



-- 
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