From fe4cd3cddc99f157710296dad892bec427cae991 Mon Sep 17 00:00:00 2001 From: Evan Mattson <35585003+moonbox3@users.noreply.github.com> Date: Thu, 16 Apr 2026 11:46:49 +0900 Subject: [PATCH] Revert to public MCP server and skip on transient upstream errors (#5296) The local MCP server can't be used for hosted tools tests because Anthropic's backend needs to reach the MCP URL from their infrastructure (not localhost on the CI runner). Revert to learn.microsoft.com/api/mcp but catch BadRequestError, InternalServerError, APIConnectionError, and APITimeoutError and pytest.skip so upstream outages don't block the merge queue. --- .../anthropic/tests/test_anthropic_client.py | 24 ++++++++++++------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/python/packages/anthropic/tests/test_anthropic_client.py b/python/packages/anthropic/tests/test_anthropic_client.py index a10a8830b4..945e5356a4 100644 --- a/python/packages/anthropic/tests/test_anthropic_client.py +++ b/python/packages/anthropic/tests/test_anthropic_client.py @@ -1504,9 +1504,7 @@ async def test_anthropic_client_integration_function_calling() -> None: @skip_if_anthropic_integration_tests_disabled async def test_anthropic_client_integration_hosted_tools() -> None: """Integration test for hosted tools.""" - local_mcp_url = os.environ.get("LOCAL_MCP_URL", "") - if not local_mcp_url or not local_mcp_url.startswith(("http://", "https://")): - pytest.skip("LOCAL_MCP_URL not set or not an HTTP URL; skipping hosted tools test") + import anthropic client = AnthropicClient() @@ -1515,15 +1513,23 @@ async def test_anthropic_client_integration_hosted_tools() -> None: AnthropicClient.get_web_search_tool(), AnthropicClient.get_code_interpreter_tool(), AnthropicClient.get_mcp_tool( - name="local-mcp", - url=local_mcp_url, + name="example-mcp", + url="https://learn.microsoft.com/api/mcp", ), ] - response = await client.get_response( - messages=messages, - options={"tools": tools, "max_tokens": 100}, - ) + try: + response = await client.get_response( + messages=messages, + options={"tools": tools, "max_tokens": 100}, + ) + except ( + anthropic.BadRequestError, + anthropic.InternalServerError, + anthropic.APIConnectionError, + anthropic.APITimeoutError, + ) as e: + pytest.skip(f"Upstream MCP server unavailable: {e}") assert response is not None assert response.text is not None