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


##########
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:
   Checked the source: the header, separator and all rows already start with a 
single `|`. There is no leading `||`, so no change is needed here.



##########
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:
   Fixed in 108d708958. Added `@abstractmethod` and replaced 
`NotImplementedError` with `pass`. Also implemented the Domain facet in 
`MockOperation` and added a test exercising all five tools with the mock 
client. All 308 MCP tests, formatting checks and pylint pass.



##########
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:
   Fixed in 108d708958. All five decorators now reuse 
`_READONLY_TOOL_ANNOTATIONS`; the registration test continues to verify each 
tool's read-only, non-destructive and idempotent annotations.



##########
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:
   Addressed together with the identical comment above in 108d708958: all five 
tools now share `_READONLY_TOOL_ANNOTATIONS`.



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