-
Notifications
You must be signed in to change notification settings - Fork 71
feat(mcp): Add get_api_docs_urls tool with data.externalDocumentationUrls support #858
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Aaron ("AJ") Steers (aaronsteers)
merged 10 commits into
main
from
devin/1762889439-get-api-docs-urls-tool
Nov 12, 2025
+376
−3
Merged
Changes from 8 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
8c8fd5d
feat(mcp): Add get_api_docs_urls tool to registry domain
devin-ai-integration[bot] b4dcfa2
feat(mcp): Update get_api_docs_urls to support data.externalDocumenta…
devin-ai-integration[bot] c103fa3
fix(mcp): Refactor test to avoid CodeQL false positive
devin-ai-integration[bot] 6309b76
fix(format): Apply ruff formatting to test file
devin-ai-integration[bot] 9bff539
feat(mcp): Add support for extracting externalDocumentationUrls from …
devin-ai-integration[bot] e71e3bf
refactor(mcp): Simplify get_api_docs_urls tool per PR feedback
devin-ai-integration[bot] bd9b023
refactor(mcp): Remove hallucinated specs and simplify error handling
devin-ai-integration[bot] 731878f
refactor(mcp): Refactor manifest parsing into helper functions and cl…
devin-ai-integration[bot] 9521495
Merge branch 'main' into devin/1762889439-get-api-docs-urls-tool
devin-ai-integration[bot] b8a74db
refactor(registry): Move manifest parsing logic from MCP to registry …
devin-ai-integration[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,181 @@ | ||
| # Copyright (c) 2024 Airbyte, Inc., all rights reserved. | ||
| """Unit tests for MCP connector registry tools.""" | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| from unittest.mock import MagicMock, patch | ||
|
|
||
|
|
||
| from airbyte.mcp.connector_registry import ( | ||
| ApiDocsUrl, | ||
| _fetch_manifest_dict, | ||
| _manifest_url_for, | ||
| get_api_docs_urls, | ||
| ) | ||
|
|
||
|
|
||
| class TestManifestUrlFor: | ||
| """Tests for _manifest_url_for function.""" | ||
|
|
||
| def test_manifest_url_for(self) -> None: | ||
| """Test generating manifest URL for a connector.""" | ||
| url = _manifest_url_for("source-example") | ||
| assert "source-example" in url | ||
| assert "manifest.yaml" in url | ||
| assert "latest" in url | ||
|
|
||
|
|
||
| class TestFetchManifestDict: | ||
| """Tests for _fetch_manifest_dict function.""" | ||
|
|
||
| def test_manifest_not_found(self) -> None: | ||
| """Test handling when manifest.yaml doesn't exist (404).""" | ||
| with patch("airbyte.mcp.connector_registry.requests.get") as mock_get: | ||
| mock_response = MagicMock() | ||
| mock_response.status_code = 404 | ||
| mock_get.return_value = mock_response | ||
|
|
||
| manifest_dict = _fetch_manifest_dict("https://example.com/manifest.yaml") | ||
| assert manifest_dict == {} | ||
|
|
||
| def test_fetch_manifest_dict(self) -> None: | ||
| """Test fetching and parsing manifest.yaml.""" | ||
| manifest_yaml = """ | ||
| version: 1.0.0 | ||
| type: DeclarativeSource | ||
| data: | ||
| name: Example | ||
| """ | ||
| with patch("airbyte.mcp.connector_registry.requests.get") as mock_get: | ||
| mock_response = MagicMock() | ||
| mock_response.status_code = 200 | ||
| mock_response.text = manifest_yaml | ||
| mock_get.return_value = mock_response | ||
|
|
||
| manifest_dict = _fetch_manifest_dict("https://example.com/manifest.yaml") | ||
| assert manifest_dict["version"] == "1.0.0" | ||
| assert manifest_dict["type"] == "DeclarativeSource" | ||
| assert manifest_dict["data"]["name"] == "Example" | ||
|
|
||
|
|
||
| class TestApiDocsUrlFromManifestDict: | ||
| """Tests for ApiDocsUrl.from_manifest_dict classmethod.""" | ||
|
|
||
| def test_manifest_with_external_docs_urls(self) -> None: | ||
| """Test extracting URLs from data.externalDocumentationUrls field.""" | ||
| manifest_dict = { | ||
| "version": "1.0.0", | ||
| "type": "DeclarativeSource", | ||
| "data": { | ||
| "externalDocumentationUrls": [ | ||
| { | ||
| "title": "Versioning docs", | ||
| "url": "https://api.example.com/versioning", | ||
| "type": "api_reference", | ||
| }, | ||
| { | ||
| "title": "Changelog", | ||
| "url": "https://api.example.com/changelog", | ||
| "type": "api_release_history", | ||
| }, | ||
| { | ||
| "title": "Deprecated API calls", | ||
| "url": "https://api.example.com/deprecations", | ||
| "type": "api_deprecations", | ||
| "requiresLogin": True, | ||
| }, | ||
| ] | ||
| }, | ||
| } | ||
|
|
||
| urls = ApiDocsUrl.from_manifest_dict(manifest_dict) | ||
| assert len(urls) == 3 | ||
| assert urls[0].title == "Versioning docs" | ||
| assert urls[0].url == "https://api.example.com/versioning" | ||
| assert urls[0].doc_type == "api_reference" | ||
| assert urls[0].requires_login is False | ||
| assert urls[1].title == "Changelog" | ||
| assert urls[1].doc_type == "api_release_history" | ||
| assert urls[2].title == "Deprecated API calls" | ||
| assert urls[2].doc_type == "api_deprecations" | ||
| assert urls[2].requires_login is True | ||
|
|
||
| def test_manifest_with_external_docs_no_type(self) -> None: | ||
| """Test extracting URLs from data.externalDocumentationUrls without type field.""" | ||
| manifest_dict = { | ||
| "version": "1.0.0", | ||
| "type": "DeclarativeSource", | ||
| "data": { | ||
| "externalDocumentationUrls": [ | ||
| { | ||
| "title": "General docs", | ||
| "url": "https://api.example.com/docs", | ||
| } | ||
| ] | ||
| }, | ||
| } | ||
|
|
||
| urls = ApiDocsUrl.from_manifest_dict(manifest_dict) | ||
| assert len(urls) == 1 | ||
| assert urls[0].title == "General docs" | ||
| assert urls[0].doc_type == "other" | ||
| assert urls[0].requires_login is False | ||
|
|
||
| def test_empty_manifest(self) -> None: | ||
| """Test handling empty manifest dict.""" | ||
| urls = ApiDocsUrl.from_manifest_dict({}) | ||
| assert len(urls) == 0 | ||
|
|
||
|
|
||
| class TestGetApiDocsUrls: | ||
| """Tests for get_api_docs_urls function.""" | ||
|
|
||
| def test_connector_not_found(self) -> None: | ||
| """Test handling when connector is not found.""" | ||
| with patch( | ||
| "airbyte.mcp.connector_registry.get_available_connectors" | ||
| ) as mock_get: | ||
| mock_get.return_value = ["source-faker", "source-facebook-marketing"] | ||
|
|
||
| result = get_api_docs_urls("nonexistent-connector") | ||
| assert result == "Connector not found." | ||
|
|
||
| def test_deduplication_of_urls(self) -> None: | ||
| """Test that duplicate URLs are deduplicated.""" | ||
| with ( | ||
| patch( | ||
| "airbyte.mcp.connector_registry.get_available_connectors" | ||
| ) as mock_get, | ||
| patch("airbyte.mcp.connector_registry.get_source") as mock_source, | ||
| patch( | ||
| "airbyte.mcp.connector_registry._fetch_manifest_dict" | ||
| ) as mock_fetch_dict, | ||
| patch( | ||
| "airbyte.mcp.connector_registry._extract_docs_from_registry" | ||
| ) as mock_registry, | ||
| ): | ||
| mock_get.return_value = ["source-example", "source-faker"] | ||
|
|
||
| mock_connector = MagicMock() | ||
| mock_connector.docs_url = ( | ||
| "https://docs.airbyte.com/integrations/sources/example" | ||
| ) | ||
| mock_source.return_value = mock_connector | ||
|
|
||
| mock_registry.return_value = [] | ||
|
|
||
| mock_fetch_dict.return_value = { | ||
| "data": { | ||
| "externalDocumentationUrls": [ | ||
| { | ||
| "title": "Airbyte Documentation", | ||
| "url": "https://docs.airbyte.com/integrations/sources/example", | ||
| } | ||
| ] | ||
| } | ||
| } | ||
|
|
||
| result = get_api_docs_urls("source-example") | ||
|
|
||
| assert isinstance(result, list) | ||
| assert len(result) == 1 |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.