Skip to content

Commit 594c8a8

Browse files
committed
PR feedback updates
1 parent bcfe0ba commit 594c8a8

File tree

4 files changed

+19
-14
lines changed

4 files changed

+19
-14
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ client = McpdClient(api_endpoint="http://localhost:8090", api_key="optional-key"
145145

146146
* `client.tools(server_name: str) -> list[dict]` - Returns the tool schema definitions for only the specified server.
147147

148-
* `client.agent_tools(servers: list[str] | None = None, check_health: bool = True) -> list[Callable]` - Returns a list of self-contained, callable functions suitable for agentic frameworks. By default, filters to healthy servers only. Use `servers` to filter by server names, or `check_health=False` to include all servers regardless of health.
148+
* `client.agent_tools(servers: list[str] | None = None, *, check_health: bool = True) -> list[Callable]` - Returns a list of self-contained, callable functions suitable for agentic frameworks. By default, filters to healthy servers only. Use `servers` to filter by server names, or `check_health=False` to include all servers regardless of health.
149149

150150
* `client.clear_agent_tools_cache()` - Clears cached generated callable functions that are created when calling agent_tools().
151151

src/mcpd/mcpd_client.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,6 @@ def agent_tools(self, servers: list[str] | None = None, *, check_health: bool =
406406
ConnectionError: If unable to connect to the mcpd daemon.
407407
TimeoutError: If requests to the daemon time out.
408408
AuthenticationError: If API key authentication fails.
409-
ServerNotFoundError: If a server becomes unavailable during tool retrieval.
410409
McpdError: If unable to retrieve server health status (when check_health=True)
411410
or retrieve tool definitions or generate functions.
412411

tests/conftest.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from collections.abc import Callable
12
from unittest.mock import Mock
23

34
import pytest
@@ -73,8 +74,8 @@ def test_something(tools_side_effect):
7374
mock_tools.side_effect = tools_side_effect(tools_map)
7475
"""
7576

76-
def _create_side_effect(tools_map: dict[str, list[dict]]):
77-
def side_effect(server_name=None):
77+
def _create_side_effect(tools_map: dict[str, list[dict]]) -> Callable[[str | None], list[dict]]:
78+
def side_effect(server_name: str | None = None) -> list[dict]:
7879
return tools_map.get(server_name, [])
7980

8081
return side_effect

tests/unit/test_mcpd_client.py

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,8 @@ def test_agent_tools_with_empty_servers_list(self, mock_health, mock_tools, clie
233233
result = client.agent_tools(servers=[])
234234

235235
assert result == []
236-
assert mock_create.call_count == 0
236+
mock_tools.assert_not_called()
237+
mock_create.assert_not_called()
237238

238239
@patch.object(McpdClient, "servers")
239240
@patch.object(McpdClient, "tools")
@@ -323,13 +324,15 @@ def test_agent_tools_no_health_check_when_disabled(self, mock_tools, mock_server
323324
@patch.object(McpdClient, "servers")
324325
@patch.object(McpdClient, "tools")
325326
@patch.object(McpdClient, "server_health")
326-
def test_agent_tools_all_servers_unhealthy(self, mock_health, mock_tools, mock_servers, client):
327+
def test_agent_tools_all_servers_unhealthy(self, mock_health, mock_tools, mock_servers, client, tools_side_effect):
327328
"""Test behavior when all servers are unhealthy."""
328329
mock_servers.return_value = ["server1", "server2"]
329-
mock_tools.return_value = {
330-
"server1": [{"name": "tool1", "description": "Tool 1"}],
331-
"server2": [{"name": "tool2", "description": "Tool 2"}],
332-
}
330+
mock_tools.side_effect = tools_side_effect(
331+
{
332+
"server1": [{"name": "tool1", "description": "Tool 1"}],
333+
"server2": [{"name": "tool2", "description": "Tool 2"}],
334+
}
335+
)
333336

334337
mock_health.return_value = {
335338
"server1": {"status": "timeout"},
@@ -375,12 +378,14 @@ def test_agent_tools_with_servers_and_health_filtering(self, mock_health, mock_t
375378
@patch.object(McpdClient, "servers")
376379
@patch.object(McpdClient, "tools")
377380
@patch.object(McpdClient, "server_health")
378-
def test_agent_tools_health_check_exception(self, mock_health, mock_tools, mock_servers, client):
381+
def test_agent_tools_health_check_exception(self, mock_health, mock_tools, mock_servers, client, tools_side_effect):
379382
"""Test behavior when health check raises exception."""
380383
mock_servers.return_value = ["server1"]
381-
mock_tools.return_value = {
382-
"server1": [{"name": "tool1", "description": "Tool 1"}],
383-
}
384+
mock_tools.side_effect = tools_side_effect(
385+
{
386+
"server1": [{"name": "tool1", "description": "Tool 1"}],
387+
}
388+
)
384389

385390
# Health check raises exception.
386391
mock_health.side_effect = Exception("Health check failed")

0 commit comments

Comments
 (0)