xintongsong commented on code in PR #107: URL: https://github.com/apache/flink-agents/pull/107#discussion_r2278183290
########## python/flink_agents/api/tools/mcp.py: ########## @@ -0,0 +1,132 @@ +################################################################################ +# 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 __future__ import annotations + +from abc import ABC, abstractmethod +from typing import Any, Dict, List, Optional, Tuple + +from pydantic import BaseModel, Field +from typing_extensions import override + +from flink_agents.api.resource import ResourceType +from flink_agents.api.chat_models.chat_model import BaseChatModel +from flink_agents.api.tools.tool import BaseTool, ToolMetadata, ToolType + + +class MCPToolDefinition(BaseModel, ABC): + """MCP tool definition returned by list_tools or get_tool_definition.""" + + name: str + description: str + parameters: Dict[str, Any] = Field(default_factory=dict) + + def to_model_tool(self, chat_model: BaseChatModel) -> Dict[str, Any]: + """Convert this MCP tool definition to a model-specific tool dict. Review Comment: I think it would be more straightforward to pass the tool into the model, and let the model read the tool meta in a common form and convert into the form it needs. Passing the model into the tool seems unnecessary, since we still need to call the model for the conversion inside the tool. In other words, I think we should not have a `to_model_tool()` function on `ToolMetadata`. Instead, we should have a `convert_tool()` on `ChatModel`. Or do we need this as an interface at all? This can be completely internal to the `ChatModel`. -- 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]
