FANNG1 commented on code in PR #7905: URL: https://github.com/apache/gravitino/pull/7905#discussion_r2256498056
########## mcp-server/mcp_server/tools/table.py: ########## @@ -0,0 +1,227 @@ +# 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_table_tools(mcp: FastMCP): + @mcp.tool(tags={"table"}) Review Comment: It dependes on how should we export tools, in some senerios , the user may doesn't want to use table tools but use policy, tag tools. ########## mcp-server/mcp_server/server.py: ########## @@ -0,0 +1,117 @@ +# 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. + +import asyncio +import logging +import re +from contextlib import asynccontextmanager +from typing import AsyncIterator +from urllib.parse import urlparse + +from fastmcp import FastMCP +from fastmcp.server.middleware.error_handling import ErrorHandlingMiddleware +from fastmcp.server.middleware.logging import ( + LoggingMiddleware, +) +from fastmcp.server.middleware.timing import TimingMiddleware + +from mcp_server.core.context import GravitinoContext +from mcp_server.core.setting import Setting +from mcp_server.tools import load_tools + + +def create_lifespan_manager(gravitino_context: GravitinoContext): + + @asynccontextmanager + async def app_lifespan(server: FastMCP) -> AsyncIterator[GravitinoContext]: + logging.info(f"Add Gravitino context: {gravitino_context}") + yield gravitino_context + + return app_lifespan + + +def create_gravition_mcp(setting: Setting) -> FastMCP: Review Comment: updated -- 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]
