|
17 | 17 | _list_public_registry_connectors, |
18 | 18 | ) |
19 | 19 | from airbyte.mcp.interactive._shared_models import ConnectorType, SupportLevel |
20 | | -from airbyte.mcp.registry import get_api_docs_urls |
| 20 | +from airbyte.mcp.registry import get_api_docs_urls, get_connector_info |
21 | 21 | from airbyte.registry import ( |
22 | 22 | ApiDocsUrl, |
23 | 23 | ConnectorMetadata, |
@@ -569,3 +569,49 @@ def test_prefab_generative_tools_include_airbyte_annotations() -> None: |
569 | 569 | assert tool.annotations is not None |
570 | 570 | assert getattr(tool.annotations, "mcp_module") == "interactive" |
571 | 571 | assert getattr(tool.annotations, INTERACTIVE_UI_ANNOTATION) is True |
| 572 | + |
| 573 | + |
| 574 | +@pytest.mark.parametrize( |
| 575 | + ("docker_installed", "expects_install"), |
| 576 | + [ |
| 577 | + pytest.param(True, True, id="docker_installs_and_reads_config_spec"), |
| 578 | + pytest.param(False, False, id="no_docker_skips_unbounded_install"), |
| 579 | + ], |
| 580 | +) |
| 581 | +def test_get_connector_info_only_installs_when_docker_available( |
| 582 | + docker_installed: bool, |
| 583 | + expects_install: bool, |
| 584 | +) -> None: |
| 585 | + """`get_connector_info` must not run the unbounded install path without Docker. |
| 586 | +
|
| 587 | + In a hosted, no-Docker runtime `connector.install()` falls back to a fresh |
| 588 | + pip/venv install per call, which is unbounded and has hung requests. The tool |
| 589 | + should skip it and leave `config_spec_jsonschema` as `None` there, while still |
| 590 | + returning the fast registry metadata. |
| 591 | + """ |
| 592 | + connector = MagicMock() |
| 593 | + connector.name = "source-faker" |
| 594 | + connector.docs_url = "https://docs.airbyte.com/integrations/sources/faker" |
| 595 | + connector.config_spec = {"type": "object"} |
| 596 | + |
| 597 | + with ( |
| 598 | + patch( |
| 599 | + "airbyte.mcp.registry.get_available_connectors", |
| 600 | + return_value=["source-faker"], |
| 601 | + ), |
| 602 | + patch("airbyte.mcp.registry.get_source", return_value=connector), |
| 603 | + patch("airbyte.mcp.registry.get_connector_metadata", return_value=None), |
| 604 | + patch( |
| 605 | + "airbyte.mcp.registry.is_docker_installed", |
| 606 | + return_value=docker_installed, |
| 607 | + ), |
| 608 | + ): |
| 609 | + result = get_connector_info("source-faker") |
| 610 | + |
| 611 | + assert not isinstance(result, str) |
| 612 | + assert connector.install.called is expects_install |
| 613 | + if expects_install: |
| 614 | + assert result.config_spec_jsonschema == {"type": "object"} |
| 615 | + else: |
| 616 | + assert result.config_spec_jsonschema is None |
| 617 | + assert result.manifest_url is not None |
0 commit comments