mchades commented on code in PR #14208:
URL: https://github.com/apache/gravitino/pull/14208#discussion_r4409861969


##########
mcp-server/mcp_server/client/plain/utils.py:
##########
@@ -37,6 +39,31 @@ def extract_content_from_response(response, field: str, 
default="") -> str:
     return json.dumps(response_json.get(field, default))
 
 
+def extract_list_from_response(response, field: str) -> str:
+    """Extract a required JSON array without rounding fractional numbers.
+
+    Propagate server errors and reject malformed envelopes instead of returning
+    an empty result for a failed discovery request.
+    """
+    try:
+        payload = simplejson.loads(response.content, use_decimal=True)
+    except simplejson.JSONDecodeError as exc:
+        response.raise_for_status()
+        raise GravitinoException(
+            "Invalid Gravitino response: invalid JSON"
+        ) from exc
+    if isinstance(payload, dict):
+        _handle_gravitino_exception(payload)
+    response.raise_for_status()
+    if not isinstance(payload, dict) or "code" not in payload:
+        raise GravitinoException("Invalid Gravitino response: missing code")
+    if not isinstance(payload.get(field), list):
+        raise GravitinoException(
+            f"Invalid Gravitino response: {field} must be a JSON array"
+        )
+    return simplejson.dumps(payload[field], use_decimal=True)

Review Comment:
   Fixed in 471a01b954. Both shared response extractors now preserve decimal 
precision, so loading a semantic model returns the same `aiContext` numbers as 
listing its metrics. Added regression coverage for both shared extractors and 
the list/load sequence.



##########
mcp-server/mcp_server/tools/semantic_model.py:
##########
@@ -43,6 +44,65 @@ async def list_of_semantic_models(
             )
         )
 
+    @mcp.tool(
+        tags={"semantic_model"},
+        annotations=ToolAnnotations(
+            readOnlyHint=True, destructiveHint=False, idempotentHint=True

Review Comment:
   Added the same read-only annotations to `list_of_semantic_models` and 
`load_semantic_model` in 471a01b954. The `tools/list` test now covers all four 
read-only semantic-model tools.



##########
docs/gravitino-mcp-server.md:
##########
@@ -139,6 +139,8 @@ Gravitino MCP server supports the following tools, and you 
could export tool by
 | `list_of_views`                     | Retrieve a list of views for a schema. 
Only for catalogs supporting views.     | `view`          |
 | `load_view`                         | Retrieve a view's metadata. Only for 
catalogs supporting views.                | `view`          |
 | `list_of_semantic_models`           | List the Semantic Models the caller 
can access in a schema.                    | `semantic_model` |
+| `list_metrics`                      | List visible metric identifiers across 
Semantic Models in a schema.           | `semantic_model` |
+| `list_metric_infos`                 | List complete visible metrics across 
Semantic Models in a schema.             | `semantic_model` |

Review Comment:
   This update is already included in #14210, which adds both tool names to 
that list and depends on this PR.



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