Skip to content

Commit a8cf82c

Browse files
feat(mcp): Add optional workspace_id parameter to cloud tools with conditional schema hiding (#876)
Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
1 parent f1cb667 commit a8cf82c

File tree

2 files changed

+221
-31
lines changed

2 files changed

+221
-31
lines changed

airbyte/mcp/_tool_utils.py

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
from __future__ import annotations
99

10+
import inspect
1011
import os
1112
from collections.abc import Callable
1213
from typing import Any, Literal, TypeVar
@@ -25,6 +26,7 @@
2526
os.environ.get("AIRBYTE_CLOUD_MCP_READONLY_MODE", "").strip() == "1"
2627
)
2728
AIRBYTE_CLOUD_MCP_SAFE_MODE = os.environ.get("AIRBYTE_CLOUD_MCP_SAFE_MODE", "1").strip() != "0"
29+
AIRBYTE_CLOUD_WORKSPACE_ID_IS_SET = bool(os.environ.get("AIRBYTE_CLOUD_WORKSPACE_ID", "").strip())
2830

2931
_REGISTERED_TOOLS: list[tuple[Callable[..., Any], dict[str, Any]]] = []
3032
_GUIDS_CREATED_IN_SESSION: set[str] = set()
@@ -158,8 +160,20 @@ def register_tools(app: Any, domain: Literal["cloud", "local", "registry"]) -> N
158160
for func, tool_annotations in get_registered_tools(domain):
159161
if should_register_tool(tool_annotations):
160162
extra_help_text = getattr(func, "_mcp_extra_help_text", None)
163+
description: str | None = None
161164
if extra_help_text:
162165
description = (func.__doc__ or "").rstrip() + "\n" + extra_help_text
163-
app.tool(func, annotations=tool_annotations, description=description)
164-
else:
165-
app.tool(func, annotations=tool_annotations)
166+
167+
# For cloud tools, conditionally hide workspace_id parameter when env var is set
168+
exclude_args: list[str] | None = None
169+
if domain == "cloud" and AIRBYTE_CLOUD_WORKSPACE_ID_IS_SET:
170+
params = set(inspect.signature(func).parameters.keys())
171+
excluded = [name for name in ["workspace_id"] if name in params]
172+
exclude_args = excluded or None
173+
174+
app.tool(
175+
func,
176+
annotations=tool_annotations,
177+
description=description,
178+
exclude_args=exclude_args,
179+
)

0 commit comments

Comments
 (0)