Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions src/google/adk/tools/mcp_tool/mcp_toolset.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,37 @@ def __init__(
self._auth_credential = auth_credential
self._require_confirmation = require_confirmation

@property
def connection_params(self) -> Union[
StdioServerParameters,
StdioConnectionParams,
SseConnectionParams,
StreamableHTTPConnectionParams,
]:
return self._connection_params

@property
def auth_scheme(self) -> Optional[AuthScheme]:
return self._auth_scheme

@property
def auth_credential(self) -> Optional[AuthCredential]:
return self._auth_credential

@property
def require_confirmation(self) -> Union[bool, Callable[..., bool]]:
return self._require_confirmation

@property
def header_provider(
self,
) -> Optional[Callable[[ReadonlyContext], Dict[str, str]]]:
Comment on lines +165 to +167
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The formatting of this property definition is unconventional. It's more standard to keep self on the same line as the method name. If the line length is an issue, you can break the type hint across multiple lines for better readability.

  def header_provider(self) -> Optional[Callable[[ReadonlyContext], Dict[str, str]]]:

return self._header_provider

@property
def errlog(self) -> TextIO:
return self._errlog

@retry_on_errors
async def get_tools(
self,
Expand Down
26 changes: 26 additions & 0 deletions tests/unittests/tools/mcp_tool/test_mcp_toolset.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,32 @@ def test_init_basic(self):
assert toolset._auth_scheme is None
assert toolset._auth_credential is None

def test_connection_params(self):
"""Test getting connection params."""
toolset = MCPToolset(connection_params=self.mock_stdio_params)
assert toolset.connection_params == self.mock_stdio_params

def test_auth_scheme(self):
"""Test getting auth scheme."""
toolset = MCPToolset(connection_params=self.mock_stdio_params)
assert toolset.auth_scheme is None

def test_auth_credential(self):
"""Test getting auth credential."""
toolset = MCPToolset(connection_params=self.mock_stdio_params)
assert toolset.auth_credential is None

def test_error_log(self):
"""Test getting error log."""
toolset = MCPToolset(connection_params=self.mock_stdio_params)
assert toolset.errlog == sys.stderr

def test_auth_credential_updates(self):
"""Test setting auth credential."""
toolset = MCPToolset(connection_params=self.mock_stdio_params)
toolset._auth_credential = "test_auth_credential"
assert toolset.auth_credential == "test_auth_credential"

def test_init_with_stdio_connection_params(self):
"""Test initialization with StdioConnectionParams."""
stdio_params = StdioConnectionParams(
Expand Down