mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-08 22:21:35 +00:00
fix(mcp): make list page cap a plain constant and use a real ListToolsResult in the unit mock
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
parent
26b48d5891
commit
d32f8a07c8
4 changed files with 5 additions and 7 deletions
|
|
@ -136,7 +136,7 @@ MCP_CLIENT_TIMEOUT: Final = float(os.getenv("LITELLM_MCP_CLIENT_TIMEOUT", "60.0"
|
|||
MCP_TOOL_LISTING_TIMEOUT: Final = float(os.getenv("LITELLM_MCP_TOOL_LISTING_TIMEOUT", "30.0"))
|
||||
MCP_METADATA_TIMEOUT: Final = float(os.getenv("LITELLM_MCP_METADATA_TIMEOUT", "10.0"))
|
||||
MCP_HEALTH_CHECK_TIMEOUT: Final = float(os.getenv("LITELLM_MCP_HEALTH_CHECK_TIMEOUT", "10.0"))
|
||||
MCP_LIST_MAX_PAGES: Final = int(os.getenv("LITELLM_MCP_LIST_MAX_PAGES", "100"))
|
||||
MCP_LIST_MAX_PAGES: Final = 100
|
||||
|
||||
# Allowlist of commands permitted for MCP stdio transport.
|
||||
# Prevents arbitrary command execution via /mcp-rest/test/* endpoints or server creation.
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ async def collect_pages(
|
|||
return items
|
||||
if pages_read >= MCP_LIST_MAX_PAGES:
|
||||
verbose_logger.warning(
|
||||
"MCP %s from %s still paginating after %s pages (LITELLM_MCP_LIST_MAX_PAGES); returning what was read",
|
||||
"MCP %s from %s still paginating after %s pages (MCP_LIST_MAX_PAGES); returning what was read",
|
||||
method,
|
||||
server,
|
||||
pages_read,
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ from unittest.mock import AsyncMock, MagicMock, patch, ANY
|
|||
import litellm.experimental_mcp_client.client as mcp_client_module
|
||||
from litellm.experimental_mcp_client.client import MCPClient
|
||||
from litellm.types.mcp import MCPAuth, MCPTransport
|
||||
from mcp.types import Tool as MCPTool, CallToolResult as MCPCallToolResult
|
||||
from mcp.types import Tool as MCPTool, CallToolResult as MCPCallToolResult, ListToolsResult
|
||||
|
||||
|
||||
def test_mcp_client_uses_configurable_default_timeout():
|
||||
|
|
@ -174,9 +174,7 @@ class TestMCPClientUnitTests:
|
|||
},
|
||||
)
|
||||
]
|
||||
mock_result = MagicMock()
|
||||
mock_result.tools = mock_tools
|
||||
mock_session_instance.list_tools.return_value = mock_result
|
||||
mock_session_instance.list_tools.return_value = ListToolsResult(tools=mock_tools)
|
||||
|
||||
client = MCPClient("http://example.com")
|
||||
result = await client.list_tools()
|
||||
|
|
|
|||
|
|
@ -79,4 +79,4 @@ async def test_collect_pages_honors_the_page_cap(monkeypatch, caplog):
|
|||
|
||||
assert len(upstream.cursors_seen) == 3
|
||||
assert len(tools) == 30
|
||||
assert any("LITELLM_MCP_LIST_MAX_PAGES" in record.getMessage() for record in caplog.records)
|
||||
assert any("MCP_LIST_MAX_PAGES" in record.getMessage() for record in caplog.records)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue