You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@gravitino.apache.org by "yuqi1129 (via GitHub)" <gi...@apache.org> on 2025/08/11 11:53:42 UTC
[PR] [#8005] feat(mcp-server): Support read operations for fileset, topic and model in MCP server. [gravitino]
yuqi1129 opened a new pull request, #8018:
URL: https://github.com/apache/gravitino/pull/8018
### What changes were proposed in this pull request?
Support read operations for fileset, topic and model in MCP server.
### Why are the changes needed?
It's a feature for mcp-server.
Fix: #8005
### Does this PR introduce _any_ user-facing change?
N/A.
### How was this patch tested?
Test locally.
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#8005] feat(mcp-server): Support read operations for fileset, topic and model in MCP server. [gravitino]
Posted by "jerryshao (via GitHub)" <gi...@apache.org>.
jerryshao commented on code in PR #8018:
URL: https://github.com/apache/gravitino/pull/8018#discussion_r2269637428
##########
mcp-server/mcp_server/tools/fileset.py:
##########
@@ -0,0 +1,177 @@
+# 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_fileset_tools(mcp: FastMCP):
+ @mcp.tool(tags={"fileset"})
+ async def get_list_of_filesets(
+ ctx: Context,
+ catalog_name: str,
+ schema_name: str,
+ ):
+ """
+ Retrieve a list of filesets within a specific catalog and schema.
+
+ Parameters:
+ ctx (Context): The request context object containing lifespan context
+ and connector information.
+ catalog_name (str): The name of the catalog to filter filesets by.
+ schema_name (str): The name of the schema to filter filesets by.
+
+ Returns:
+ str: A JSON string representing an array of fileset identifiers.
+
+ Example Return Value:
+ [
+ {
+ "namespace": [
+ "test",
+ "fileset_catalog",
+ "fileset_schema1"
+ ],
+ "name": "fileset1"
+ }
+ ]
+ """
+ client = ctx.request_context.lifespan_context.rest_client()
+ return await client.as_fileset_operation().get_list_of_filesets(
+ catalog_name, schema_name
+ )
+
+ @mcp.tool(tags={"fileset"})
+ async def load_fileset(
+ ctx: Context,
+ catalog_name: str,
+ schema_name: str,
+ fileset_name: str,
+ ):
+ """
+ Load detailed information of a specific fileset.
+
+ Parameters:
+ ctx (Context): The request context object containing lifespan context
+ and connector information.
+ catalog_name (str): The name of the catalog containing the fileset.
+ schema_name (str): The name of the schema containing the fileset.
+ fileset_name (str): The name of the fileset to load.
+
+ Returns:
+ str: A JSON string containing full metadata of the specified fileset.
+
+ Example Return Value:
+ {
+ "name": "fileset1",
+ "comment": "",
+ "type": "managed",
+ "storageLocations": {
+ "location1": "file:/tmp/fileset1"
+ },
+ "properties": {
+ "default-location-name": "location1"
+ },
+ "audit": {
+ "creator": "anonymous",
+ "createTime": "2025-08-07T07:52:56.656313Z"
+ }
+ }
+ """
+ client = ctx.request_context.lifespan_context.rest_client()
+ return await client.as_fileset_operation().load_fileset(
+ catalog_name, schema_name, fileset_name
+ )
+
+ @mcp.tool(tags={"fileset"})
+ async def list_files_in_fileset(
+ ctx: Context,
+ catalog_name: str,
+ schema_name: str,
+ fileset_name: str,
+ location_name: str,
+ sub_path: str = "/",
+ ):
+ """
+ List files in a specific fileset.
+
+ Parameters:
+ ctx (Context): The request context object containing lifespan context
+ and connector information.
+ catalog_name (str): The name of the catalog containing the fileset.
+ schema_name (str): The name of the schema containing the fileset.
+ fileset_name (str): The name of the fileset to list files from.
+ location_name (str): The name of the location within the fileset.
+ sub_path (str): Sub-path within the fileset to list files from (default is root "/").
+
+ Returns:
+ str: A JSON string containing a list of files in the specified fileset.
+
+ Example Return Value:
+ [
+ {
+ "name": "2.txt",
+ "isDir": false,
+ "size": 2,
+ "lastModified": 1754911672329,
+ "path": "/fileset/fileset_catalog/fileset_schema1/fileset1/"
+ },
+ {
+ "name": "1.txt",
+ "isDir": false,
+ "size": 2,
+ "lastModified": 1754911668512,
+ "path": "/fileset/fileset_catalog/fileset_schema1/fileset1/"
+ }
+ ]
+ """
+ client = ctx.request_context.lifespan_context.rest_client()
+ return await client.as_fileset_operation().list_files_in_fileset(
+ catalog_name, schema_name, fileset_name, location_name, sub_path
+ )
+
+ @mcp.tool(tags={"fileset"})
+ async def get_fileset_location(
+ ctx: Context,
+ catalog_name: str,
+ schema_name: str,
+ fileset_name: str,
+ sub_path: str,
+ location_name: str,
+ ):
+ """
+ Get the location of a specific fileset.
+
+ Parameters:
+ ctx (Context): The request context object containing lifespan context
+ and connector information.
+ catalog_name (str): The name of the catalog containing the fileset.
+ schema_name (str): The name of the schema containing the fileset.
+ fileset_name (str): The name of the fileset to get the location for.
+ sub_path (str): Sub-path within the fileset.
+ location_name (str): The name of the location within the fileset.
+
+ Returns:
+ str: A JSON string containing the location information of the specified fileset.
+
+ Example Return Value:
+ file:/tmp/fileset1
+
+ """
+ client = ctx.request_context.lifespan_context.rest_client()
+ return await client.as_fileset_operation().get_fileset_location(
+ catalog_name, schema_name, fileset_name, sub_path, location_name
+ )
Review Comment:
This is not useful, please delete this tool.
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#8005] feat(mcp-server): Support read operations for fileset, topic and model in MCP server. [gravitino]
Posted by "yuqi1129 (via GitHub)" <gi...@apache.org>.
yuqi1129 commented on code in PR #8018:
URL: https://github.com/apache/gravitino/pull/8018#discussion_r2272431801
##########
mcp-server/mcp_server/client/plain/plain_rest_client_model_operation.py:
##########
@@ -0,0 +1,68 @@
+# 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 mcp_server.client import ModelOperation
+
+
+class PlainRESTClientModelOperation(ModelOperation):
+ """
+ Implementation of ModelOperation using a plain REST client.
+ """
+
+ def __init__(self, metalake_name: str, rest_client):
+ self.metalake_name = metalake_name
+ self.rest_client = rest_client
+
+ async def get_list_of_models(
+ self, catalog_name: str, schema_name: str
+ ) -> str:
+ response = await self.rest_client.get(
+ f"/api/metalakes/{self.metalake_name}/catalogs/{catalog_name}/schemas/{schema_name}/models"
+ )
+ return response.json().get("identifiers", [])
+
+ async def load_model(
+ self, catalog_name: str, schema_name: str, model_name: str
+ ) -> str:
+ response = await self.rest_client.get(
+ f"/api/metalakes/{self.metalake_name}/catalogs/{catalog_name}/schemas/{schema_name}/models/{model_name}"
+ )
+ return response.json().get("model", {})
+
+ async def list_model_versions(
+ self, catalog_name: str, schema_name: str, model_name: str
+ ) -> str:
+ response = await self.rest_client.get(
+ f"/api/metalakes/{self.metalake_name}/catalogs/{catalog_name}/schemas/{schema_name}/models/{model_name}/versions"
+ )
+ return response.json().get("versions", [])
+
+ async def load_model_version(
+ self, catalog_name: str, schema_name: str, model_name: str, version: int
+ ) -> str:
+ response = await self.rest_client.get(
+ f"/api/metalakes/{self.metalake_name}/catalogs/{catalog_name}/schemas/{schema_name}/models/{model_name}/versions/{version}"
+ )
Review Comment:
I have checked it. Module `mcp-server` uses `black` to detect and fix the format problem automatically, it will not modify a raw string like `f"xxxx"` to multiple lines, which is different from `pylint` as `pylint` will throw a message like `E501 line too long`
Do we need to introduce the checker`pylint` and resolve extra-long fields as `black` and `isort` used in the module have already been set as follows:
```toml
# content from ${GRAVITINO_HOME}/mcp-server/pyproject.toml
[tool.isort]
profile = "black"
line_length = 80
multi_line_output = 3
include_trailing_comma = true
force_grid_wrap = 0
use_parentheses = true
[tool.black]
line-length = 80
target-version = ['py38']
```
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#8005] feat(mcp-server): Support read operations for fileset, topic and model in MCP server. [gravitino]
Posted by "jerryshao (via GitHub)" <gi...@apache.org>.
jerryshao merged PR #8018:
URL: https://github.com/apache/gravitino/pull/8018
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#8005] feat(mcp-server): Support read operations for fileset, topic and model in MCP server. [gravitino]
Posted by "jerryshao (via GitHub)" <gi...@apache.org>.
jerryshao commented on code in PR #8018:
URL: https://github.com/apache/gravitino/pull/8018#discussion_r2269632286
##########
mcp-server/mcp_server/client/plain/plain_rest_client_model_operation.py:
##########
@@ -0,0 +1,68 @@
+# 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 mcp_server.client import ModelOperation
+
+
+class PlainRESTClientModelOperation(ModelOperation):
+ """
+ Implementation of ModelOperation using a plain REST client.
+ """
+
+ def __init__(self, metalake_name: str, rest_client):
+ self.metalake_name = metalake_name
+ self.rest_client = rest_client
+
+ async def get_list_of_models(
+ self, catalog_name: str, schema_name: str
+ ) -> str:
+ response = await self.rest_client.get(
+ f"/api/metalakes/{self.metalake_name}/catalogs/{catalog_name}/schemas/{schema_name}/models"
+ )
+ return response.json().get("identifiers", [])
+
+ async def load_model(
+ self, catalog_name: str, schema_name: str, model_name: str
+ ) -> str:
+ response = await self.rest_client.get(
+ f"/api/metalakes/{self.metalake_name}/catalogs/{catalog_name}/schemas/{schema_name}/models/{model_name}"
+ )
+ return response.json().get("model", {})
+
+ async def list_model_versions(
+ self, catalog_name: str, schema_name: str, model_name: str
+ ) -> str:
+ response = await self.rest_client.get(
+ f"/api/metalakes/{self.metalake_name}/catalogs/{catalog_name}/schemas/{schema_name}/models/{model_name}/versions"
+ )
+ return response.json().get("versions", [])
Review Comment:
You'd better list the detailed information for different model versions.
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#8005] feat(mcp-server): Support read operations for fileset, topic and model in MCP server. [gravitino]
Posted by "yuqi1129 (via GitHub)" <gi...@apache.org>.
yuqi1129 commented on code in PR #8018:
URL: https://github.com/apache/gravitino/pull/8018#discussion_r2272389693
##########
mcp-server/mcp_server/client/fileset_operation.py:
##########
@@ -0,0 +1,102 @@
+# 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 abc import ABC, abstractmethod
+
+
+class FilesetOperation(ABC):
+ """
+ Abstract base class for Gravitino fileset operations.
+ """
+
+ @abstractmethod
+ async def get_list_of_filesets(
+ self, catalog_name: str, schema_name: str
+ ) -> str:
+ """
+ Retrieve the list of filesets within a specified catalog.
+
+ Args:
+ catalog_name: Name of the catalog
+ schema_name: Name of the schema
+
+ Returns:
+ str: JSON-formatted string containing fileset list information
+ """
+ pass
+
+ @abstractmethod
+ async def load_fileset(
+ self, catalog_name: str, schema_name: str, fileset_name: str
+ ) -> str:
+ """
+ Load detailed information of a specific fileset.
+
+ Args:
+ catalog_name: Name of the catalog
+ schema_name: Name of the schema
+ fileset_name: Name of the fileset
+
+ Returns:
+ str: JSON-formatted string containing full fileset metadata
+ """
+ pass
+
+ @abstractmethod
+ async def list_files_in_fileset(
+ self,
+ catalog_name: str,
+ schema_name: str,
+ fileset_name: str,
+ location_name: str,
+ sub_path: str = "/",
+ ) -> str:
+ """
+ List files in a specific fileset.
+
+ Args:
+ catalog_name: Name of the catalog
+ schema_name: Name of the schema
+ fileset_name: Name of the fileset
+ sub_path: Sub-path within the fileset to list files from (default is root "/")
+ location_name: Name of the location
+
+ Returns:
+ str: JSON-formatted string containing list of files in the fileset
+ """
+ pass
+
+ @abstractmethod
+ async def get_fileset_location(
Review Comment:
done
##########
mcp-server/mcp_server/client/plain/plain_rest_client_model_operation.py:
##########
@@ -0,0 +1,68 @@
+# 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 mcp_server.client import ModelOperation
+
+
+class PlainRESTClientModelOperation(ModelOperation):
+ """
+ Implementation of ModelOperation using a plain REST client.
+ """
+
+ def __init__(self, metalake_name: str, rest_client):
+ self.metalake_name = metalake_name
+ self.rest_client = rest_client
+
+ async def get_list_of_models(
+ self, catalog_name: str, schema_name: str
+ ) -> str:
+ response = await self.rest_client.get(
+ f"/api/metalakes/{self.metalake_name}/catalogs/{catalog_name}/schemas/{schema_name}/models"
+ )
+ return response.json().get("identifiers", [])
+
+ async def load_model(
+ self, catalog_name: str, schema_name: str, model_name: str
+ ) -> str:
+ response = await self.rest_client.get(
+ f"/api/metalakes/{self.metalake_name}/catalogs/{catalog_name}/schemas/{schema_name}/models/{model_name}"
+ )
+ return response.json().get("model", {})
+
+ async def list_model_versions(
+ self, catalog_name: str, schema_name: str, model_name: str
+ ) -> str:
+ response = await self.rest_client.get(
+ f"/api/metalakes/{self.metalake_name}/catalogs/{catalog_name}/schemas/{schema_name}/models/{model_name}/versions"
+ )
+ return response.json().get("versions", [])
Review Comment:
done
##########
mcp-server/mcp_server/tools/fileset.py:
##########
@@ -0,0 +1,177 @@
+# 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_fileset_tools(mcp: FastMCP):
+ @mcp.tool(tags={"fileset"})
+ async def get_list_of_filesets(
+ ctx: Context,
+ catalog_name: str,
+ schema_name: str,
+ ):
+ """
+ Retrieve a list of filesets within a specific catalog and schema.
+
+ Parameters:
+ ctx (Context): The request context object containing lifespan context
+ and connector information.
+ catalog_name (str): The name of the catalog to filter filesets by.
+ schema_name (str): The name of the schema to filter filesets by.
+
+ Returns:
+ str: A JSON string representing an array of fileset identifiers.
+
+ Example Return Value:
+ [
+ {
+ "namespace": [
+ "test",
+ "fileset_catalog",
+ "fileset_schema1"
+ ],
+ "name": "fileset1"
+ }
+ ]
+ """
+ client = ctx.request_context.lifespan_context.rest_client()
+ return await client.as_fileset_operation().get_list_of_filesets(
+ catalog_name, schema_name
+ )
+
+ @mcp.tool(tags={"fileset"})
+ async def load_fileset(
+ ctx: Context,
+ catalog_name: str,
+ schema_name: str,
+ fileset_name: str,
+ ):
+ """
+ Load detailed information of a specific fileset.
+
+ Parameters:
+ ctx (Context): The request context object containing lifespan context
+ and connector information.
+ catalog_name (str): The name of the catalog containing the fileset.
+ schema_name (str): The name of the schema containing the fileset.
+ fileset_name (str): The name of the fileset to load.
+
+ Returns:
+ str: A JSON string containing full metadata of the specified fileset.
+
+ Example Return Value:
+ {
+ "name": "fileset1",
+ "comment": "",
+ "type": "managed",
+ "storageLocations": {
+ "location1": "file:/tmp/fileset1"
+ },
+ "properties": {
+ "default-location-name": "location1"
+ },
+ "audit": {
+ "creator": "anonymous",
+ "createTime": "2025-08-07T07:52:56.656313Z"
+ }
+ }
+ """
+ client = ctx.request_context.lifespan_context.rest_client()
+ return await client.as_fileset_operation().load_fileset(
+ catalog_name, schema_name, fileset_name
+ )
+
+ @mcp.tool(tags={"fileset"})
+ async def list_files_in_fileset(
+ ctx: Context,
+ catalog_name: str,
+ schema_name: str,
+ fileset_name: str,
+ location_name: str,
+ sub_path: str = "/",
+ ):
+ """
+ List files in a specific fileset.
+
+ Parameters:
+ ctx (Context): The request context object containing lifespan context
+ and connector information.
+ catalog_name (str): The name of the catalog containing the fileset.
+ schema_name (str): The name of the schema containing the fileset.
+ fileset_name (str): The name of the fileset to list files from.
+ location_name (str): The name of the location within the fileset.
+ sub_path (str): Sub-path within the fileset to list files from (default is root "/").
+
+ Returns:
+ str: A JSON string containing a list of files in the specified fileset.
+
+ Example Return Value:
+ [
+ {
+ "name": "2.txt",
+ "isDir": false,
+ "size": 2,
+ "lastModified": 1754911672329,
+ "path": "/fileset/fileset_catalog/fileset_schema1/fileset1/"
+ },
+ {
+ "name": "1.txt",
+ "isDir": false,
+ "size": 2,
+ "lastModified": 1754911668512,
+ "path": "/fileset/fileset_catalog/fileset_schema1/fileset1/"
+ }
+ ]
+ """
+ client = ctx.request_context.lifespan_context.rest_client()
+ return await client.as_fileset_operation().list_files_in_fileset(
+ catalog_name, schema_name, fileset_name, location_name, sub_path
+ )
+
+ @mcp.tool(tags={"fileset"})
+ async def get_fileset_location(
+ ctx: Context,
+ catalog_name: str,
+ schema_name: str,
+ fileset_name: str,
+ sub_path: str,
+ location_name: str,
+ ):
+ """
+ Get the location of a specific fileset.
+
+ Parameters:
+ ctx (Context): The request context object containing lifespan context
+ and connector information.
+ catalog_name (str): The name of the catalog containing the fileset.
+ schema_name (str): The name of the schema containing the fileset.
+ fileset_name (str): The name of the fileset to get the location for.
+ sub_path (str): Sub-path within the fileset.
+ location_name (str): The name of the location within the fileset.
+
+ Returns:
+ str: A JSON string containing the location information of the specified fileset.
+
+ Example Return Value:
+ file:/tmp/fileset1
+
+ """
+ client = ctx.request_context.lifespan_context.rest_client()
+ return await client.as_fileset_operation().get_fileset_location(
+ catalog_name, schema_name, fileset_name, sub_path, location_name
+ )
Review Comment:
done
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#8005] feat(mcp-server): Support read operations for fileset, topic and model in MCP server. [gravitino]
Posted by "jerryshao (via GitHub)" <gi...@apache.org>.
jerryshao commented on code in PR #8018:
URL: https://github.com/apache/gravitino/pull/8018#discussion_r2272848146
##########
mcp-server/mcp_server/tools/fileset.py:
##########
@@ -0,0 +1,144 @@
+# 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_fileset_tools(mcp: FastMCP):
+ @mcp.tool(tags={"fileset"})
+ async def get_list_of_filesets(
+ ctx: Context,
+ catalog_name: str,
+ schema_name: str,
+ ):
+ """
+ Retrieve a list of filesets within a specific catalog and schema.
+
+ Parameters:
+ ctx (Context): The request context object containing lifespan context
+ and connector information.
+ catalog_name (str): The name of the catalog to filter filesets by.
+ schema_name (str): The name of the schema to filter filesets by.
+
+ Returns:
+ str: A JSON string representing an array of fileset identifiers.
+
+ Example Return Value:
+ [
+ {
+ "namespace": [
+ "test",
+ "fileset_catalog",
+ "fileset_schema1"
+ ],
+ "name": "fileset1"
+ }
+ ]
+ """
+ client = ctx.request_context.lifespan_context.rest_client()
+ return await client.as_fileset_operation().get_list_of_filesets(
+ catalog_name, schema_name
+ )
Review Comment:
We don't have to fix this issue here. But we should think about this.
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#8005] feat(mcp-server): Support read operations for fileset, topic and model in MCP server. [gravitino]
Posted by "jerryshao (via GitHub)" <gi...@apache.org>.
jerryshao commented on code in PR #8018:
URL: https://github.com/apache/gravitino/pull/8018#discussion_r2269539443
##########
mcp-server/mcp_server/client/fileset_operation.py:
##########
@@ -0,0 +1,102 @@
+# 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 abc import ABC, abstractmethod
+
+
+class FilesetOperation(ABC):
+ """
+ Abstract base class for Gravitino fileset operations.
+ """
+
+ @abstractmethod
+ async def get_list_of_filesets(
+ self, catalog_name: str, schema_name: str
+ ) -> str:
+ """
+ Retrieve the list of filesets within a specified catalog.
+
+ Args:
+ catalog_name: Name of the catalog
+ schema_name: Name of the schema
+
+ Returns:
+ str: JSON-formatted string containing fileset list information
+ """
+ pass
+
+ @abstractmethod
+ async def load_fileset(
+ self, catalog_name: str, schema_name: str, fileset_name: str
+ ) -> str:
+ """
+ Load detailed information of a specific fileset.
+
+ Args:
+ catalog_name: Name of the catalog
+ schema_name: Name of the schema
+ fileset_name: Name of the fileset
+
+ Returns:
+ str: JSON-formatted string containing full fileset metadata
+ """
+ pass
+
+ @abstractmethod
+ async def list_files_in_fileset(
+ self,
+ catalog_name: str,
+ schema_name: str,
+ fileset_name: str,
+ location_name: str,
+ sub_path: str = "/",
+ ) -> str:
+ """
+ List files in a specific fileset.
+
+ Args:
+ catalog_name: Name of the catalog
+ schema_name: Name of the schema
+ fileset_name: Name of the fileset
+ sub_path: Sub-path within the fileset to list files from (default is root "/")
+ location_name: Name of the location
+
+ Returns:
+ str: JSON-formatted string containing list of files in the fileset
+ """
+ pass
+
+ @abstractmethod
+ async def get_fileset_location(
Review Comment:
This is not useful for LLM, you need to remove it.
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#8005] feat(mcp-server): Support read operations for fileset, topic and model in MCP server. [gravitino]
Posted by "jerryshao (via GitHub)" <gi...@apache.org>.
jerryshao commented on code in PR #8018:
URL: https://github.com/apache/gravitino/pull/8018#discussion_r2269634828
##########
mcp-server/mcp_server/client/plain/plain_rest_client_model_operation.py:
##########
@@ -0,0 +1,68 @@
+# 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 mcp_server.client import ModelOperation
+
+
+class PlainRESTClientModelOperation(ModelOperation):
+ """
+ Implementation of ModelOperation using a plain REST client.
+ """
+
+ def __init__(self, metalake_name: str, rest_client):
+ self.metalake_name = metalake_name
+ self.rest_client = rest_client
+
+ async def get_list_of_models(
+ self, catalog_name: str, schema_name: str
+ ) -> str:
+ response = await self.rest_client.get(
+ f"/api/metalakes/{self.metalake_name}/catalogs/{catalog_name}/schemas/{schema_name}/models"
+ )
+ return response.json().get("identifiers", [])
+
+ async def load_model(
+ self, catalog_name: str, schema_name: str, model_name: str
+ ) -> str:
+ response = await self.rest_client.get(
+ f"/api/metalakes/{self.metalake_name}/catalogs/{catalog_name}/schemas/{schema_name}/models/{model_name}"
+ )
+ return response.json().get("model", {})
+
+ async def list_model_versions(
+ self, catalog_name: str, schema_name: str, model_name: str
+ ) -> str:
+ response = await self.rest_client.get(
+ f"/api/metalakes/{self.metalake_name}/catalogs/{catalog_name}/schemas/{schema_name}/models/{model_name}/versions"
+ )
+ return response.json().get("versions", [])
+
+ async def load_model_version(
+ self, catalog_name: str, schema_name: str, model_name: str, version: int
+ ) -> str:
+ response = await self.rest_client.get(
+ f"/api/metalakes/{self.metalake_name}/catalogs/{catalog_name}/schemas/{schema_name}/models/{model_name}/versions/{version}"
+ )
Review Comment:
Besides, most of the code line are too long, can you check the client-python and also enable the code format for this module.
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#8005] feat(mcp-server): Support read operations for fileset, topic and model in MCP server. [gravitino]
Posted by "jerryshao (via GitHub)" <gi...@apache.org>.
jerryshao commented on code in PR #8018:
URL: https://github.com/apache/gravitino/pull/8018#discussion_r2272783790
##########
mcp-server/mcp_server/client/plain/plain_rest_client_model_operation.py:
##########
@@ -0,0 +1,68 @@
+# 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 mcp_server.client import ModelOperation
+
+
+class PlainRESTClientModelOperation(ModelOperation):
+ """
+ Implementation of ModelOperation using a plain REST client.
+ """
+
+ def __init__(self, metalake_name: str, rest_client):
+ self.metalake_name = metalake_name
+ self.rest_client = rest_client
+
+ async def get_list_of_models(
+ self, catalog_name: str, schema_name: str
+ ) -> str:
+ response = await self.rest_client.get(
+ f"/api/metalakes/{self.metalake_name}/catalogs/{catalog_name}/schemas/{schema_name}/models"
+ )
+ return response.json().get("identifiers", [])
+
+ async def load_model(
+ self, catalog_name: str, schema_name: str, model_name: str
+ ) -> str:
+ response = await self.rest_client.get(
+ f"/api/metalakes/{self.metalake_name}/catalogs/{catalog_name}/schemas/{schema_name}/models/{model_name}"
+ )
+ return response.json().get("model", {})
+
+ async def list_model_versions(
+ self, catalog_name: str, schema_name: str, model_name: str
+ ) -> str:
+ response = await self.rest_client.get(
+ f"/api/metalakes/{self.metalake_name}/catalogs/{catalog_name}/schemas/{schema_name}/models/{model_name}/versions"
+ )
+ return response.json().get("versions", [])
+
+ async def load_model_version(
+ self, catalog_name: str, schema_name: str, model_name: str, version: int
+ ) -> str:
+ response = await self.rest_client.get(
+ f"/api/metalakes/{self.metalake_name}/catalogs/{catalog_name}/schemas/{schema_name}/models/{model_name}/versions/{version}"
+ )
Review Comment:
Yes, I think we needed, you can check the client-python module. But this can be done in the separate 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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#8005] feat(mcp-server): Support read operations for fileset, topic and model in MCP server. [gravitino]
Posted by "jerryshao (via GitHub)" <gi...@apache.org>.
jerryshao commented on code in PR #8018:
URL: https://github.com/apache/gravitino/pull/8018#discussion_r2272799468
##########
mcp-server/mcp_server/tools/fileset.py:
##########
@@ -0,0 +1,144 @@
+# 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_fileset_tools(mcp: FastMCP):
+ @mcp.tool(tags={"fileset"})
+ async def get_list_of_filesets(
+ ctx: Context,
+ catalog_name: str,
+ schema_name: str,
+ ):
+ """
+ Retrieve a list of filesets within a specific catalog and schema.
+
+ Parameters:
+ ctx (Context): The request context object containing lifespan context
+ and connector information.
+ catalog_name (str): The name of the catalog to filter filesets by.
+ schema_name (str): The name of the schema to filter filesets by.
+
+ Returns:
+ str: A JSON string representing an array of fileset identifiers.
+
+ Example Return Value:
+ [
+ {
+ "namespace": [
+ "test",
+ "fileset_catalog",
+ "fileset_schema1"
+ ],
+ "name": "fileset1"
+ }
+ ]
+ """
+ client = ctx.request_context.lifespan_context.rest_client()
+ return await client.as_fileset_operation().get_list_of_filesets(
+ catalog_name, schema_name
+ )
Review Comment:
I would suggest we improve the return value to make it more easy to understand by LLM, like:
```
"catalog": "xxx",
"schema": "yyy",
"fileset": "zzz"
```
Current nameidentifier format makes LLM a little difficult to understand, what do you think?
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org