From 14dfefad10ce4359c8e6b70374b08be3487e9603 Mon Sep 17 00:00:00 2001 From: Song YiChun Date: Mon, 11 Aug 2025 10:30:50 +0800 Subject: [PATCH 1/4] Add mcp router as a built-in tool --- veadk/tools/builtin_tools/mcp_router.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 veadk/tools/builtin_tools/mcp_router.py diff --git a/veadk/tools/builtin_tools/mcp_router.py b/veadk/tools/builtin_tools/mcp_router.py new file mode 100644 index 00000000..eb403cf2 --- /dev/null +++ b/veadk/tools/builtin_tools/mcp_router.py @@ -0,0 +1,21 @@ +# Copyright (c) 2025 Beijing Volcano Engine Technology Co., Ltd. and/or its affiliates. +# +# Licensed 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 google.adk.tools.mcp_tool.mcp_toolset import MCPToolset, SseConnectionParams + +from veadk.config import getenv + +url = getenv("TOOL_MCP_Router_URL") + +mcp_router = MCPToolset(connection_params=SseConnectionParams(url=url)) \ No newline at end of file From d4d662d4c628ca5833959ff423acca693715b0a7 Mon Sep 17 00:00:00 2001 From: Song YiChun Date: Mon, 11 Aug 2025 10:53:32 +0800 Subject: [PATCH 2/4] add configuration example of router and resolve CI format error in mcp_router.py --- config.yaml.example | 2 ++ veadk/tools/builtin_tools/mcp_router.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/config.yaml.example b/config.yaml.example index 9bf4325c..c19191ca 100644 --- a/config.yaml.example +++ b/config.yaml.example @@ -40,6 +40,8 @@ tool: las: url: #mcp sse url dataset_id: #dataset name + mcp_router: + url: #mcp sse url observability: diff --git a/veadk/tools/builtin_tools/mcp_router.py b/veadk/tools/builtin_tools/mcp_router.py index eb403cf2..7e5a3cfd 100644 --- a/veadk/tools/builtin_tools/mcp_router.py +++ b/veadk/tools/builtin_tools/mcp_router.py @@ -18,4 +18,4 @@ url = getenv("TOOL_MCP_Router_URL") -mcp_router = MCPToolset(connection_params=SseConnectionParams(url=url)) \ No newline at end of file +mcp_router = MCPToolset(connection_params=SseConnectionParams(url=url)) From a147427eb0b087116e6f2ef58561be8bfc2f21cf Mon Sep 17 00:00:00 2001 From: Song YiChun Date: Mon, 11 Aug 2025 11:24:49 +0800 Subject: [PATCH 3/4] Change the environment variable name to TOOL_MCP_ROUTER_URL --- veadk/tools/builtin_tools/mcp_router.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/veadk/tools/builtin_tools/mcp_router.py b/veadk/tools/builtin_tools/mcp_router.py index 7e5a3cfd..237f8e5d 100644 --- a/veadk/tools/builtin_tools/mcp_router.py +++ b/veadk/tools/builtin_tools/mcp_router.py @@ -16,6 +16,6 @@ from veadk.config import getenv -url = getenv("TOOL_MCP_Router_URL") +url = getenv("TOOL_MCP_ROUTER_URL") mcp_router = MCPToolset(connection_params=SseConnectionParams(url=url)) From 5e6ee6c46047664476a538d706334c7de8070abb Mon Sep 17 00:00:00 2001 From: Song YiChun Date: Mon, 11 Aug 2025 15:45:29 +0800 Subject: [PATCH 4/4] fix sse/streamable compatible issue by change mcp_router.py and update config.yaml.example --- config.yaml.example | 2 +- veadk/tools/builtin_tools/mcp_router.py | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/config.yaml.example b/config.yaml.example index c19191ca..70e45c59 100644 --- a/config.yaml.example +++ b/config.yaml.example @@ -41,7 +41,7 @@ tool: url: #mcp sse url dataset_id: #dataset name mcp_router: - url: #mcp sse url + url: #mcp sse/streamable-http url observability: diff --git a/veadk/tools/builtin_tools/mcp_router.py b/veadk/tools/builtin_tools/mcp_router.py index 237f8e5d..258837c5 100644 --- a/veadk/tools/builtin_tools/mcp_router.py +++ b/veadk/tools/builtin_tools/mcp_router.py @@ -12,10 +12,11 @@ # See the License for the specific language governing permissions and # limitations under the License. -from google.adk.tools.mcp_tool.mcp_toolset import MCPToolset, SseConnectionParams +from google.adk.tools.mcp_tool.mcp_toolset import MCPToolset from veadk.config import getenv +from veadk.utils.mcp_utils import get_mcp_params url = getenv("TOOL_MCP_ROUTER_URL") -mcp_router = MCPToolset(connection_params=SseConnectionParams(url=url)) +mcp_router = MCPToolset(connection_params=get_mcp_params(url=url))