Skip to content

AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.

feat(platform): expert integrations connect through MCP first (#15199)

Ubbeaa3ce9659e02
diff --git a/autogpt_platform/backend/backend/api/features/experts/credential_counts.py b/autogpt_platform/backend/backend/api/features/experts/credential_counts.py
index 03e1684673..944f4d7db3 100644
--- a/autogpt_platform/backend/backend/api/features/experts/credential_counts.py
+++ b/autogpt_platform/backend/backend/api/features/experts/credential_counts.py
@@ -3,14 +3,15 @@ import asyncio
import prisma.models
from backend.api.features.experts.credentials import _seed_if_needed, _user_credentials
+from backend.integrations.service_identity import service_for_credential
async def expert_credential_providers(
user_id: str, experts: list[prisma.models.Expert]
) -> dict[str, list[str]]:
- """The provider of every live credential each owned expert may use.
+ """Service icon ids for each owned expert, one per live granted credential.
- One entry per grant, so ``len`` is the credential count and a provider
+ One entry per grant, so ``len`` is the credential count and a service
granted twice appears twice; the roster dedupes for its logos.
"""
owned = [expert for expert in experts if expert.ownerUserId == user_id]
@@ -31,10 +32,17 @@ async def expert_credential_providers(
),
_user_credentials(user_id),
)
- provider_by_id = {credential.id: credential.provider for credential in credentials}
+ # One service icon id per grant: the provider slug for a block
+ # credential, the catalog icon for an MCP one.
+ icon_by_id = {credential.id: _icon_for(credential) for credential in credentials}
providers: dict[str, list[str]] = {}
for grant in grants:
- provider = provider_by_id.get(grant.credentialId)
- if provider is not None:
- providers.setdefault(grant.expertId, []).append(provider)
+ icon = icon_by_id.get(grant.credentialId)
+ if icon is not None:
+ providers.setdefault(grant.expertId, []).append(icon)
return providers
+
+
+def _icon_for(credential) -> str:
+ identity = service_for_credential(credential)
+ return identity.icon or identity.service
diff --git a/autogpt_platform/backend/backend/api/features/experts/credential_counts_test.py b/autogpt_platform/backend/backend/api/features/experts/credential_counts_test.py
index c82ca134e5..cdcea062f2 100644
--- a/autogpt_platform/backend/backend/api/features/experts/credential_counts_test.py
+++ b/autogpt_platform/backend/backend/api/features/experts/credential_counts_test.py
@@ -61,6 +61,54 @@ async def test_lists_live_credential_providers_in_one_owner_scoped_batch():
)
+async def test_an_mcp_grant_is_listed_under_its_service_icon():
+ from pydantic import SecretStr
+
+ from backend.data.model import OAuth2Credentials
+ from backend.integrations.mcp_catalog import get_mcp_catalog
+
+ linear = next(e for e in get_mcp_catalog() if e.name == "mcp_linear")
+ mcp = OAuth2Credentials(
+ id="mcp-1",
+ provider="mcp",
+ title="MCP: mcp.linear.app",
+ access_token=SecretStr("t"),
+ scopes=[],
+ metadata={"mcp_server_url": linear.mcp_server.server_url},
+ )
+ experts = [
+ prisma.models.Expert.model_construct(id="expert-1", ownerUserId="owner-1")
+ ]
+ with (
+ patch.object(credential_counts, "_seed_if_needed", new=AsyncMock()),
+ patch.object(
+ credential_counts,
+ "_user_credentials",
+ new=AsyncMock(
+ return_value=[mcp, SimpleNamespace(id="live-2", provider="notion")]
+ ),
+ ),
+ patch.object(
+ prisma.models.ExpertCredential,
+ "prisma",
+ return_value=SimpleNamespace(
+ find_many=AsyncMock(
+ return_value=[
+ SimpleNamespace(expertId="expert-1", credentialId="mcp-1"),
+ SimpleNamespace(expertId="expert-1", credentialId="live-2"),
+ ]
+ )
+ ),
+ ),
+ ):
+ providers = await credential_counts.expert_credential_providers(
+ "owner-1", experts
+ )
+
+ assert providers == {"expert-1": [linear.mcp_server.icon_id, "notion"]}
+
+
@pytest.mark.asyncio
async def test_empty_roster_skips_credential_reads():
with patch.object(
diff --git a/autogpt_platform/backend/backend/api/features/experts/credentials.py b/autogpt_platform/backend/backend/api/features/experts/credentials.py
index b67d5044c8..f1ceb85f5b 100644
--- a/autogpt_platform/backend/backend/api/features/experts/credentials.py
+++ b/autogpt_platform/backend/backend/api/features/experts/credentials.py
@@ -22,6 +22,7 @@ from backend.api.features.experts import scheduling
from backend.api.features.experts.models import ExpertCredentialRef
from backend.data.model import Credentials
from backend.integrations.credentials_store import is_system_credential
+from backend.integrations.service_identity import service_for_credential
from backend.util.exceptions import ExpertNotFoundError
if TYPE_CHECKING:
@@ -199,12 +200,16 @@ def _to_refs(
credential = by_id.get(grant.credentialId)
if credential is None:
continue
+ identity = service_for_credential(credential)
refs.append(
ExpertCredentialRef(
credential_id=credential.id,
provider=str(credential.provider),
title=credential.title or str(credential.provider),
type=str(credential.type),
+ service=identity.service,
+ service_name=identity.name,
+ service_icon=identity.icon,
)
)
return refs
diff --git a/autogpt_platform/backend/backend/api/features/experts/credentials_test.py b/autogpt_platform/backend/backend/api/features/experts/credentials_test.py
index 1eba3f75f6..07b6fb58dd 100644
--- a/autogpt_platform/backend/backend/api/features/experts/credentials_test.py
+++ b/autogpt_platform/backend/backend/api/features/experts/credentials_test.py
@@ -13,7 +13,11 @@ from backend.api.features.experts.credentials import (
filter_credentials_for_expert,
settle_credential_seed,
)
-from backend.data.model import APIKeyCredentials, CredentialsMetaInput
+from backend.data.model import (
+ APIKeyCredentials,
+ CredentialsMetaInput,
+ OAuth2Credentials,
+)
from backend.executor.utils import _enforce_expert_credential_scope
@@ -321,3 +325,31 @@ async def test_settling_the_seed_stamps_even_when_derivation_was_incomplete(
seed.assert_awaited_once_with("user-1", expert)
stamp.assert_awaited_once_with("expert-1")
+
+
+def test_refs_carry_the_service_behind_an_mcp_credential():
+ from backend.integrations.mcp_catalog import get_mcp_catalog
+
+ linear = next(e for e in get_mcp_catalog() if e.name == "mcp_linear")
+ credential = OAuth2Credentials(
+ id="cred-mcp",
+ provider="mcp",
+ title="MCP: mcp.linear.app",
+ access_token=SecretStr("t"),
+ scopes=[],
+ metadata={"mcp_server_url": linear.mcp_server.server_url},
+ )
+
+ refs = _to_refs([_Grant("cred-mcp", "mcp")], [credential]) # type: ignore[arg-type]
+
+ assert refs[0].service == "linear"
+ assert refs[0].service_name == "Linear"
+ assert refs[0].service_icon == linear.mcp_server.icon_id
+
+
+def test_refs_carry_the_provider_as_service_for_a_block_credential():
+ refs = _to_refs( # type: ignore[arg-type]
+ [_Grant("cred-1", "notion")], [_api_key_credential("cred-1", "notion")]
+ )
+ assert refs[0].service == "notion"
+ assert refs[0].service_icon == "notion"
diff --git a/autogpt_platform/backend/backend/api/features/experts/models.py b/autogpt_platform/backend/backend/api/features/experts/models.py
index 74893781c0..7f36f189bf 100644
--- a/autogpt_platform/backend/backend/api/features/experts/models.py
+++ b/autogpt_platform/backend/backend/api/features/experts/models.py
@@ -195,6 +195,9 @@ class ExpertCredentialRef(BaseModel):
provider: str
title: str
type: str
+ service: str = ""
+ service_name: str | None = None
+ service_icon: str | None = None
EXPERT_DAY_ONE_MAX_ITEMS = 3
diff --git a/autogpt_platform/backend/backend/api/features/integrations/codex_test.py b/autogpt_platform/backend/backend/api/features/integrations/codex_test.py
index 0057ee1743..6daa0e8fd9 100644
--- a/autogpt_platform/backend/backend/api/features/integrations/codex_test.py
+++ b/autogpt_platform/backend/backend/api/features/integrations/codex_test.py
@@ -242,6 +242,9 @@ def test_codex_callback_persists_one_safe_credential():
"host": None,
"mcp_auth_scheme": None,
"is_managed": False,
+ "service": "codex",
+ "service_name": None,
+ "service_icon": "codex",
}
raw_response = response.text
assert "access-secret" not in raw_response
diff --git a/autogpt_platform/backend/backend/api/features/integrations/mcp_catalog_routes_test.py b/autogpt_platform/backend/backend/api/features/integrations/mcp_catalog_routes_test.py
index c7e6080c19..d01f6cdd53 100644
--- a/autogpt_platform/backend/backend/api/features/integrations/mcp_catalog_routes_test.py
+++ b/autogpt_platform/backend/backend/api/features/integrations/mcp_catalog_routes_test.py
@@ -65,3 +65,28 @@ def test_provider_openapi_exposes_typed_mcp_metadata():
assert metadata["auth_methods"]["minItems"] == 1
assert "auth_methods" in schemas["MCPServerMetadata"]["required"]
assert "mcp_server" in schemas["ProviderMetadata"]["properties"]
+
+
+def test_provider_listing_carries_the_service_identity():
+ with (
+ patch("backend.blocks.load_all_blocks"),
+ patch(
+ "backend.api.features.integrations.router.get_all_provider_names",
+ return_value=["linear", "google"],
+ ),
+ patch(
+ "backend.api.features.integrations.router.get_provider_description",
+ return_value="Native integration",
+ ),
+ patch(
+ "backend.api.features.integrations.router.get_supported_auth_types",
+ return_value=["api_key"],
+ ),
+ ):
+ providers = {p["name"]: p for p in TestClient(app).get("/providers").json()}
+
+ assert providers["linear"]["service"] == "linear"
+ assert providers["linear"]["service_icon"] == "linear"
+ assert providers["mcp_linear"]["service"] == "linear"
+ assert providers["mcp_linear"]["service_name"] == "Linear"
+ assert providers["mcp_sentry"]["service"] == "sentry"
diff --git a/autogpt_platform/backend/backend/api/features/integrations/models.py b/autogpt_platform/backend/backend/api/features/integrations/models.py
index 8fed2d8050..f7c43e32b5 100644
--- a/autogpt_platform/backend/backend/api/features/integrations/models.py
+++ b/autogpt_platform/backend/backend/api/features/integrations/models.py
@@ -75,6 +75,12 @@ class ProviderMetadata(BaseModel):
"no auth types declared."
),
)
+ service: str = Field(
+ default="",
+ description="Grouping key shared by a block provider and its MCP server.",
+ )
+ service_name: str | None = Field(default=None)
+ service_icon: str | None = Field(default=None)
def get_supported_auth_types(name: str) -> list[CredentialsType]:
diff --git a/autogpt_platform/backend/backend/api/features/integrations/router.py b/autogpt_platform/backend/backend/api/features/integrations/router.py
index aa89340733..50af82c12d 100644
--- a/autogpt_platform/backend/backend/api/features/integrations/router.py
+++ b/autogpt_platform/backend/backend/api/features/integrations/router.py
@@ -76,6 +76,11 @@ from backend.integrations.oauth import (
)
from backend.integrations.oauth.device_base import BaseDeviceAuthHandler
from backend.integrations.providers import ProviderName, provider_key
+from backend.integrations.service_identity import (
+ service_for_catalog_entry,
+ service_for_credential,
+ service_for_provider,
+)
from backend.integrations.webhooks import get_webhook_manager
from backend.util import product_analytics
from backend.util.exceptions import (
@@ -249,6 +254,9 @@ class CredentialsMetaResponse(BaseModel):
description="Manual authorization scheme for MCP credentials",
)
is_managed: bool = False
+ service: str = ""
+ service_name: str | None = None
+ service_icon: str | None = None
@model_validator(mode="before")
@classmethod
@@ -290,6 +298,7 @@ def to_meta_response(cred: Credentials) -> CredentialsMetaResponse:
if stored_scheme in get_args(MCPAuthScheme):
mcp_auth_scheme = stored_scheme
+ identity = service_for_credential(cred)
return CredentialsMetaResponse(
id=cred.id,
provider=cred.provider,
@@ -300,6 +309,9 @@ def to_meta_response(cred: Credentials) -> CredentialsMetaResponse:
host=CredentialsMetaResponse.get_host(cred),
mcp_auth_scheme=mcp_auth_scheme,
is_managed=cred.is_managed,
+ service=identity.service,
+ service_name=identity.name,
+ service_icon=identity.icon,
)
@@ -2048,21 +2060,32 @@ async def list_providers(
all_providers = get_all_provider_names()
if user_id is None or not await has_codex_access_for_discovery(user_id):
all_providers = [name for name in all_providers if name != ProviderName.CODEX]
- return [
- ProviderMetadata(
+
+ def _native(name: str) -> ProviderMetadata:
+ identity = service_for_provider(name)
+ return ProviderMetadata(
name=name,
description=get_provider_description(name),
supported_auth_types=get_supported_auth_types(name),
+ service=identity.service,
+ service_name=identity.name,
+ service_icon=identity.icon,
)
- for name in all_providers
- ] + [
- ProviderMetadata(
+
+ def _catalog(entry) -> ProviderMetadata:
+ identity = service_for_catalog_entry(entry)
+ return ProviderMetadata(
name=entry.name,
display_name=entry.display_name,
description=entry.description,
mcp_server=entry.mcp_server,
+ service=identity.service,
+ service_name=identity.name,
+ service_icon=identity.icon,
)
- for entry in get_mcp_catalog()
+
+ return [_native(name) for name in all_providers] + [
+ _catalog(entry) for entry in get_mcp_catalog()
]
diff --git a/autogpt_platform/backend/backend/api/features/integrations/router_test.py b/autogpt_platform/backend/backend/api/features/integrations/router_test.py
index a0c5f1d801..5b501acc0c 100644
--- a/autogpt_platform/backend/backend/api/features/integrations/router_test.py
+++ b/autogpt_platform/backend/backend/api/features/integrations/router_test.py
@@ -362,6 +362,35 @@ class TestManagedCredentials:
assert managed_cred["is_managed"] is True
assert regular_cred["is_managed"] is False
+ def test_list_credentials_carries_the_service_identity(self):
+ from backend.integrations.mcp_catalog import get_mcp_catalog
+
+ linear = next(e for e in get_mcp_catalog() if e.name == "mcp_linear")
+ api_key = APIKeyCredentials(
+ id="key-1", provider="openai", title="My Key", api_key=SecretStr("sk")
+ )
+ mcp = OAuth2Credentials(
+ id="mcp-1",
+ provider="mcp",
+ title="MCP: mcp.linear.app",
+ access_token=SecretStr("t"),
+ scopes=[],
+ metadata={"mcp_server_url": linear.mcp_server.server_url},
+ )
+ with patch(
+ "backend.api.features.integrations.router.creds_manager"
+ ) as mock_mgr:
+ mock_mgr.store.get_all_creds = AsyncMock(return_value=[api_key, mcp])
+ resp = client.get("/credentials")
+
+ assert resp.status_code == 200
+ by_id = {c["id"]: c for c in resp.json()}
+ assert by_id["key-1"]["service"] == "openai"
+ assert by_id["key-1"]["service_icon"] == "openai"
+ assert by_id["mcp-1"]["service"] == "linear"
+ assert by_id["mcp-1"]["service_name"] == "Linear"
+ assert by_id["mcp-1"]["service_icon"] == linear.mcp_server.icon_id
+
# ---------------------------------------------------------------------------
# Managed credential provisioning infrastructure
diff --git a/autogpt_platform/backend/backend/api/features/mcp/test_oauth_auth_methods.py b/autogpt_platform/backend/backend/api/features/mcp/test_oauth_auth_methods.py
index 683df51197..3beae2fe6e 100644
--- a/autogpt_platform/backend/backend/api/features/mcp/test_oauth_auth_methods.py
+++ b/autogpt_platform/backend/backend/api/features/mcp/test_oauth_auth_methods.py
@@ -375,10 +375,10 @@ async def test_issuer_mismatch_rejected_before_registration(client, oauth_mocks)
@pytest.mark.parametrize(
"server_url,scope_override,expected",
[
- ("https://mcp.customer.io/mcp", None, ["read"]),
- ("https://MCP.CUSTOMER.IO:443/mcp/", None, ["read"]),
- ("https://mcp-eu.customer.io/mcp", None, ["read"]),
- ("https://mcp.customer.io/mcp", ["read", "write"], ["read", "write"]),
+ ("https://mcp.customer.io/mcp", None, ["read", "write"]),
+ ("https://MCP.CUSTOMER.IO:443/mcp/", None, ["read", "write"]),
+ ("https://mcp-eu.customer.io/mcp", None, ["read", "write"]),
+ ("https://mcp.customer.io/mcp", ["read"], ["read"]),
("https://mcp.customer.io/mcp", [], []),
("https://mcp.craft.do/my/mcp", None, []),
("https://unknown.example.com/mcp", None, ["discovered"]),
diff --git a/autogpt_platform/backend/backend/copilot/capabilities/dispatch.py b/autogpt_platform/backend/backend/copilot/capabilities/dispatch.py
index 0a8008a40c..6f3c463f94 100644
--- a/autogpt_platform/backend/backend/copilot/capabilities/dispatch.py
+++ b/autogpt_platform/backend/backend/copilot/capabilities/dispatch.py
@@ -33,7 +33,8 @@ def resolve_tool_dispatch(
tool_name: str, args: Mapping[str, Any] | None
) -> DispatchedToolCall | None:
"""The platform tool a ``run_capability`` call runs, or None when the call
- is not one — another tool, a block or MCP id, or ``validate_only``.
+ is not one — another tool, a block or MCP id, ``validate_only``, or a
+ ``connect`` call.
A ``skill:<name>`` id is the ``read_skill`` call that loads the skill,
with the name taken from the id, so a skill found by search is loaded
@@ -67,4 +68,7 @@ def resolve_tool_dispatch(
# Coercing it to {} would run the tool on its defaults; the dispatcher
# owns the "input must be an object" answer, so leave the call to it.
return None
+ if payload and payload.get("connect"):
+ # A tool has nothing to connect; the dispatcher describes it instead.
+ return None
return DispatchedToolCall(tool, name, {**dict(payload or {}), **bound})
diff --git a/autogpt_platform/backend/backend/copilot/capabilities/dispatch_test.py b/autogpt_platform/backend/backend/copilot/capabilities/dispatch_test.py
index 1260ce4c94..4f11b39d37 100644
--- a/autogpt_platform/backend/backend/copilot/capabilities/dispatch_test.py
+++ b/autogpt_platform/backend/backend/copilot/capabilities/dispatch_test.py
@@ -110,6 +110,8 @@ def test_resolver_turns_a_skill_id_into_the_read_skill_call():
[
# validate_only describes the call; it must not run the tool.
("run_capability", {"id": f"tool:{INNER}", "input": {}, "validate_only": True}),
+ # connect only checks credentials; a tool has none, so nothing runs.
+ ("run_capability", {"id": f"tool:{INNER}", "input": {"connect": True}}),
("run_capability", {"id": "skill:", "input": {}}),
("run_capability", {"id": "block:1234", "input": {}}),
("run_capability", {"id": "https://mcp.example/sse", "input": {}}),
diff --git a/autogpt_platform/backend/backend/copilot/capabilities/index.py b/autogpt_platform/backend/backend/copilot/capabilities/index.py
index 1a7bb0fb15..7bba02ec67 100644
--- a/autogpt_platform/backend/backend/copilot/capabilities/index.py
+++ b/autogpt_platform/backend/backend/copilot/capabilities/index.py
@@ -132,6 +132,7 @@ class CapabilityIndex:
permissions: "CopilotPermissions | None" = None,
limit: int = DEFAULT_LIMIT,
fallback_limit: int = DEFAULT_FALLBACK_LIMIT,
+ prefer_mcp: bool = False,
) -> SearchResult:
query = " ".join((query or "").split())
if not query:
@@ -182,7 +183,12 @@ class CapabilityIndex:
)[:fallback_limit]
else:
main = rest
- hits += _ranked([to_hit(idx, "search") for idx in main])
+ hits += _ranked(
+ [to_hit(idx, "search") for idx in main],
+ mcp_first=prefer_mcp
+ and service_indices is not None
+ and any(self.entries[idx].kind == "mcp_server" for idx in main),
+ )
return SearchResult(
query=query, hits=hits[:limit], fallback=fallback, service=service
)
@@ -340,10 +346,51 @@ def _service_tags(entry: CapabilityEntry) -> Iterable[str]:
yield from (tag.lower() for tag in entry.tags[marker + 1 :])
-def _ranked(hits: list[SearchHit]) -> list[SearchHit]:
+def _ranked(hits: list[SearchHit], *, mcp_first: bool = False) -> list[SearchHit]:
"""Coverage first; among equals a connected capability, then a platform
tool (first-party, no credentials, already trusted by the model), then
- the class-weighted BM25 score (``score`` already carries the weight)."""
+ the class-weighted BM25 score (``score`` already carries the weight).
+
+ ``mcp_first`` is for an expert chat that named a service: connection
+ still leads, but within a tier the service's MCP server comes before
+ its blocks, which stay listed for what the server cannot do."""
+ if mcp_first:
+ ranked = sorted(
+ hits,
+ key=lambda h: (
+ tier(h.entry, h.connected),
+ -h.coverage,
+ h.entry.kind != "tool",
+ -h.score,
+ h.entry.name.lower(),
+ ),
+ )
+ service_hits: dict[str, list[SearchHit]] = defaultdict(list)
+ for hit in ranked:
+ if hit.entry.service:
+ service_hits[hit.entry.service].append(hit)
+ for service, entries in service_hits.items():
+ service_hits[service] = sorted(
+ entries,
+ key=lambda h: (
+ tier(h.entry, h.connected),
+ h.entry.kind != "mcp_server",
+ -h.coverage,
+ h.entry.kind != "tool",
+ -h.score,
+ h.entry.name.lower(),
+ ),
+ )
+ offsets: dict[str, int] = defaultdict(int)
+ result: list[SearchHit] = []
+ for hit in ranked:
+ service = hit.entry.service
+ if not service:
+ result.append(hit)
+ continue
+ result.append(service_hits[service][offsets[service]])
+ offsets[service] += 1
+ return result
return sorted(
hits,
key=lambda h: (
diff --git a/autogpt_platform/backend/backend/copilot/capabilities/index_test.py b/autogpt_platform/backend/backend/copilot/capabilities/index_test.py
index 727bd95381..cfb9e34b87 100644
--- a/autogpt_platform/backend/backend/copilot/capabilities/index_test.py
+++ b/autogpt_platform/backend/backend/copilot/capabilities/index_test.py
@@ -298,3 +298,131 @@ def test_a_platform_entry_keeps_a_bare_ref_a_skill_shares(index):
shared = layered.get("web_search")
assert shared is not None and shared.kind == "tool"
assert layered.get("skill:web_search") is clone
+
+
+def _mcp(host: str, name: str, service: str, purpose: str):
+ return CapabilityEntry(
+ id=f"mcp:{host}",
+ kind="mcp_server",
+ klass="service",
+ name=name,
+ purpose=purpose,
+ tags=["mcp", service, host],
+ context="direct",
+ implementations=[Implementation(kind="mcp_server", ref=f"https://{host}/mcp")],
+ connection=Connection(
+ required=True, key_type="server_url", key=f"https://{host}/mcp"
+ ),
+ service=service,
+ )
+
+
+def twin_index() -> CapabilityIndex:
+ linear_block = _block(
+ LINEAR_ID,
+ "LinearCreateIssueBlock",
+ "Create a new issue in Linear.",
+ provider="linear",
+ args=("title", "team"),
+ )
+ linear_block.service = "linear"
+ return CapabilityIndex(
+ [
+ linear_block,
+ _mcp(
+ "mcp.linear.app",
+ "Linear",
+ "linear",
+ "Issues, projects and cycles in Linear.",
+ ),
+ _mcp("mcp.sentry.dev", "Sentry", "sentry", "Errors and traces in Sentry."),
+ ]
+ )
+
+
+def test_prefer_mcp_lists_the_server_before_its_block(twin_index: CapabilityIndex):
+ result = twin_index.search("linear issue", prefer_mcp=True)
+ assert result.hits[0].entry.id == "mcp:mcp.linear.app"
+ assert f"block:{LINEAR_ID}" in result.ids
+
+
+def test_prefer_mcp_still_puts_a_connected_block_first(twin_index: CapabilityIndex):
+ connected = ConnectionState(providers=frozenset({"linear"}))
+ result = twin_index.search("linear issue", connections=connected, prefer_mcp=True)
+ assert result.hits[0].entry.id == f"block:{LINEAR_ID}"
+ assert "mcp:mcp.linear.app" in result.ids
+
+
+def test_prefer_mcp_with_the_server_connected(twin_index: CapabilityIndex):
+ connected = ConnectionState(server_urls=frozenset({"https://mcp.linear.app/mcp"}))
+ result = twin_index.search("linear issue", connections=connected, prefer_mcp=True)
+ assert result.hits[0].entry.id == "mcp:mcp.linear.app"
+
+
+def test_default_order_is_coverage_first(twin_index: CapabilityIndex):
+ result = twin_index.search("linear issue")
+ assert result.ids.index(f"block:{LINEAR_ID}") < result.ids.index(
+ "mcp:mcp.linear.app"
+ )
+
+
+def test_prefer_mcp_leaves_a_block_without_a_twin_alone(twin_index: CapabilityIndex):
+ github = _block(
+ GITHUB_ID,
+ "GithubMakeIssueBlock",
+ "Create an issue on GitHub.",
+ provider="github",
+ )
+ github.service = "github"
+ index = twin_index.with_entries([github])
+ result = index.search("github issue", prefer_mcp=True)
+ assert result.hits[0].entry.id == f"block:{GITHUB_ID}"
+
+
+def test_prefer_mcp_keeps_coverage_first_when_no_server_matches(index):
+ notes = _skill("linear-notes", "Keep notes about Linear.")
+ layered = index.with_entries([notes])
+ result = layered.search("linear issue", prefer_mcp=True)
+ assert result.service == "linear"
+ assert result.names == ["LinearCreateIssueBlock", "linear-notes"]
+
+
+def test_prefer_mcp_does_not_move_one_service_ahead_of_another():
+ linear_block = _block(
+ LINEAR_ID,
+ "LinearCreateIssueBlock",
+ "Create and triage a GitHub issue from a Linear issue.",
+ provider="linear",
+ )
+ linear_block.service = "linear"
+ github_block = _block(
+ GITHUB_ID,
+ "GithubMakeIssueBlock",
+ "Create a new GitHub repository issue.",
+ provider="github",
+ )
+ github_block.service = "github"
+ index = CapabilityIndex(
+ [
+ linear_block,
+ github_block,
+ _mcp(
+ "mcp.linear.app",
+ "Linear",
+ "linear",
+ "Read Linear issues.",
+ ),
+ ]
+ )
+
+ result = index.search(
+ "create github repository linear read triage issue", prefer_mcp=True
+ )
+
+ assert result.ids.index(f"block:{GITHUB_ID}") < result.ids.index(
+ "mcp:mcp.linear.app"
+ )
+ assert result.ids.index("mcp:mcp.linear.app") < result.ids.index(
+ f"block:{LINEAR_ID}"
+ )
diff --git a/autogpt_platform/backend/backend/copilot/capabilities/models.py b/autogpt_platform/backend/backend/copilot/capabilities/models.py
index 449e3325d0..3052a6a59a 100644
--- a/autogpt_platform/backend/backend/copilot/capabilities/models.py
+++ b/autogpt_platform/backend/backend/copilot/capabilities/models.py
@@ -63,6 +63,9 @@ class CapabilityEntry(BaseModel):
id: str
kind: CapabilityKindName
klass: CapabilityClass = "service"
+ # The vendor behind the entry, the same for a block and the MCP server
+ # of one service. None for primitives and tools.
+ service: str | None = None
name: str
purpose: str = Field(max_length=PURPOSE_MAX_CHARS)
# Everything the source says about the capability, for the index only:
diff --git a/autogpt_platform/backend/backend/copilot/capabilities/sources/blocks.py b/autogpt_platform/backend/backend/copilot/capabilities/sources/blocks.py
index e574ef9d8e..818fa506d9 100644
--- a/autogpt_platform/backend/backend/copilot/capabilities/sources/blocks.py
+++ b/autogpt_platform/backend/backend/copilot/capabilities/sources/blocks.py
@@ -23,6 +23,7 @@ from backend.copilot.capabilities.models import (
)
from backend.copilot.capabilities.text import tokenize
from backend.data.model import CredentialsFieldInfo
+from backend.integrations.service_identity import service_for_provider
logger = logging.getLogger(__name__)
@@ -68,6 +69,11 @@ def _block_entry(block: AnyBlockSchema) -> CapabilityEntry:
id=f"block:{block.id}",
kind="block",
klass=block.capability_kind,
+ service=(
+ service_for_provider(provider).service
+ if provider and block.capability_kind == "service"
+ else None
+ ),
name=block.name,
purpose=clip_purpose(block.optimized_description or block.description),
# The optimized description is curated for retrieval (it is loaded from
diff --git a/autogpt_platform/backend/backend/copilot/capabilities/sources/mcp_catalog.py b/autogpt_platform/backend/backend/copilot/capabilities/sources/mcp_catalog.py
index baddedfd7b..f63916f0ba 100644
--- a/autogpt_platform/backend/backend/copilot/capabilities/sources/mcp_catalog.py
+++ b/autogpt_platform/backend/backend/copilot/capabilities/sources/mcp_catalog.py
@@ -18,6 +18,7 @@ from backend.copilot.capabilities.models import (
)
from backend.copilot.capabilities.text import tokenize
from backend.integrations.mcp_catalog import MCPCatalogEntry, get_mcp_catalog
+from backend.integrations.service_identity import service_for_catalog_entry
def mcp_catalog_entries() -> list[CapabilityEntry]:
@@ -56,6 +57,7 @@ def _catalog_entry(preset: MCPCatalogEntry, keyed_by_host: bool) -> CapabilityEn
id=f"mcp:{host}" if keyed_by_host and host else f"mcp:{slug}",
kind="mcp_server",
klass="service",
+ service=service_for_catalog_entry(preset).service,
name=preset.display_name,
purpose=clip_purpose(preset.description),
description=normalize_text(preset.description),
diff --git a/autogpt_platform/backend/backend/copilot/prompting.py b/autogpt_platform/backend/backend/copilot/prompting.py
index d42dc82b76..29aa4a91ba 100644
--- a/autogpt_platform/backend/backend/copilot/prompting.py
+++ b/autogpt_platform/backend/backend/copilot/prompting.py
@@ -189,6 +189,9 @@ Verify the hostname belongs to the vendor first; if several candidates exist,
ask the user which to use — never auto-pick a URL the user is about to sign
in to. Writes to servers outside the catalog pause for review.
+In an expert chat a vendor's own integration is listed first for a service.
+Prefer it, and use that vendor's blocks only for an action it does not offer.
+
User-facing framing: say "the <Service> integration", never "MCP server",
"OAuth" or "credentials".
@@ -379,12 +382,11 @@ ID / other parameters — the user can connect while answering.
Linear account", call the capability so the card does the job.
**4. Connecting is not running.** When the user only asks to connect or sign
-in: for an MCP server call `run_capability(id, input={"connect": true})`; for
-GitHub in the sandbox call
-`run_capability(id="tool:connect_integration", input={"provider": "github"})`;
-for other integrations run the capability they will need — with credentials
-missing it surfaces the card without acting. Never run an action the user has
-not asked for.
+in, call `run_capability(id, input={"connect": true})` for any capability: it
+surfaces the card when credentials are missing and confirms when they are
+not, and it never acts. GitHub in the sandbox is the one exception: use
+`run_capability(id="tool:connect_integration", input={"provider": "github"})`
+as the sandbox notes describe. Never run an action the user has not asked for.
**5. The card asks for credentials, not inputs.** Collect every other input in
chat (`ask_question` when you lack a value), then call the capability once
diff --git a/autogpt_platform/backend/backend/copilot/prompting_test.py b/autogpt_platform/backend/backend/copilot/prompting_test.py
index e2f2571647..0c7b1fd2a2 100644
--- a/autogpt_platform/backend/backend/copilot/prompting_test.py
+++ b/autogpt_platform/backend/backend/copilot/prompting_test.py
@@ -117,6 +117,16 @@ class TestCredentialsSurfacingGuardrails:
assert "Connecting is not running" in result
assert "The card asks for credentials, not inputs" in result
+ def test_prompt_states_the_one_connect_convention(self):
+ result = prompting.get_sdk_supplement(use_e2b=False)
+ assert 'input={"connect": true}' in result
+ assert "for any capability" in result
+
+ def test_prompt_tells_experts_the_vendor_integration_comes_first(self):
+ result = prompting.get_sdk_supplement(use_e2b=False)
+ assert "own integration is listed first" in result
+ assert "only for an action it does not offer" in result
+
class TestToolDiscoveryPriorityAntiPattern:
"""The Discovery section must forbid claiming a capability gap without
diff --git a/autogpt_platform/backend/backend/copilot/tools/find_capability.py b/autogpt_platform/backend/backend/copilot/tools/find_capability.py
index 33c8cbeb75..740bb857e3 100644
--- a/autogpt_platform/backend/backend/copilot/tools/find_capability.py
+++ b/autogpt_platform/backend/backend/copilot/tools/find_capability.py
@@ -129,6 +129,7 @@ class FindCapabilityTool(BaseTool):
kind=_KIND_ARG.get(kind or ""),
connections=connections,
permissions=get_current_permissions(),
+ prefer_mcp=session.expert_id is not None and context != "graph",
)
if not result.hits and not result.fallback:
return NoResultsResponse(
diff --git a/autogpt_platform/backend/backend/copilot/tools/find_capability_test.py b/autogpt_platform/backend/backend/copilot/tools/find_capability_test.py
index 7c12494145..e0284f1f17 100644
--- a/autogpt_platform/backend/backend/copilot/tools/find_capability_test.py
+++ b/autogpt_platform/backend/backend/copilot/tools/find_capability_test.py
@@ -167,3 +167,47 @@ async def test_loader_fails_closed_when_the_grant_lookup_fails():
assert state.providers == frozenset()
assert state.ungranted is not None
assert state.ungranted.providers == frozenset({"github"})
+
+
+async def test_expert_direct_search_lists_the_mcp_server_first():
+ """GitHub ships both as blocks and as a catalog server linked to the
+ ``github`` provider: an expert chat lists the server first and keeps the
+ blocks, which can write where the server cannot."""
+ session = make_session(USER, expert_id="expert-1")
+ with patch(
+ "backend.copilot.tools.find_capability.load_connection_state",
+ AsyncMock(return_value=ConnectionState()),
+ ):
+ result = await FindCapabilityTool()._execute(
+ USER, session, query="github issue"
+ )
+ assert isinstance(result, CapabilityListResponse)
+ assert result.capabilities[0]["kind"] == "mcp_server"
+ assert _github_hits(result)
+
+
+async def test_expert_graph_search_keeps_blocks():
+ session = make_session(USER, expert_id="expert-1")
+ with patch(
+ "backend.copilot.tools.find_capability.load_connection_state",
+ AsyncMock(return_value=ConnectionState()),
+ ):
+ result = await FindCapabilityTool()._execute(
+ USER, session, query="github issue", context="graph"
+ )
+ assert isinstance(result, CapabilityListResponse)
+ assert _github_hits(result)
+
+
+async def test_otto_search_keeps_the_usual_order():
+ session = make_session(USER)
+ with patch(
+ "backend.copilot.tools.find_capability.load_connection_state",
+ AsyncMock(return_value=ConnectionState()),
+ ):
+ result = await FindCapabilityTool()._execute(
+ USER, session, query="github issue"
+ )
+ assert isinstance(result, CapabilityListResponse)
+ assert _github_hits(result)
+ assert result.capabilities[0]["kind"] == "block"
diff --git a/autogpt_platform/backend/backend/copilot/tools/run_capability.py b/autogpt_platform/backend/backend/copilot/tools/run_capability.py
index b44ed462bd..f6fc861e49 100644
--- a/autogpt_platform/backend/backend/copilot/tools/run_capability.py
+++ b/autogpt_platform/backend/backend/copilot/tools/run_capability.py
@@ -23,6 +23,7 @@ from backend.copilot.capabilities.registry import configured_tool, get_registry
from backend.copilot.capabilities.resolve import resolve_entry
from backend.copilot.capabilities.sources import skill_name
from backend.copilot.capabilities.sources.mcp_catalog import setup_hint
+from backend.copilot.context import get_current_permissions
from backend.copilot.gate import METERED, gate_active
from backend.copilot.gate.subject import NO_OP, Subject, block_subject, mcp_subject
from backend.copilot.model import ChatSession
@@ -33,11 +34,16 @@ from backend.data.activity_event import ActivityEventDraft
from .base import GATE_APPROVED, BaseTool
from .capability_gates import gate_denied, gate_denied_error
from .describe_capability import MCP_RUN_PARAMETERS, UNKNOWN_ID_HINT, describe_skill
-from .helpers import required_input_keys, resolve_block_credentials
+from .helpers import (
+ prepare_block_for_execution,
+ required_input_keys,
+ resolve_block_credentials,
+)
from .models import (
CapabilityDetailsResponse,
ErrorResponse,
ReviewRequiredResponse,
+ SetupRequirementsResponse,
ToolResponseBase,
)
from .run_block import RunBlockTool
@@ -111,7 +117,7 @@ class RunCapabilityTool(BaseTool):
return NO_OP
if entry.kind == "mcp_server":
return _mcp_subject(entry.implementations[0].ref, payload or {})
- if entry.kind != "block":
+ if entry.kind != "block" or (payload or {}).get("connect", False):
return NO_OP
block_id = next(
(impl.ref for impl in entry.implementations if impl.kind == "block"), ""
@@ -226,6 +232,43 @@ async def _run_block(
block_id = next(
(impl.ref for impl in entry.implementations if impl.kind == "block"), ""
)
+ if payload.pop("connect", False):
+ permissions = get_current_permissions()
+ if permissions is not None and not permissions.is_block_allowed(
+ block_id, entry.name
+ ):
+ return ErrorResponse(
+ message=(
+ f"Block '{entry.name}' ({block_id}) is not permitted by the "
+ "current execution permissions. Use find_capability to discover "
+ "blocks that are allowed."
+ ),
+ session_id=session.session_id,
+ )
+ prep = await prepare_block_for_execution(
+ block_id=block_id,
+ input_data=payload,
+ user_id=user_id,
+ session=session,
+ session_id=session.session_id,
+ dry_run=False,
+ validate_only=False,
+ )
+ picker_only = (
+ isinstance(prep, SetupRequirementsResponse)
+ and prep.setup_info.user_readiness.has_all_credentials
+ )
+ if isinstance(prep, ToolResponseBase) and not picker_only:
+ return prep
+ return CapabilityDetailsResponse(
+ message=(
+ f"The user is already connected for {entry.name}. "
+ "Nothing was run. Call again without connect to act."
+ ),
+ capability=entry.listing(),
+ parameters={},
+ session_id=session.session_id,
+ )
return await RunBlockTool()._execute(
user_id,
session,
diff --git a/autogpt_platform/backend/backend/copilot/tools/run_capability_connect_test.py b/autogpt_platform/backend/backend/copilot/tools/run_capability_connect_test.py
new file mode 100644
index 0000000000..724bb91570
--- /dev/null
+++ b/autogpt_platform/backend/backend/copilot/tools/run_capability_connect_test.py
@@ -0,0 +1,164 @@
+"""``connect: true`` surfaces or confirms credentials without running anything."""
+
+from types import SimpleNamespace
+from unittest.mock import AsyncMock, MagicMock, patch
+
+from backend.copilot.capabilities.models import (
+ CapabilityEntry,
+ Connection,
+ Implementation,
+)
+from backend.copilot.gate.subject import NO_OP
+from backend.copilot.permissions import CopilotPermissions
+from backend.copilot.tools._test_data import make_session
+from backend.copilot.tools.models import (
+ CapabilityDetailsResponse,
+ SetupInfo,
+ SetupRequirementsResponse,
+ UserReadiness,
+)
+from backend.copilot.tools.run_capability import RunCapabilityTool, _run_block
+
+USER = "user-connect"
+BLOCK_ID = "11111111-1111-1111-1111-111111111111"
+
+
+def _entry() -> CapabilityEntry:
+ return CapabilityEntry(
+ id=f"block:{BLOCK_ID}",
+ kind="block",
+ name="LinearCreateIssueBlock",
+ purpose="Create an issue.",
+ implementations=[Implementation(kind="block", ref=BLOCK_ID)],
+ connection=Connection(required=True, key_type="provider", key="linear"),
+ service="linear",
+ )
+
+
+def _card(
+ session_id: str, has_all_credentials: bool = False
+) -> SetupRequirementsResponse:
+ return SetupRequirementsResponse(
+ message="needs linear",
+ session_id=session_id,
+ setup_info=SetupInfo(
+ agent_id=BLOCK_ID,
+ agent_name="LinearCreateIssueBlock",
+ user_readiness=UserReadiness(
+ has_all_credentials=has_all_credentials,
+ missing_credentials={},
+ ready_to_run=False,
+ ),
+ requirements={
+ "credentials": [],
+ "inputs": [],
+ "execution_modes": ["immediate"],
+ },
+ ),
+ )
+
+
+async def _connect(prep_result, validate_only: bool = False):
+ session = make_session(USER)
+ prepare = AsyncMock(return_value=prep_result(session.session_id))
+ with (
+ patch("backend.copilot.tools.run_capability.gate_denied", return_value=False),
+ patch(
+ "backend.copilot.tools.run_capability.prepare_block_for_execution",
+ prepare,
+ ),
+ patch("backend.copilot.tools.run_capability.RunBlockTool") as run_block,
+ ):
+ result = await _run_block(
+ _entry(), USER, session, {"connect": True}, validate_only, False
+ )
+ prepare.assert_awaited_once()
+ assert "connect" not in prepare.await_args.kwargs["input_data"]
+ run_block.assert_not_called()
+ return result, prepare
+
+
+async def test_connect_returns_the_card_when_credentials_are_missing():
+ result, _ = await _connect(_card)
+ assert isinstance(result, SetupRequirementsResponse)
+
+
+async def test_connect_confirms_and_does_not_run_when_credentials_exist():
+ # any non-ToolResponseBase stands for a ready preparation
+ result, _ = await _connect(lambda _session_id: object())
+ assert isinstance(result, CapabilityDetailsResponse)
+ assert "connected" in result.message.lower()
+ assert "nothing was run" in result.message.lower()
+
+
+async def test_connect_treats_a_picker_only_card_as_connected():
+ result, _ = await _connect(lambda sid: _card(sid, has_all_credentials=True))
+ assert isinstance(result, CapabilityDetailsResponse)
+ assert "connected" in result.message.lower()
+
+
+async def test_connect_with_validate_only_still_surfaces_the_card():
+ result, prepare = await _connect(_card, validate_only=True)
+ assert isinstance(result, SetupRequirementsResponse)
+ assert prepare.await_args.kwargs["validate_only"] is False
+
+
+async def test_connect_rejects_a_block_denied_by_permissions():
+ session = make_session(USER)
+ permissions = CopilotPermissions(blocks=[BLOCK_ID])
+ with (
+ patch("backend.copilot.tools.run_capability.gate_denied", return_value=False),
+ patch(
+ "backend.copilot.tools.run_capability.get_current_permissions",
+ return_value=permissions,
+ ),
+ patch(
+ "backend.copilot.tools.run_capability.prepare_block_for_execution",
+ AsyncMock(),
+ ) as prepare,
+ ):
+ result = await _run_block(
+ _entry(), USER, session, {"connect": True}, False, False
+ )
+
+ assert "not permitted" in result.message
+ prepare.assert_not_awaited()
+
+
+async def test_without_connect_the_block_runs_as_before():
+ session = make_session(USER)
+ with (
+ patch("backend.copilot.tools.run_capability.gate_denied", return_value=False),
+ patch("backend.copilot.tools.run_capability.RunBlockTool") as run_block,
+ ):
+ run_block.return_value._execute = AsyncMock(
+ return_value=_card(session.session_id)
+ )
+ await _run_block(_entry(), USER, session, {"title": "x"}, False, False)
+ run_block.return_value._execute.assert_awaited_once()
+
+
+async def test_a_connect_call_on_a_block_has_no_gate_subject():
+ session = make_session(USER)
+ entry = _entry()
+ with (
+ patch(
+ "backend.copilot.tools.run_capability.resolve_session_entry",
+ AsyncMock(return_value=entry),
+ ),
+ patch(
+ "backend.copilot.tools.run_capability.get_block", return_value=MagicMock()
+ ),
+ patch(
+ "backend.copilot.tools.run_capability.required_input_keys",
+ return_value=set(),
+ ),
+ patch(
+ "backend.copilot.tools.run_capability.block_subject",
+ return_value=SimpleNamespace(effect=None),
+ ),
+ ):
+ subject = await RunCapabilityTool().gate_subject(
+ USER, session, {"id": entry.id, "input": {"connect": True}}
+ )
+ assert subject is NO_OP
diff --git a/autogpt_platform/backend/backend/integrations/mcp_catalog.json b/autogpt_platform/backend/backend/integrations/mcp_catalog.json
index 8c4391580b..6b4a1c0b3f 100644
--- a/autogpt_platform/backend/backend/integrations/mcp_catalog.json
+++ b/autogpt_platform/backend/backend/integrations/mcp_catalog.json
@@ -54,7 +54,7 @@
"mcp_server": {
"server_url": "https://mcp.airtable.com/mcp",
"documentation_url": "https://support.airtable.com/articles/9897799762-using-the-airtable-mcp-server",
- "setup_instructions": "Sign in and select bases to authorize. Records, comments and schema reads are selected initially. Allow changes adds record, comment and schema writes. A personal access token can further limit automation to selected bases or workspaces.",
+ "setup_instructions": "Sign in and select bases to authorize. This requests record, comment and schema reads and writes. A personal access token can further limit automation to selected bases or workspaces.",
"connection_mode": "hosted",
"icon_id": "airtable",
"auth_methods": [
@@ -65,9 +65,7 @@
"data.records:read",
"schema.bases:read",
"data.recordComments:read",
- "workspacesAndBases:read"
- ],
- "oauth_write_scopes": [
+ "workspacesAndBases:read",
"data.records:write",
"schema.bases:write",
"data.recordComments:write"
@@ -179,11 +177,11 @@
{
"name": "mcp_apollo_io",
"display_name": "Apollo.io",
- "description": "Find people and read existing Apollo contacts, with optional contact creation and updates.",
+ "description": "Find people and read, create and update Apollo contacts.",
"mcp_server": {
"server_url": "https://mcp.apollo.io/mcp",
"documentation_url": "https://docs.apollo.io/docs/apollo-mcp",
- "setup_instructions": "Sign in for people search and existing-contact reads. Allow changes adds contact creation and updates. Account access rules still apply.",
+ "setup_instructions": "Sign in for people search, contact reads, and contact creation and updates. Account access rules still apply.",
"connection_mode": "hosted",
"icon_id": "apollo",
"auth_methods": [
@@ -194,9 +192,7 @@
"app_scopes",
"mixed_people_api_search",
"contacts_search",
- "contact_read"
- ],
- "oauth_write_scopes": [
+ "contact_read",
"contact_write",
"contact_update"
],
@@ -463,15 +459,13 @@
"mcp_server": {
"server_url": "https://mcp.context.dev/mcp",
"documentation_url": "https://docs.context.dev/install-mcp",
- "setup_instructions": "Sign in to research and retrieve web content. Read access is selected initially; allow changes only when you want to create or update monitors. Account credits apply.",
+ "setup_instructions": "Sign in to research and retrieve web content, and to create or update monitors. Account credits apply.",
"connection_mode": "hosted",
"auth_methods": [
"oauth"
],
"oauth_scopes": [
- "api.read"
- ],
- "oauth_write_scopes": [
+ "api.read",
"api.write"
],
"icon_id": "context_dev"
@@ -535,15 +529,13 @@
"mcp_server": {
"server_url": "https://mcp.customer.io/mcp",
"documentation_url": "https://docs.customer.io/ai/mcp/get-started/",
- "setup_instructions": "An account admin must enable Customer.io MCP under Settings > AI. Sign in and select your US workspaces. Read access is selected initially; Allow changes adds draft-write access. Sensitive data, live publishing and configuration need separate grants and are not requested here.",
+ "setup_instructions": "An account admin must enable Customer.io MCP under Settings > AI. Sign in and select your US workspaces. This requests read and draft-write access; sensitive data, live publishing and configuration need separate grants and are not requested here.",
"connection_mode": "hosted",
"auth_methods": [
"oauth"
],
"oauth_scopes": [
- "read"
- ],
- "oauth_write_scopes": [
+ "read",
"write"
],
"icon_id": "customer_io"
@@ -556,15 +548,13 @@
"mcp_server": {
"server_url": "https://mcp-eu.customer.io/mcp",
"documentation_url": "https://docs.customer.io/ai/mcp/get-started/",
- "setup_instructions": "An account admin must enable Customer.io MCP under Settings > AI. Sign in and select your EU workspaces. Read access is selected initially; Allow changes adds draft-write access. Sensitive data, live publishing and configuration need separate grants and are not requested here.",
+ "setup_instructions": "An account admin must enable Customer.io MCP under Settings > AI. Sign in and select your EU workspaces. This requests read and draft-write access; sensitive data, live publishing and configuration need separate grants and are not requested here.",
"connection_mode": "hosted",
"auth_methods": [
"oauth"
],
"oauth_scopes": [
- "read"
- ],
- "oauth_write_scopes": [
+ "read",
"write"
],
"icon_id": "customer_io"
@@ -587,17 +577,20 @@
{
"name": "mcp_github",
"display_name": "GitHub",
- "description": "Search repositories and read code, issues, and pull requests with GitHub's read-only MCP tools.",
+ "description": "Search repositories, read code, and work with issues and pull requests through GitHub's MCP tools.",
"mcp_server": {
- "server_url": "https://api.githubcopilot.com/mcp/readonly",
+ "server_url": "https://api.githubcopilot.com/mcp/",
"documentation_url": "https://github.com/github/github-mcp-server/blob/main/docs/remote-server.md",
- "setup_instructions": "Use a fine-grained personal access token limited to the repositories and read permissions you need. Organization approval or SSO authorization may be required. This connection exposes read-only tools.",
+ "setup_instructions": "Use a fine-grained personal access token limited to the repositories and permissions you need. Organization approval or SSO authorization may be required.",
"connection_mode": "hosted",
"auth_methods": [
"bearer"
],
"icon_id": "github",
- "provider": "github"
+ "provider": "github",
+ "legacy_server_urls": [
+ "https://api.githubcopilot.com/mcp/readonly"
+ ]
}
},
{
@@ -739,20 +732,18 @@
{
"name": "mcp_linear",
"display_name": "Linear",
- "description": "Search issues, projects, and documents, with optional updates to your team's work.",
+ "description": "Search and update issues, projects, and documents.",
"mcp_server": {
"server_url": "https://mcp.linear.app/mcp",
"documentation_url": "https://linear.app/docs/mcp",
- "setup_instructions": "Sign in to the Linear workspace to connect. Read access is selected initially; Allow changes adds write access. You can also use a Linear API key limited to the teams and permissions you need.",
+ "setup_instructions": "Sign in to the Linear workspace to connect. You can also use a Linear API key limited to the teams and permissions you need.",
"connection_mode": "hosted",
"auth_methods": [
"oauth",
"bearer"
],
"oauth_scopes": [
- "read"
- ],
- "oauth_write_scopes": [
+ "read",
"write"
],
"icon_id": "linear",
@@ -1014,7 +1005,7 @@
"mcp_server": {
"server_url": "https://api.fullstory.com/mcp/subtext",
"documentation_url": "https://subtext.fullstory.com/docs/install/manual",
- "setup_instructions": "Sign in to Subtext or use a project API key from Settings > API Keys. Configure the capture snippet to make recordings available. Session and privacy-setting reads are selected initially; allow changes only to modify privacy rules.",
+ "setup_instructions": "Sign in to Subtext or use a project API key from Settings > API Keys. Configure the capture snippet to make recordings available. This requests session reads and privacy-rule changes.",
"connection_mode": "hosted",
"auth_methods": [
"oauth",
@@ -1022,9 +1013,7 @@
],
"oauth_scopes": [
"sessions:read",
- "settings.privacy:read"
- ],
- "oauth_write_scopes": [
+ "settings.privacy:read",
"settings.privacy.element_block:write",
"settings.privacy.url:write"
],
@@ -1102,7 +1091,7 @@
"mcp_server": {
"server_url": "https://treg.to/mcp/",
"documentation_url": "https://treg.to/llms.txt",
- "setup_instructions": "Sign in and choose your Treg team, or use a team-scoped dashboard API key. Discovery and account reads are selected initially; allow changes to grant tool execution, which may consume team credits.",
+ "setup_instructions": "Sign in and choose your Treg team, or use a team-scoped dashboard API key. This requests discovery, account reads and tool execution, which may consume team credits.",
"connection_mode": "hosted",
"auth_methods": [
"oauth",
@@ -1110,9 +1099,7 @@
],
"oauth_scopes": [
"treg:catalog",
- "treg:read"
- ],
- "oauth_write_scopes": [
+ "treg:read",
"treg:call"
],
"icon_id": "treg"
diff --git a/autogpt_platform/backend/backend/integrations/mcp_catalog.py b/autogpt_platform/backend/backend/integrations/mcp_catalog.py
index a7d25b4087..2cda913439 100644
--- a/autogpt_platform/backend/backend/integrations/mcp_catalog.py
+++ b/autogpt_platform/backend/backend/integrations/mcp_catalog.py
@@ -49,6 +49,12 @@ class MCPServerMetadata(BaseModel):
"also ships blocks for it. Lets the UI file an MCP connection under the "
"same service as its API-key credential instead of a generic MCP group.",
)
+ legacy_server_urls: list[str] = Field(
+ default_factory=list,
+ exclude=True,
+ description="Addresses this server was listed under before, so "
+ "connections saved against them still belong to it.",
+ )
@field_validator("server_url", "documentation_url", "oauth_server_url")
@classmethod
@@ -101,6 +107,8 @@ class MCPServerMetadata(BaseModel):
raise ValueError("OAuth settings require OAuth authentication")
for option in self.server_url_options:
self.validate_public_url(option.url)
+ for url in self.legacy_server_urls:
+ self.validate_public_url(url)
return self
@field_validator("oauth_scopes", "oauth_write_scopes")
@@ -162,6 +170,7 @@ def get_mcp_catalog_entry_for_url(server_url: str) -> MCPCatalogEntry | None:
server.server_url,
server.oauth_server_url,
*(option.url for option in server.server_url_options),
+ *server.legacy_server_urls,
]
if any(url and _catalog_url_key(url) == key for url in urls):
return entry
diff --git a/autogpt_platform/backend/backend/integrations/mcp_catalog_test.py b/autogpt_platform/backend/backend/integrations/mcp_catalog_test.py
index 3fd717a8ba..fa3d7043a1 100644
--- a/autogpt_platform/backend/backend/integrations/mcp_catalog_test.py
+++ b/autogpt_platform/backend/backend/integrations/mcp_catalog_test.py
@@ -50,6 +50,19 @@ def test_openseo_catalog_entry_defaults_to_cloud_and_allows_self_hosting():
assert entry.mcp_server.documentation_url == "https://openseo.so/docs/mcp"
+def test_no_catalogued_server_is_limited_to_read_access():
+ for entry in get_mcp_catalog():
+ server = entry.mcp_server
+ assert not server.oauth_write_scopes, entry.name
+ assert "readonly" not in (server.server_url or ""), entry.name
+
+
+def test_a_connection_saved_against_an_old_address_still_finds_its_server():
+ entry = get_mcp_catalog_entry_for_url("https://api.githubcopilot.com/mcp/readonly")
+ assert entry is not None and entry.name == "mcp_github"
+ assert "legacy_server_urls" not in entry.mcp_server.model_dump()
+
+
@pytest.mark.parametrize(
"url",
[
@@ -233,15 +246,15 @@ def test_a_tool_cannot_carry_two_effects():
@pytest.mark.parametrize(
"url, tool, effect",
[
- ("https://api.githubcopilot.com/mcp/readonly", "issue_read", "read"),
- ("https://api.githubcopilot.com/mcp/readonly", "create_branch", "external"),
- ("https://api.githubcopilot.com/mcp/readonly", "issue_write", "irreversible"),
+ ("https://api.githubcopilot.com/mcp/", "issue_read", "read"),
+ ("https://api.githubcopilot.com/mcp/", "create_branch", "external"),
+ ("https://api.githubcopilot.com/mcp/", "issue_write", "irreversible"),
(
- "https://api.githubcopilot.com/mcp/readonly",
+ "https://api.githubcopilot.com/mcp/",
"merge_pull_request",
"irreversible",
),
- ("https://api.githubcopilot.com/mcp/readonly", "not_published", None),
+ ("https://api.githubcopilot.com/mcp/", "not_published", None),
("https://mcp.example.com/mcp", "get_things", None),
],
)
diff --git a/autogpt_platform/backend/backend/integrations/service_identity.py b/autogpt_platform/backend/backend/integrations/service_identity.py
new file mode 100644
index 0000000000..3f4b0838e9
--- /dev/null
+++ b/autogpt_platform/backend/backend/integrations/service_identity.py
@@ -0,0 +1,89 @@
+"""The service behind a provider, a catalog server or a stored credential.
+
+A vendor can be reachable two ways, as a block provider ("linear") and as an
+MCP server ("mcp_linear"), and a stored MCP credential names neither: it is
+``provider="mcp"`` plus a server URL. Every listing that groups, de-dupes or
+draws a logo needs the same answer to "which service is this", so it is
+computed here and nowhere else.
+"""
+
+import logging
+from urllib.parse import urlsplit
+
+from pydantic import BaseModel, ConfigDict
+
+from backend.data.model import Credentials, OAuth2Credentials
+from backend.integrations.credentials_store import canonical_provider
+from backend.integrations.mcp_catalog import (
+ MCPCatalogEntry,
+ get_mcp_catalog_entry_for_url,
+)
+from backend.integrations.providers import ProviderName
+
+logger = logging.getLogger(__name__)
+
+UNKNOWN_MCP_SERVICE = "mcp:unknown"
+
+_warned_credential_ids: set[str] = set()
+
+
+class ServiceIdentity(BaseModel):
+ model_config = ConfigDict(frozen=True)
+
+ service: str
+ name: str | None = None
+ icon: str | None = None
+
+
+def catalog_slug(entry: MCPCatalogEntry) -> str:
+ return entry.name.removeprefix("mcp_")
+
+
+def service_for_provider(provider: str) -> ServiceIdentity:
+ """A block provider is its own service; its logo is filed under its slug."""
+ slug = canonical_provider(provider)
+ return ServiceIdentity(service=slug, icon=slug)
+
+
+def service_for_catalog_entry(entry: MCPCatalogEntry) -> ServiceIdentity:
+ server = entry.mcp_server
+ return ServiceIdentity(
+ service=server.provider or catalog_slug(entry),
+ name=entry.display_name,
+ icon=server.icon_id,
+ )
+
+
+def service_for_credential(credential: Credentials) -> ServiceIdentity:
+ provider = canonical_provider(credential.provider)
+ if provider != ProviderName.MCP.value or not isinstance(
+ credential, OAuth2Credentials
+ ):
+ return service_for_provider(provider)
+ url = (credential.metadata or {}).get("mcp_server_url")
+ if not isinstance(url, str) or not url.strip():
+ _warn_once(credential.id, "has no server URL")
+ return ServiceIdentity(service=UNKNOWN_MCP_SERVICE)
+ entry = get_mcp_catalog_entry_for_url(url)
+ if entry is not None:
+ return service_for_catalog_entry(entry)
+ host = _hostname(url)
+ if host is None:
+ _warn_once(credential.id, "has an unparseable server URL")
+ return ServiceIdentity(service=UNKNOWN_MCP_SERVICE)
+ return ServiceIdentity(service=f"mcp:{host}", name=host)
+
+
+def _warn_once(credential_id: str, reason: str) -> None:
+ if credential_id in _warned_credential_ids:
+ return
+ _warned_credential_ids.add(credential_id)
+ logger.warning("MCP credential %s %s", credential_id, reason)
+
+
+def _hostname(url: str) -> str | None:
+ try:
+ parsed = urlsplit(url.strip())
+ except ValueError:
+ return None
+ return parsed.hostname or None
diff --git a/autogpt_platform/backend/backend/integrations/service_identity_test.py b/autogpt_platform/backend/backend/integrations/service_identity_test.py
new file mode 100644
index 0000000000..9ae2f99ea7
--- /dev/null
+++ b/autogpt_platform/backend/backend/integrations/service_identity_test.py
@@ -0,0 +1,110 @@
+"""One grouping key for a provider, a catalog server and a stored credential."""
+
+import logging
+
+import pytest
+from pydantic import SecretStr
+
+from backend.data.model import APIKeyCredentials, OAuth2Credentials
+from backend.integrations.mcp_catalog import MCPCatalogEntry, get_mcp_catalog
+from backend.integrations.service_identity import (
+ service_for_catalog_entry,
+ service_for_credential,
+ service_for_provider,
+)
+
+
+def _entry(name: str) -> MCPCatalogEntry:
+ return next(e for e in get_mcp_catalog() if e.name == name)
+
+
+def _mcp_credential(
+ url: str | None, provider: str = "mcp", credential_id: str = "cred-mcp"
+) -> OAuth2Credentials:
+ return OAuth2Credentials(
+ id=credential_id,
+ provider=provider,
+ title=f"MCP: {url}",
+ access_token=SecretStr("t"),
+ scopes=[],
+ metadata={"mcp_server_url": url} if url is not None else {},
+ )
+
+
+def test_block_provider_is_its_own_service():
+ identity = service_for_provider("github")
+ assert identity.service == "github"
+ assert identity.name is None
+ assert identity.icon == "github"
+
+
+def test_catalog_entry_with_a_block_provider_uses_that_provider():
+ entry = _entry("mcp_apollo_io")
+ identity = service_for_catalog_entry(entry)
+ assert identity.service == "apollo"
+ assert identity.name == "Apollo.io"
+ assert identity.icon == entry.mcp_server.icon_id
+
+
+def test_catalog_entry_without_a_block_provider_uses_its_slug():
+ identity = service_for_catalog_entry(_entry("mcp_sentry"))
+ assert identity.service == "sentry"
+ assert identity.name == "Sentry"
+
+
+def test_api_key_credential_resolves_to_its_provider():
+ credential = APIKeyCredentials(
+ id="c", provider="notion", title="Team Notion", api_key=SecretStr("k")
+ )
+ assert service_for_credential(credential).service == "notion"
+
+
+def test_mcp_credential_for_a_catalog_url_resolves_to_the_catalog_service():
+ url = _entry("mcp_linear").mcp_server.server_url
+ assert url
+ identity = service_for_credential(_mcp_credential(url))
+ assert identity.service == "linear"
+ assert identity.name == "Linear"
+
+
+def test_mcp_credential_matches_the_catalog_url_without_a_trailing_slash():
+ url = _entry("mcp_notion").mcp_server.server_url
+ assert url
+ identity = service_for_credential(_mcp_credential(url.rstrip("/") + "/"))
+ assert identity.service == "notion"
+
+
+def test_mcp_credential_for_a_custom_url_is_keyed_by_host():
+ identity = service_for_credential(
+ _mcp_credential("https://mcp.internal.example/mcp")
+ )
+ assert identity.service == "mcp:mcp.internal.example"
+ assert identity.name == "mcp.internal.example"
+ assert identity.icon is None
+
+
+def test_mcp_credential_with_a_legacy_provider_spelling_still_resolves():
+ url = _entry("mcp_linear").mcp_server.server_url
+ assert url
+ identity = service_for_credential(_mcp_credential(url, provider="ProviderName.MCP"))
+ assert identity.service == "linear"
+
+
+def test_mcp_credential_with_a_malformed_url_never_raises():
+ identity = service_for_credential(_mcp_credential("not a url"))
+ assert identity.service == "mcp:unknown"
+ identity = service_for_credential(_mcp_credential(None))
+ assert identity.service == "mcp:unknown"
+
+
+def test_a_malformed_credential_is_warned_about_once(
+ caplog: pytest.LogCaptureFixture,
+):
+ credential = _mcp_credential("not a url", credential_id="cred-warn-once")
+ with caplog.at_level(
+ logging.WARNING, logger="backend.integrations.service_identity"
+ ):
+ service_for_credential(credential)
+ service_for_credential(credential)
+ warnings = [r for r in caplog.records if "cred-warn-once" in r.getMessage()]
+ assert len(warnings) == 1
diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/__tests__/composer-connect-expert.test.tsx b/autogpt_platform/frontend/src/app/(platform)/copilot/__tests__/composer-connect-expert.test.tsx
new file mode 100644
index 0000000000..6505228199
--- /dev/null
+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/__tests__/composer-connect-expert.test.tsx
@@ -0,0 +1,230 @@
+import {
+ getGetV1ListCredentialsMockHandler,
+ getGetV1ListProvidersMockHandler,
+} from "@/app/api/__generated__/endpoints/integrations/integrations.msw";
+import { server } from "@/mocks/mock-server";
+import {
+ fireEvent,
+ render,
+ screen,
+ waitFor,
+ within,
+} from "@/tests/integrations/test-utils";
+import userEvent from "@testing-library/user-event";
+import { http, HttpResponse } from "msw";
+import { afterEach, beforeEach, describe, expect, test, vi } from "vitest";
+import { ChatContainer } from "../components/ChatContainer/ChatContainer";
+import { CopilotModals } from "../components/CopilotModals/CopilotModals";
+import { useCopilotUIStore } from "../store";
+
+vi.mock("@/services/feature-flags/use-get-flag", async (importOriginal) => {
+ const actual =
+ await importOriginal<
+ typeof import("@/services/feature-flags/use-get-flag")
+ >();
+ return {
+ ...actual,
+ useGetFlag: () => false,
+ useFlagStatus: () => ({ enabled: false, ready: true }),
+ };
+});
+
+vi.mock("@/lib/auth/hooks/useAuth", () => ({
+ useAuth: () => ({ user: null, isUserLoading: false, isLoggedIn: true }),
+}));
+
+vi.mock("../components/ChatMessagesContainer/ChatMessagesContainer", () => ({
+ ChatMessagesContainer: () => <div data-testid="chat-messages-container" />,
+}));
+
+class MockResizeObserver {
+ observe() {}
+ disconnect() {}
+ unobserve() {}
+}
+
+const maria = {
+ id: "expert-maria",
+ name: "Maria",
+ avatarUrl: null,
+ role: "Marketing Strategist",
+ isArchived: false,
+ readOnlyReason: null,
+};
+
+const baseProps = {
+ messages: [] as never[],
+ status: "ready",
+ error: undefined,
+ isLoadingSession: false,
+ isSessionError: false,
+ isCreatingSession: false,
+ isReconnecting: false,
+ isRestoringActiveSession: false,
+ restoreStatusMessage: null,
+ activeStreamStartedAt: null,
+ isUserStopping: false,
+ isSyncing: false,
+ onCreateSession: vi.fn(),
+ onSend: vi.fn(),
+ onStop: vi.fn(),
+ onEnqueue: vi.fn(),
+ queuedMessages: [],
+ isUploadingFiles: false,
+ hasMoreMessages: false,
+ isLoadingMore: false,
+ onLoadMore: vi.fn(),
+ droppedFiles: [],
+ onDroppedFilesConsumed: vi.fn(),
+};
+
+function arrangeSentry() {
+ const requests = { token: 0, grants: 0 };
+ server.use(
+ getGetV1ListCredentialsMockHandler([]),
+ getGetV1ListProvidersMockHandler([
+ {
+ name: "mcp_sentry",
+ display_name: "Sentry",
+ description: "Errors",
+ supported_auth_types: [],
+ service: "sentry",
+ service_name: "Sentry",
+ service_icon: "sentry",
+ mcp_server: {
+ server_url: "https://mcp.sentry.dev/mcp",
+ documentation_url: "https://docs.sentry.io",
+ setup_instructions: "Paste your Sentry token.",
+ connection_mode: "hosted",
+ auth_methods: ["bearer"],
+ oauth_write_scopes: [],
+ server_url_options: [],
+ allow_custom_url: false,
+ },
+ },
+ ]),
+ http.post("*/api/mcp/discover-tools", () =>
+ HttpResponse.json({
+ tools: [],
+ server_url: "https://mcp.sentry.dev/mcp",
+ }),
+ ),
+ http.post("*/api/mcp/token", () => {
+ requests.token += 1;
+ return HttpResponse.json({
+ id: "cred-sentry",
+ provider: "mcp",
+ type: "oauth2",
+ title: "MCP: mcp.sentry.dev",
+ service: "sentry",
+ });
+ }),
+ http.post("*/api/experts/:expertId/credentials", () => {
+ requests.grants += 1;
+ return HttpResponse.json([]);
+ }),
+ );
+ return requests;
+}
+
+beforeEach(() => {
+ useCopilotUIStore.setState({ contextPanelExpert: null });
+ vi.stubGlobal("ResizeObserver", MockResizeObserver);
+});
+
+afterEach(() => {
+ useCopilotUIStore.setState({ contextPanelExpert: null });
+ vi.unstubAllGlobals();
+});
+
+describe("connecting a service from the composer", () => {
+ test("a new chat after an expert chat grants nothing to that expert", async () => {
+ const requests = arrangeSentry();
+ const { rerender } = render(
+ <>
+ <ChatContainer
+ key="chat-host-session-maria"
+ {...baseProps}
+ sessionId="session-maria"
+ expertIdentity={maria}
+ />
+ <CopilotModals />
+ </>,
+ );
+ await waitFor(() =>
+ expect(useCopilotUIStore.getState().contextPanelExpert).toEqual({
+ id: "expert-maria",
+ name: "Maria",
+ }),
+ );
+
+ rerender(
+ <>
+ <ChatContainer
+ key="chat-host-new"
+ {...baseProps}
+ sessionId={null}
+ expertIdentity={null}
+ />
+ <CopilotModals />
+ </>,
+ );
+
+ await userEvent.click(
+ await screen.findByRole("button", { name: "Add files and more" }),
+ );
+ await userEvent.click(
+ await screen.findByRole("menuitem", { name: /Connect service/ }),
+ );
+ const dialog = await screen.findByRole("dialog");
+ fireEvent.click(
+ await within(dialog).findByRole("button", { name: /Sentry/ }),
+ );
+ fireEvent.change(await within(dialog).findByLabelText("API token"), {
+ target: { value: "sntrys_token" },
+ });
+ fireEvent.click(within(dialog).getByRole("button", { name: "Save token" }));
+
+ await waitFor(() => expect(screen.queryByRole("dialog")).toBeNull());
+ expect(requests.token).toBe(1);
+ expect(requests.grants).toBe(0);
+ expect(useCopilotUIStore.getState().contextPanelExpert).toBeNull();
+ });
+
+ test("an expert resolving from cache cannot receive a new grant", async () => {
+ const requests = arrangeSentry();
+ render(
+ <>
+ <ChatContainer
+ {...baseProps}
+ sessionId={null}
+ expertIdentity={maria}
+ isResolvingExpertIdentity
+ />
+ <CopilotModals />
+ </>,
+ );
+
+ await waitFor(() =>
+ expect(useCopilotUIStore.getState().contextPanelExpert).toBeNull(),
+ );
+ await userEvent.click(
+ await screen.findByRole("button", { name: "Add files and more" }),
+ );
+ await userEvent.click(
+ await screen.findByRole("menuitem", { name: /Connect service/ }),
+ );
+ const dialog = await screen.findByRole("dialog");
+ fireEvent.click(
+ await within(dialog).findByRole("button", { name: /Sentry/ }),
+ );
+ fireEvent.change(await within(dialog).findByLabelText("API token"), {
+ target: { value: "sntrys_token" },
+ });
+ fireEvent.click(within(dialog).getByRole("button", { name: "Save token" }));
+
+ await waitFor(() => expect(screen.queryByRole("dialog")).toBeNull());
+ expect(requests.token).toBe(1);
+ expect(requests.grants).toBe(0);
+ });
+});
diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/__tests__/store.test.ts b/autogpt_platform/frontend/src/app/(platform)/copilot/__tests__/store.test.ts
index 6b47644768..b09c7763d6 100644
--- a/autogpt_platform/frontend/src/app/(platform)/copilot/__tests__/store.test.ts
+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/__tests__/store.test.ts
@@ -522,15 +522,13 @@ describe("lastArtifact session scoping", () => {
expect(useCopilotUIStore.getState().artifactPanel.lastArtifact).toBeNull();
});
- it("clearLastArtifact forgets the previous chat's expert integrations", () => {
+ it("clearLastArtifact leaves the previous chat's integrations tab", () => {
useCopilotUIStore
.getState()
.toggleIntegrationsPanel({ id: "expert-maria", name: "Maria" });
useCopilotUIStore.getState().closeArtifactPanel();
useCopilotUIStore.getState().clearLastArtifact();
- const s = useCopilotUIStore.getState();
- expect(s.contextPanelExpert).toBeNull();
- expect(s.artifactPanel.activeTab).toBe("files");
+ expect(useCopilotUIStore.getState().artifactPanel.activeTab).toBe("files");
});
it("closing the artifacts tab forgets the remembered preview", () => {
diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChainActionCard/McpConnectorRow.tsx b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChainActionCard/McpConnectorRow.tsx
index c1cf708415..bc2c18d44c 100644
--- a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChainActionCard/McpConnectorRow.tsx
+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChainActionCard/McpConnectorRow.tsx
@@ -78,6 +78,16 @@ export function McpConnectorRow({ request }: { request: McpConnectorRequest }) {
<Icon icon={CheckmarkCircle02Icon} size={16} />
Connected
</span>
+ ) : request.grantable ? (
+ <Button
+ variant="primary"
+ size="small"
+ className="shrink-0"
+ disabled={request.granting || request.loading}
+ onClick={request.onGrant}
+ >
+ {request.granting ? "Granting…" : "Grant access"}
+ </Button>
) : (
<Button
variant="primary"
diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChainActionCard/__tests__/ChainActionCard.test.tsx b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChainActionCard/__tests__/ChainActionCard.test.tsx
index b2d87ba241..2bc9c0155a 100644
--- a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChainActionCard/__tests__/ChainActionCard.test.tsx
+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChainActionCard/__tests__/ChainActionCard.test.tsx
@@ -125,8 +125,11 @@ function mcpRequest(
error: null,
showManualToken: false,
authScheme: "bearer",
+ grantable: false,
+ granting: false,
onConnect: vi.fn(),
onUseToken: vi.fn(),
+ onGrant: vi.fn(),
...overrides,
};
}
@@ -401,6 +404,15 @@ describe("ChainActionCard", () => {
expect(screen.getByText("OAuth failed")).toBeDefined();
});
+ it("offers Grant access in place of Connect when an expert can be granted the account's server", () => {
+ const request = mcpRequest({ grantable: true });
+ renderCard({ mcp: [request] });
+
+ expect(screen.queryByRole("button", { name: "Connect" })).toBeNull();
+ fireEvent.click(screen.getByRole("button", { name: "Grant access" }));
+ expect(request.onGrant).toHaveBeenCalled();
+ });
+
it("submits a trimmed manual token via the Use Token button", () => {
const request = mcpRequest({ showManualToken: true });
renderCard({ mcp: [request] });
diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChainActionCard/helpers.ts b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChainActionCard/helpers.ts
index 62ac848c47..9a3205a9ac 100644
--- a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChainActionCard/helpers.ts
+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChainActionCard/helpers.ts
@@ -55,8 +55,11 @@ export interface McpConnectorRequest {
error: string | null;
showManualToken: boolean;
authScheme: "basic" | "bearer";
+ grantable: boolean;
+ granting: boolean;
onConnect: () => void;
onUseToken: (token: string) => void;
+ onGrant: () => void;
}
/** One setup card's ask, handed to the chain so every card in the chain can
diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatContainer/ChatContainer.tsx b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatContainer/ChatContainer.tsx
index a93fc6b1c2..4b5c61a0c2 100644
--- a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatContainer/ChatContainer.tsx
+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatContainer/ChatContainer.tsx
@@ -23,6 +23,7 @@ import { useIsUsageLimitReached } from "../UsageLimits/useIsUsageLimitReached";
import { TaskProgressBar } from "../TaskProgressBar/TaskProgressBar";
import { getLatestTaskList } from "../TaskProgressBar/helpers";
import { ContextPanelToggle } from "../ContextPanel/ContextPanelToggle";
+import { useShareChatExpert } from "../ContextPanel/useShareChatExpert";
import { ArchivedExpertNotice } from "./components/ArchivedExpertNotice";
import { SessionNotFound } from "./components/SessionNotFound";
import { SharedChatNotice } from "./components/SharedChatNotice";
@@ -198,6 +199,11 @@ export const ChatContainer = ({
? expertIdentity
: null;
const isExpertArchived = archivedExpertIdentity !== null;
+ const chatExpert =
+ !isResolvingExpertIdentity && expertIdentity && !expertIdentity.isArchived
+ ? { id: expertIdentity.id, name: expertIdentity.name }
+ : null;
+ useShareChatExpert(chatExpert);
const isSendLocked = isExpertArchived || !!isResolvingExpertIdentity;
// NO_OP is module-level so a locked composer keeps a stable function identity
// across renders — otherwise every consumer of `guardedOnSend` (the actions
@@ -345,11 +351,7 @@ export const ChatContainer = ({
<div className="absolute right-0 top-0 z-30">
<ContextPanelToggle
sessionId={sessionId}
- expert={
- expertIdentity && !expertIdentity.isArchived
- ? { id: expertIdentity.id, name: expertIdentity.name }
- : null
- }
+ expert={chatExpert}
/>
</div>
<NewChatOnboarding
diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatInput/__tests__/integrationMentions.test.ts b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatInput/__tests__/integrationMentions.test.ts
index 9f353653a3..327b42e667 100644
--- a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatInput/__tests__/integrationMentions.test.ts
+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatInput/__tests__/integrationMentions.test.ts
@@ -73,6 +73,21 @@ describe("connectedIntegrationsFromCredentials", () => {
).toEqual(result);
});
+ it("names an MCP credential by its service and server", () => {
+ const [sentry] = connectedIntegrationsFromCredentials([
+ credential("mcp", {
+ id: "cred-sentry",
+ type: "oauth2",
+ title: "MCP: mcp.sentry.dev",
+ service: "sentry",
+ service_name: "Sentry",
+ }),
+ ]);
+ expect(sentry.providerName).toBe("Sentry");
+ expect(sentry.name).toBe("mcp.sentry.dev");
+ expect(sentry.token).toBe("[mcp.sentry.dev](credential://mcp/cred-sentry)");
+ });
+
it("skips platform credit credentials, which are not something to address", () => {
const result = connectedIntegrationsFromCredentials([
credential("openai", { title: "Use Credits for OpenAI" }),
diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatInput/components/__tests__/MentionDropdown.test.tsx b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatInput/components/__tests__/MentionDropdown.test.tsx
index ae859c3fda..7b8c536623 100644
--- a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatInput/components/__tests__/MentionDropdown.test.tsx
+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatInput/components/__tests__/MentionDropdown.test.tsx
@@ -142,6 +142,29 @@ describe("MentionDropdown", () => {
).toBeTruthy();
});
+ it("names an MCP credential by its service and server, never as MCP", () => {
+ const [sentry] = connectedIntegrationsFromCredentials([
+ {
+ id: "cred-sentry",
+ provider: "mcp",
+ type: "oauth2",
+ title: "MCP: mcp.sentry.dev",
+ username: null,
+ scopes: null,
+ service: "sentry",
+ service_name: "Sentry",
+ },
+ ]);
+ renderDropdown({
+ options: [{ kind: "integration", integration: sentry }],
+ hasIntegrations: true,
+ });
+ const option = screen.getByRole("option");
+ expect(option.textContent).toContain("mcp.sentry.dev");
+ expect(option.textContent).toContain("Sentry");
+ expect(option.textContent).not.toMatch(/mcp:|\bMcp\b|\bMCP\b/);
+ });
+
it("drops the headings when files are not part of the picker", () => {
renderDropdown({
options: [GOOGLE_ITEM],
diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatInput/helpers.ts b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatInput/helpers.ts
index ee07fa76ec..038ee1baa7 100644
--- a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatInput/helpers.ts
+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatInput/helpers.ts
@@ -1,7 +1,10 @@
import { serializeCredentialMention } from "../CredentialMention/helpers";
import type { CredentialsMetaResponse } from "@/app/api/__generated__/models/credentialsMetaResponse";
import { filterSystemCredentials } from "@/components/contextual/CredentialsInput/helpers";
-import { formatProviderName } from "@/components/contextual/IntegrationsPanel/helpers";
+import {
+ serviceName,
+ stripProviderPrefix,
+} from "@/components/contextual/IntegrationsPanel/helpers";
// Browsers name clipboard screenshots "image.png"; rename so multiple
// pasted images stay distinguishable in the composer and workspace.
@@ -76,16 +79,19 @@ export interface MentionRange {
export function connectedIntegrationsFromCredentials<
T extends Pick<
CredentialsMetaResponse,
- "id" | "provider" | "title" | "username"
+ "id" | "provider" | "title" | "username" | "service" | "service_name"
>,
>(credentials: T[]): IntegrationMention[] {
const accounts = filterSystemCredentials(credentials)
.filter((credential) => credential.provider)
.map((credential) => {
const provider = credential.provider;
- const providerName = formatProviderName(provider);
- const name =
- credential.title?.trim() || credential.username?.trim() || providerName;
+ const providerName = serviceName(credential);
+ const title = stripProviderPrefix(
+ credential.title?.trim() ?? "",
+ provider,
+ ).trim();
+ const name = title || credential.username?.trim() || providerName;
const account = {
credentialId: credential.id,
provider,
diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ContextPanel/ContextPanelToggle.tsx b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ContextPanel/ContextPanelToggle.tsx
index d21460c871..7fcb3d464e 100644
--- a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ContextPanel/ContextPanelToggle.tsx
+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ContextPanel/ContextPanelToggle.tsx
@@ -8,7 +8,6 @@ import { Icon } from "@/components/atoms/Icon/Icon";
import { useIsMobile } from "../../useIsMobile";
import { IntegrationsToggle } from "./components/IntegrationsToggle/IntegrationsToggle";
import { useSessionFiles } from "./components/FilesTab/useSessionFiles";
-import { useEffect } from "react";
interface Props {
sessionId?: string | null;
@@ -30,11 +29,6 @@ export function ContextPanelToggle({ sessionId = null, expert = null }: Props) {
const { deliverables, documentCount: liveDocumentCount } =
useSessionFiles(sessionId);
const documentCount = Math.max(deliverables.length, liveDocumentCount);
- const expertId = expert?.id ?? null;
- const expertName = expert?.name ?? null;
- const setContextPanelExpert = useCopilotUIStore(
- (s) => s.setContextPanelExpert,
- );
const isFilesOpen = useCopilotUIStore(
(s) =>
s.artifactPanel.isOpen &&
@@ -55,12 +49,6 @@ export function ContextPanelToggle({ sessionId = null, expert = null }: Props) {
// The mobile sheet has no computer face to open.
const showComputerToggle = !!sessionId && !isMobile;
- useEffect(() => {
- setContextPanelExpert(
- expertId && expertName ? { id: expertId, name: expertName } : null,
- );
- }, [expertId, expertName, setContextPanelExpert]);
-
function handleComputerToggle() {
// Back to whatever the computer was covering: the preview, the tab, or
// nothing at all.
diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ContextPanel/__tests__/ContextPanelToggle.test.tsx b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ContextPanel/__tests__/ContextPanelToggle.test.tsx
index 261422d960..fd130b8ad9 100644
--- a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ContextPanel/__tests__/ContextPanelToggle.test.tsx
+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ContextPanel/__tests__/ContextPanelToggle.test.tsx
@@ -85,22 +85,6 @@ afterEach(() => {
});
describe("ContextPanelToggle files button", () => {
- test("shares the chat expert with the file panel", async () => {
- render(
- <ContextPanelToggle
- sessionId="s1"
- expert={{ id: "expert-maria", name: "Maria" }}
- />,
- );
-
- await vi.waitFor(() =>
- expect(useCopilotUIStore.getState().contextPanelExpert).toEqual({
- id: "expert-maria",
- name: "Maria",
- }),
- );
- });
-
test("shows the number of documents generated in the chat", async () => {
const documentId = "aaaaaaaa-0000-0000-0000-000000000001";
const uploadId = "bbbbbbbb-0000-0000-0000-000000000002";
diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ContextPanel/components/IntegrationsToggle/IntegrationsToggle.tsx b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ContextPanel/components/IntegrationsToggle/IntegrationsToggle.tsx
index 08552df284..31ffa3aa0d 100644
--- a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ContextPanel/components/IntegrationsToggle/IntegrationsToggle.tsx
+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ContextPanel/components/IntegrationsToggle/IntegrationsToggle.tsx
@@ -93,7 +93,7 @@ export function IntegrationsToggle({ expert, className }: Props) {
<TooltipTrigger asChild>
<span className="flex size-6 items-center justify-center rounded-full bg-white ring-2 ring-white smooth-shadow-ring-sm">
<IntegrationLogo
- provider={service.id}
+ provider={service.icon}
alt={service.name}
size={14}
/>
diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ContextPanel/useShareChatExpert.ts b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ContextPanel/useShareChatExpert.ts
new file mode 100644
index 0000000000..de91d93e25
--- /dev/null
+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ContextPanel/useShareChatExpert.ts
@@ -0,0 +1,17 @@
+import { useEffect } from "react";
+import { useCopilotUIStore, type ContextPanelExpert } from "../../store";
+
+export function useShareChatExpert(expert: ContextPanelExpert | null) {
+ const expertId = expert?.id ?? null;
+ const expertName = expert?.name ?? null;
+ const setContextPanelExpert = useCopilotUIStore(
+ (s) => s.setContextPanelExpert,
+ );
+
+ useEffect(() => {
+ setContextPanelExpert(
+ expertId && expertName ? { id: expertId, name: expertName } : null,
+ );
+ return () => setContextPanelExpert(null);
+ }, [expertId, expertName, setContextPanelExpert]);
+}
diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/components/CopilotModals/CopilotModals.tsx b/autogpt_platform/frontend/src/app/(platform)/copilot/components/CopilotModals/CopilotModals.tsx
index 98dcd15d9e..5cf5e72048 100644
--- a/autogpt_platform/frontend/src/app/(platform)/copilot/components/CopilotModals/CopilotModals.tsx
+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/components/CopilotModals/CopilotModals.tsx
@@ -5,12 +5,18 @@ import { IntegrationsPanel } from "@/components/contextual/IntegrationsPanel/Int
import { SchedulesPanel } from "@/components/contextual/SchedulesPanel/SchedulesPanel";
import { SkillsPanel } from "@/components/contextual/SkillsPanel/SkillsPanel";
import { Dialog } from "@/components/molecules/Dialog/Dialog";
+import { useToast } from "@/components/molecules/Toast/use-toast";
+import { grantToExpert } from "@/services/experts/grant-to-expert";
+import { useQueryClient } from "@tanstack/react-query";
import { useCopilotUIStore } from "../../store";
import { useCopilotModal } from "../../useCopilotModal";
export function CopilotModals() {
const { modal, closeModal } = useCopilotModal();
const setInitialPrompt = useCopilotUIStore((s) => s.setInitialPrompt);
+ const expert = useCopilotUIStore((s) => s.contextPanelExpert);
+ const queryClient = useQueryClient();
+ const { toast } = useToast();
function handleGuidedPrompt(prompt: string) {
closeModal();
@@ -21,6 +27,18 @@ export function CopilotModals() {
if (!open) closeModal();
}
+ async function handleConnected(credential: { id: string }) {
+ if (!expert) return;
+ const ok = await grantToExpert(queryClient, expert.id, credential.id);
+ if (!ok) {
+ toast({
+ title: `Connected, but could not give ${expert.name} access`,
+ description: "Grant it from the Integrations tab.",
+ variant: "destructive",
+ });
+ }
+ }
+
return (
<>
<Dialog
@@ -55,13 +73,20 @@ export function CopilotModals() {
title="Integrations"
>
<Dialog.Content>
- <IntegrationsPanel withHeading={false} />
+ <IntegrationsPanel
+ withHeading={false}
+ surface="dialog"
+ preferMcp
+ onConnected={expert ? handleConnected : undefined}
+ />
</Dialog.Content>
</Dialog>
<ConnectServiceDialog
+ preferMcp
open={modal === "connect"}
onOpenChange={handleOpenChange}
+ onConnected={expert ? handleConnected : undefined}
/>
</>
);
diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/components/CopilotModals/__tests__/CopilotModals.test.tsx b/autogpt_platform/frontend/src/app/(platform)/copilot/components/CopilotModals/__tests__/CopilotModals.test.tsx
index 34b889645b..7bf39b1c4f 100644
--- a/autogpt_platform/frontend/src/app/(platform)/copilot/components/CopilotModals/__tests__/CopilotModals.test.tsx
+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/components/CopilotModals/__tests__/CopilotModals.test.tsx
@@ -7,13 +7,17 @@ import {
getListCopilotFollowupSchedulesMockHandler,
} from "@/app/api/__generated__/endpoints/schedules/schedules.msw";
import { getListCopilotSkillsMockHandler } from "@/app/api/__generated__/endpoints/skills/skills.msw";
+import { ConnectServiceDialog } from "@/components/contextual/IntegrationsPanel/components/ConnectServiceDialog/ConnectServiceDialog";
import { server } from "@/mocks/mock-server";
import {
fireEvent,
render,
screen,
+ waitFor,
within,
} from "@/tests/integrations/test-utils";
+import userEvent from "@testing-library/user-event";
+import { http, HttpResponse } from "msw";
import { NuqsTestingAdapter } from "nuqs/adapters/testing";
import { afterEach, beforeEach, describe, expect, test, vi } from "vitest";
import { useCopilotUIStore } from "../../../store";
@@ -50,9 +54,96 @@ function Harness() {
);
}
+const linearBlockAndSignIn = getGetV1ListProvidersMockHandler([
+ {
+ name: "linear",
+ description: "Issues and projects",
+ supported_auth_types: ["api_key"],
+ service: "linear",
+ service_name: null,
+ service_icon: "linear",
+ },
+ {
+ name: "mcp_linear",
+ display_name: "Linear",
+ supported_auth_types: [],
+ service: "linear",
+ service_name: "Linear",
+ service_icon: "linear",
+ mcp_server: {
+ server_url: "https://mcp.linear.app/mcp",
+ documentation_url: "https://linear.app/docs",
+ setup_instructions: "Sign in to Linear.",
+ connection_mode: "hosted",
+ auth_methods: ["oauth"],
+ },
+ },
+]);
+
+async function openLinear(dialog: HTMLElement) {
+ await userEvent.click(
+ await within(dialog).findByRole("button", { name: /Linear/ }),
+ );
+}
+
+function arrangeSentryGrantForMaria() {
+ const grants = { granted: [] as string[] };
+ useCopilotUIStore.setState({
+ contextPanelExpert: { id: "expert-maria", name: "Maria" },
+ });
+ server.use(
+ getGetV1ListProvidersMockHandler([
+ {
+ name: "mcp_sentry",
+ display_name: "Sentry",
+ description: "Errors",
+ supported_auth_types: [],
+ service: "sentry",
+ service_name: "Sentry",
+ service_icon: "sentry",
+ mcp_server: {
+ server_url: "https://mcp.sentry.dev/mcp",
+ documentation_url: "https://docs.sentry.io",
+ setup_instructions: "Paste your Sentry token.",
+ connection_mode: "hosted",
+ auth_methods: ["bearer"],
+ oauth_write_scopes: [],
+ server_url_options: [],
+ allow_custom_url: false,
+ },
+ },
+ ]),
+ http.post("*/api/mcp/discover-tools", () =>
+ HttpResponse.json({
+ tools: [],
+ server_url: "https://mcp.sentry.dev/mcp",
+ }),
+ ),
+ http.post("*/api/mcp/token", () =>
+ HttpResponse.json({
+ id: "cred-sentry",
+ provider: "mcp",
+ type: "oauth2",
+ title: "MCP: mcp.sentry.dev",
+ service: "sentry",
+ }),
+ ),
+ http.post("*/api/experts/expert-maria/credentials", async ({ request }) => {
+ grants.granted = (
+ (await request.json()) as { credential_ids: string[] }
+ ).credential_ids;
+ return HttpResponse.json([]);
+ }),
+ );
+ return grants;
+}
+
describe("CopilotModals", () => {
beforeEach(() => {
- useCopilotUIStore.setState({ initialPrompt: null });
+ useCopilotUIStore.setState({
+ initialPrompt: null,
+ contextPanelExpert: null,
+ });
server.use(
getListCopilotSkillsMockHandler([]),
getListCopilotFollowupSchedulesMockHandler([]),
@@ -140,6 +231,73 @@ describe("CopilotModals", () => {
expect(screen.queryByText("No integration connected")).toBeNull();
});
+ test("the connect dialog opens a service on its sign-in, with the API key one click away", async () => {
+ server.use(linearBlockAndSignIn);
+ render(<Harness />);
+ fireEvent.click(screen.getByText("open-connect"));
+
+ const dialog = await screen.findByRole("dialog");
+ await openLinear(dialog);
+ expect(await within(dialog).findByText("Sign in to Linear.")).toBeDefined();
+ expect(within(dialog).queryByPlaceholderText("My Linear key")).toBeNull();
+
+ await userEvent.click(
+ within(dialog).getByRole("button", {
+ name: "More ways to connect",
+ }),
+ );
+ expect(
+ await within(dialog).findByPlaceholderText("My Linear key"),
+ ).toBeDefined();
+ expect(within(dialog).queryByText("Sign in to Linear.")).toBeNull();
+
+ await userEvent.click(
+ within(dialog).getByRole("button", {
+ name: "Use the Linear sign-in instead",
+ }),
+ );
+ expect(await within(dialog).findByText("Sign in to Linear.")).toBeDefined();
+ });
+
+ test("the integrations modal's connect dialog also opens on the sign-in", async () => {
+ server.use(linearBlockAndSignIn);
+ render(<Harness />);
+ fireEvent.click(screen.getByText("open-integrations"));
+
+ await userEvent.click(
+ (await screen.findAllByRole("button", { name: /Connect Service/ }))[0],
+ );
+ const dialog = await screen.findByRole("dialog", {
+ name: "Connect a service",
+ });
+ await openLinear(dialog);
+ expect(await within(dialog).findByText("Sign in to Linear.")).toBeDefined();
+ });
+
+ test("without the sign-in preference a service opens on its API key, with the sign-in one click away", async () => {
+ server.use(linearBlockAndSignIn);
+ render(<ConnectServiceDialog open onOpenChange={vi.fn()} />);
+
+ const dialog = await screen.findByRole("dialog");
+ await openLinear(dialog);
+ expect(
+ await within(dialog).findByPlaceholderText("My Linear key"),
+ ).toBeDefined();
+ expect(within(dialog).queryByText("Sign in to Linear.")).toBeNull();
+
+ await userEvent.click(
+ within(dialog).getByRole("button", {
+ name: "Use the Linear sign-in instead",
+ }),
+ );
+ expect(await within(dialog).findByText("Sign in to Linear.")).toBeDefined();
+ expect(
+ within(dialog).getByRole("button", {
+ name: "More ways to connect",
+ }),
+ ).toBeDefined();
+ });
+
test("renders the connect dialog from a ?modal=connect deep link", async () => {
render(
<NuqsTestingAdapter searchParams="?modal=connect">
@@ -175,4 +333,41 @@ describe("CopilotModals", () => {
expect(onUrlUpdate).toHaveBeenCalled();
});
});
+
+ test("connecting from an expert chat grants the new credential to that expert", async () => {
+ const grants = arrangeSentryGrantForMaria();
+
+ render(<Harness />);
+ fireEvent.click(screen.getByText("open-connect"));
+ const dialog = await screen.findByRole("dialog");
+ fireEvent.click(
+ await within(dialog).findByRole("button", { name: /Sentry/ }),
+ );
+ const input = await within(dialog).findByLabelText("API token");
+ fireEvent.change(input, { target: { value: "sntrys_token" } });
+ fireEvent.click(within(dialog).getByRole("button", { name: "Save token" }));
+
+ await waitFor(() => expect(grants.granted).toEqual(["cred-sentry"]));
+ });
+
+ test("connecting from the integrations modal in an expert chat grants the new credential to that expert", async () => {
+ const grants = arrangeSentryGrantForMaria();
+
+ render(<Harness />);
+ fireEvent.click(screen.getByText("open-integrations"));
+ await userEvent.click(
+ (await screen.findAllByRole("button", { name: /Connect Service/ }))[0],
+ );
+ const dialog = await screen.findByRole("dialog", {
+ name: "Connect a service",
+ });
+ fireEvent.click(
+ await within(dialog).findByRole("button", { name: /Sentry/ }),
+ );
+ const input = await within(dialog).findByLabelText("API token");
+ fireEvent.change(input, { target: { value: "sntrys_token" } });
+ fireEvent.click(within(dialog).getByRole("button", { name: "Save token" }));
+
+ await waitFor(() => expect(grants.granted).toEqual(["cred-sentry"]));
+ });
});
diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/components/OnboardingWelcomeDialog/ConnectProviderRow.tsx b/autogpt_platform/frontend/src/app/(platform)/copilot/components/OnboardingWelcomeDialog/ConnectProviderRow.tsx
index e58f44695c..149ba6d1fc 100644
--- a/autogpt_platform/frontend/src/app/(platform)/copilot/components/OnboardingWelcomeDialog/ConnectProviderRow.tsx
+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/components/OnboardingWelcomeDialog/ConnectProviderRow.tsx
@@ -27,7 +27,7 @@ export function ConnectProviderRow({
description,
className,
}: Props) {
- const src = `/integrations/${provider.id}.png`;
+ const src = `/integrations/${provider.iconId ?? provider.id}.png`;
const [brokenSrc, setBrokenSrc] = useState<string | null>(null);
const broken = brokenSrc === src;
diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/store.ts b/autogpt_platform/frontend/src/app/(platform)/copilot/store.ts
index 31832120b1..82c29d9aa9 100644
--- a/autogpt_platform/frontend/src/app/(platform)/copilot/store.ts
+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/store.ts
@@ -569,8 +569,6 @@ export const useCopilotUIStore = create<CopilotUIState>((set, get) => ({
}),
clearLastArtifact: () =>
set((state) => ({
- // Expert-wide panel sections belong to the previous chat's expert.
- contextPanelExpert: null,
artifactPanel: {
...state.artifactPanel,
activeTab:
diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/components/MCPSetupCard/MCPSetupCard.tsx b/autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/components/MCPSetupCard/MCPSetupCard.tsx
index b0199be062..434abbf000 100644
--- a/autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/components/MCPSetupCard/MCPSetupCard.tsx
+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/components/MCPSetupCard/MCPSetupCard.tsx
@@ -1,10 +1,12 @@
"use client";
+import { useListExpertCredentials } from "@/app/api/__generated__/endpoints/experts/experts";
import { useGetV1ListCredentials } from "@/app/api/__generated__/endpoints/integrations/integrations";
import {
postV2DiscoverAvailableToolsOnAnMcpServer,
postV2StoreABearerTokenForAnMcpServer,
} from "@/app/api/__generated__/endpoints/mcp/mcp";
+import { okData } from "@/app/api/helpers";
import type { SetupRequirementsResponse } from "@/app/api/__generated__/models/setupRequirementsResponse";
import { Button } from "@/components/atoms/Button/Button";
import { MCPAuthSchemeField } from "@/components/contextual/MCPAuthSchemeField/MCPAuthSchemeField";
@@ -25,11 +27,14 @@ import { getErrorMessage } from "@/lib/mcp-errors";
import { normalizeMcpUrl } from "@/lib/mcp-url";
import { connectMCPOAuth } from "@/lib/mcp-oauth";
import { CredentialsProvidersContext } from "@/providers/agent-credentials/credentials-provider";
+import { grantToExpert } from "@/services/experts/grant-to-expert";
+import { useQueryClient } from "@tanstack/react-query";
import { useContext, useEffect, useId, useRef, useState } from "react";
import { useCopilotChatActions } from "../../../../components/CopilotChatActionsProvider/useCopilotChatActions";
import { ContentMessage } from "../../../../components/ToolAccordion/AccordionContent";
import { ChainActionsContext } from "../../../../components/ToolChain/chainActions";
import { CredentialRejectionNotice } from "../../../../components/CredentialRejectionNotice/CredentialRejectionNotice";
+import { coerceExpertGrant } from "../../../../components/SetupRequirementsCard/helpers";
interface Props {
output: SetupRequirementsResponse;
@@ -51,6 +56,7 @@ interface Props {
*/
export function MCPSetupCard({ output, retryInstruction }: Props) {
const { onSend } = useCopilotChatActions();
+ const queryClient = useQueryClient();
const allProviders = useContext(CredentialsProvidersContext);
const chainActions = useContext(ChainActionsContext);
const actionId = useId();
@@ -62,6 +68,13 @@ export function MCPSetupCard({ output, retryInstruction }: Props) {
// agent_name is computed by the backend as the display name for the service
const service = output.setup_info.agent_name;
const rejection = output.rejection ?? null;
+ const expertGrant = Object.values(
+ output.setup_info.user_readiness?.missing_credentials ?? {},
+ )
+ .map((entry) =>
+ coerceExpertGrant((entry as { expert_grant?: unknown }).expert_grant),
+ )
+ .find(Boolean);
// Initial connection state comes from the backend. When the model
// calls `run_mcp_tool` with `surface_connect_card=true`, the response's
@@ -108,20 +121,46 @@ export function MCPSetupCard({ output, retryInstruction }: Props) {
// ``isFetchedAfterMount`` rather than ``isFetching``: this query key is
// app-wide, so ``isFetching`` also goes true on window focus and on every
// credential mutation elsewhere, blanking a genuinely connected card.
- const liveCredential = !Array.isArray(liveCredsRes)
- ? null
- : liveCredsRes.find(
+ // On an expert's card the account's own credential is not enough: only one
+ // granted to the expert counts, so an ungranted one still offers Grant
+ // access. The grant list follows the same tri-state rule as the cred list.
+ const {
+ data: expertGrants,
+ isFetchedAfterMount: expertGrantsFetched,
+ isError: expertGrantsError,
+ } = useListExpertCredentials(expertGrant?.expertId ?? "", {
+ query: {
+ enabled: Boolean(expertGrant),
+ select: (res) => okData(res) ?? [],
+ },
+ });
+ const grantedIds = expertGrant
+ ? new Set((expertGrants ?? []).map((grant) => grant.credential_id))
+ : null;
+ const serverCredentials = !Array.isArray(liveCredsRes)
+ ? []
+ : liveCredsRes.filter(
(c) =>
c.provider === "mcp" &&
typeof c.host === "string" &&
normalizeMcpUrl(c.host) === normalizedServer,
);
+ const liveCredential = serverCredentials.find(
+ (c) => !grantedIds || grantedIds.has(c.id),
+ );
+ const grantsUnknown =
+ Boolean(expertGrant) && (!expertGrantsFetched || expertGrantsError);
const liveHasCred: boolean | "unknown" =
- !liveCredsFetched || liveCredsError || !Array.isArray(liveCredsRes)
+ !liveCredsFetched ||
+ liveCredsError ||
+ !Array.isArray(liveCredsRes) ||
+ grantsUnknown
? "unknown"
: Boolean(liveCredential);
const storedManualAuthScheme: MCPAuthScheme =
- liveCredential?.mcp_auth_scheme === "basic" ? "basic" : "bearer";
+ (liveCredential ?? serverCredentials[0])?.mcp_auth_scheme === "basic"
+ ? "basic"
+ : "bearer";
const [loading, setLoading] = useState(false);
const [error, setError] = useState<string | null>(null);
@@ -146,6 +185,11 @@ export function MCPSetupCard({ output, retryInstruction }: Props) {
// on the next attempt so the user can retry.
const [forceDisconnected, setForceDisconnected] = useState(false);
const oauthRequest = useRef<AbortController | null>(null);
+ const [granting, setGranting] = useState(false);
+ const grantInFlight = useRef(false);
+ const [grantError, setGrantError] = useState<string | null>(null);
+ const [failedGrantId, setFailedGrantId] = useState<string | null>(null);
+ const grantableId = failedGrantId ?? expertGrant?.credentials[0]?.id ?? null;
// Combined view:
// 1. ``forceDisconnected`` (set by the catch block) wins.
// 2. ``localConnected`` (just completed sign-in in this component) wins.
@@ -165,12 +209,46 @@ export function MCPSetupCard({ output, retryInstruction }: Props) {
useEffect(() => () => oauthRequest.current?.abort(), []);
+ async function finish(credentialId: string | undefined) {
+ if (expertGrant && credentialId) {
+ if (grantInFlight.current) return;
+ grantInFlight.current = true;
+ setGranting(true);
+ setGrantError(null);
+ let ok = false;
+ try {
+ ok = await grantToExpert(
+ queryClient,
+ expertGrant.expertId,
+ credentialId,
+ );
+ } finally {
+ grantInFlight.current = false;
+ setGranting(false);
+ }
+ if (!ok) {
+ setFailedGrantId(credentialId);
+ setGrantError(
+ "Connected, but could not grant access. Try Grant access again.",
+ );
+ return;
+ }
+ }
+ setConnected(true);
+ onSend(retryInstruction ?? "I've connected. Please retry.");
+ }
+
+ function handleGrantExisting() {
+ if (grantableId) void finish(grantableId);
+ }
+
async function handleConnect() {
if (loading || oauthRequest.current) return;
const controller = new AbortController();
oauthRequest.current = controller;
const { signal } = controller;
setError(null);
+ setGrantError(null);
setShowManualToken(false);
setLoading(true);
try {
@@ -188,8 +266,7 @@ export function MCPSetupCard({ output, retryInstruction }: Props) {
return;
}
setForceDisconnected(false);
- setConnected(true);
- onSend(retryInstruction ?? "I've connected. Please retry.");
+ await finish(credential.id);
} catch (error: unknown) {
if (signal.aborted) return;
setConnected(false);
@@ -235,6 +312,7 @@ export function MCPSetupCard({ output, retryInstruction }: Props) {
setLoading(true);
setError(null);
+ setGrantError(null);
try {
// Probe before storing so a rejected credential never shows as Connected.
const probe = await postV2DiscoverAvailableToolsOnAnMcpServer({
@@ -272,8 +350,7 @@ export function MCPSetupCard({ output, retryInstruction }: Props) {
// Connected pill while the request is still in flight, briefly
// showing a false "Connected" state to the user.
setForceDisconnected(false);
- setConnected(true);
- onSend(retryInstruction ?? "I've connected. Please retry.");
+ await finish(res.status === 200 ? res.data.id : undefined);
} catch (e: unknown) {
// Keep the force-disconnect override on so the not-connected
// branch (error banner + manual-token input) stays visible — an
@@ -292,10 +369,12 @@ export function MCPSetupCard({ output, retryInstruction }: Props) {
const handleConnectRef = useRef(handleConnect);
const handleManualTokenRef = useRef(handleManualToken);
+ const handleGrantRef = useRef(handleGrantExisting);
useEffect(() => {
handleConnectRef.current = handleConnect;
handleManualTokenRef.current = handleManualToken;
+ handleGrantRef.current = handleGrantExisting;
});
// Inside a tool chain the card renders nothing itself — it registers an
@@ -313,14 +392,17 @@ export function MCPSetupCard({ output, retryInstruction }: Props) {
serverUrl,
connected,
loading,
- error,
+ error: error ?? grantError,
showManualToken,
authScheme: manualAuthScheme,
+ grantable: Boolean(grantableId),
+ granting,
onConnect: () => void handleConnectRef.current(),
onUseToken: (token) => {
setManualToken(token);
void handleManualTokenRef.current(token);
},
+ onGrant: () => handleGrantRef.current(),
},
});
return () => chainActions.unregister(actionId);
@@ -330,6 +412,9 @@ export function MCPSetupCard({ output, retryInstruction }: Props) {
connected,
loading,
error,
+ grantError,
+ grantableId,
+ granting,
showManualToken,
manualAuthScheme,
serverUrl,
@@ -372,22 +457,33 @@ export function MCPSetupCard({ output, retryInstruction }: Props) {
{rejection && <CredentialRejectionNotice rejection={rejection} />}
<div className="rounded-2xl border bg-background p-4">
+ {grantableId ? (
+ <Button
+ variant="primary"
+ size="small"
+ onClick={handleGrantExisting}
+ disabled={granting || loading}
+ className="mr-2"
+ >
+ {granting ? "Granting…" : "Grant access"}
+ </Button>
+ ) : null}
<Button
- variant="primary"
+ variant={grantableId ? "secondary" : "primary"}
size="small"
onClick={handleConnect}
- disabled={loading}
+ disabled={loading || granting}
>
{loading ? "Connecting…" : `Connect ${service}`}
</Button>
- {error && (
+ {(error || grantError) && (
<div
role="alert"
aria-live="polite"
className="mt-2 rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-700"
>
- {error}
+ {error ?? grantError}
</div>
)}
diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/components/MCPSetupCard/__tests__/MCPSetupCard.test.tsx b/autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/components/MCPSetupCard/__tests__/MCPSetupCard.test.tsx
index d81dff9431..79efaf8ea4 100644
--- a/autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/components/MCPSetupCard/__tests__/MCPSetupCard.test.tsx
+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/components/MCPSetupCard/__tests__/MCPSetupCard.test.tsx
@@ -44,12 +44,33 @@ vi.mock("@/app/api/__generated__/endpoints/mcp/mcp", () => ({
postV2StoreABearerTokenForAnMcpServer: vi.fn(),
}));
+const mockGrant = vi.fn();
+let mockExpertGrants: { credential_id: string }[] = [];
+vi.mock("@/app/api/__generated__/endpoints/experts/experts", () => ({
+ grantExpertCredentials: (...args: unknown[]) => mockGrant(...args),
+ useListExpertCredentials: () => ({
+ data: mockExpertGrants,
+ isFetchedAfterMount: true,
+ isError: false,
+ }),
+ getListExpertCredentialsQueryKey: (id: string) => [
+ "experts",
+ id,
+ "credentials",
+ ],
+ getGetExpertQueryKey: (id: string) => ["experts", id],
+ getListExpertSetupItemsQueryKey: () => ["experts", "setup"],
+ getListExpertsQueryKey: () => ["experts"],
+ getListExpertIdentitiesQueryKey: () => ["experts", "identities"],
+}));
+
// Mock the credentials list hook used for the on-mount live-cred re-sync.
// Default: no stored creds → ``liveHasCred=false`` matches the persisted
// ``has_all_credentials=false`` snapshot so the existing tests don't have
// to thread a connected state through MSW. ``setMockLiveCreds`` lets
// individual tests override the live state to verify the refresh path.
let mockLiveCreds: Array<{
+ id?: string;
provider: string;
host?: string | null;
mcp_auth_scheme?: "basic" | "bearer" | null;
@@ -60,6 +81,7 @@ let mockLiveCredsFetched = true;
let mockLiveCredsError = false;
function setMockLiveCreds(
next: Array<{
+ id?: string;
provider: string;
host?: string | null;
mcp_auth_scheme?: "basic" | "bearer" | null;
@@ -131,6 +153,7 @@ describe("MCPSetupCard", () => {
// `not.toHaveBeenCalled()` assertion silently depends on declaration order.
vi.clearAllMocks();
setMockLiveCreds([]);
+ mockExpertGrants = [];
currentOnSend = mockOnSend;
});
@@ -1131,4 +1154,287 @@ describe("MCPSetupCard", () => {
});
});
});
+
+ function makeExpertOutput(credentials: { id: string; title: string }[]) {
+ const output = makeSetupOutput();
+ output.setup_info.user_readiness.missing_credentials = {
+ credentials: {
+ id: "credentials",
+ provider: "mcp",
+ type: "oauth2",
+ title: "MCP",
+ expert_grant: { expert_id: "expert-maria", credentials },
+ },
+ } as never;
+ return output;
+ }
+
+ it("offers Grant access when the account already has the server and grants on click", async () => {
+ mockGrant.mockResolvedValue({
+ status: 200,
+ data: [
+ {
+ credential_id: "cred-existing",
+ provider: "mcp",
+ title: "x",
+ type: "oauth2",
+ service: "sentry",
+ },
+ ],
+ headers: new Headers(),
+ });
+ render(
+ <MCPSetupCard
+ output={makeExpertOutput([{ id: "cred-existing", title: "Sentry" }])}
+ />,
+ );
+
+ fireEvent.click(
+ await screen.findByRole("button", { name: /Grant access/ }),
+ );
+
+ await waitFor(() =>
+ expect(mockGrant).toHaveBeenCalledWith("expert-maria", {
+ credential_ids: ["cred-existing"],
+ }),
+ );
+ await waitFor(() => expect(mockOnSend).toHaveBeenCalled());
+ });
+
+ it("offers Grant access even though the account's own credential list has the server", async () => {
+ setMockLiveCreds([
+ {
+ id: "cred-existing",
+ provider: "mcp",
+ host: "https://mcp.example.com/mcp",
+ },
+ ]);
+ render(
+ <MCPSetupCard
+ output={makeExpertOutput([{ id: "cred-existing", title: "Sentry" }])}
+ />,
+ );
+
+ expect(
+ await screen.findByRole("button", { name: /Grant access/ }),
+ ).toBeDefined();
+ expect(screen.queryByText(/connected to example\.com/i)).toBeNull();
+ });
+
+ it("shows Connected once the expert has been granted the account's credential for the server", () => {
+ setMockLiveCreds([
+ {
+ id: "cred-existing",
+ provider: "mcp",
+ host: "https://mcp.example.com/mcp",
+ },
+ ]);
+ mockExpertGrants = [{ credential_id: "cred-existing" }];
+ render(
+ <MCPSetupCard
+ output={makeExpertOutput([{ id: "cred-existing", title: "Sentry" }])}
+ />,
+ );
+
+ expect(screen.getByText(/connected to example\.com/i)).toBeDefined();
+ expect(screen.queryByRole("button", { name: /Grant access/ })).toBeNull();
+ });
+
+ it("grants the credential an OAuth sign-in returns and retries only after the grant lands", async () => {
+ const { postV2InitiateOauthLoginForAnMcpServer } = await import(
+ "@/app/api/__generated__/endpoints/mcp/mcp"
+ );
+ vi.mocked(postV2InitiateOauthLoginForAnMcpServer).mockResolvedValueOnce({
+ status: 200,
+ data: {
+ login_url: "https://auth.example.com/authorize",
+ state_token: "st",
+ },
+ headers: new Headers(),
+ } as never);
+ const { openOAuthPopup } = await import("@/lib/oauth-popup");
+ vi.mocked(openOAuthPopup).mockReturnValueOnce({
+ promise: Promise.resolve({ code: "auth-code", state: "st" }),
+ cleanup: { abort: vi.fn(), signal: new AbortController().signal },
+ popupBlocked: false,
+ fallbackBlocked: false,
+ });
+ const mcpOAuthCallback = vi.fn().mockResolvedValue({
+ id: "cred-oauth",
+ provider: "mcp",
+ type: "oauth2",
+ });
+ const providers = {
+ mcp: { mcpOAuthCallback },
+ } as unknown as CredentialsProvidersContextType;
+ let resolveGrant: (value: unknown) => void = () => {};
+ mockGrant.mockReturnValueOnce(
+ new Promise((resolve) => {
+ resolveGrant = resolve;
+ }),
+ );
+
+ render(
+ <CredentialsProvidersContext.Provider value={providers}>
+ <MCPSetupCard output={makeExpertOutput([])} />
+ </CredentialsProvidersContext.Provider>,
+ );
+ fireEvent.click(
+ screen.getByRole("button", { name: /connect example\.com/i }),
+ );
+
+ await waitFor(() =>
+ expect(mockGrant).toHaveBeenCalledWith("expert-maria", {
+ credential_ids: ["cred-oauth"],
+ }),
+ );
+ expect(mockOnSend).not.toHaveBeenCalled();
+
+ await act(async () => {
+ resolveGrant({ status: 200, data: [], headers: new Headers() });
+ });
+
+ await waitFor(() => expect(mockOnSend).toHaveBeenCalledTimes(1));
+ });
+
+ it("grants only once when Grant access is clicked twice", async () => {
+ mockGrant.mockResolvedValue({
+ status: 200,
+ data: [],
+ headers: new Headers(),
+ });
+ render(
+ <MCPSetupCard
+ output={makeExpertOutput([{ id: "cred-existing", title: "Sentry" }])}
+ />,
+ );
+
+ const grant = await screen.findByRole("button", { name: /Grant access/ });
+ fireEvent.click(grant);
+ fireEvent.click(grant);
+
+ await waitFor(() => expect(mockOnSend).toHaveBeenCalled());
+ expect(mockGrant).toHaveBeenCalledTimes(1);
+ expect(mockOnSend).toHaveBeenCalledTimes(1);
+ });
+
+ it("offers to retry granting a freshly connected credential when the grant fails", async () => {
+ const {
+ postV2InitiateOauthLoginForAnMcpServer,
+ postV2StoreABearerTokenForAnMcpServer,
+ } = await import("@/app/api/__generated__/endpoints/mcp/mcp");
+ vi.mocked(postV2InitiateOauthLoginForAnMcpServer).mockResolvedValueOnce({
+ status: 400,
+ data: { detail: { code: "no_oauth", message: "No OAuth" } },
+ headers: new Headers(),
+ } as never);
+ vi.mocked(postV2StoreABearerTokenForAnMcpServer).mockResolvedValueOnce({
+ status: 200,
+ data: {
+ id: "cred-new",
+ provider: "mcp",
+ type: "oauth2",
+ title: "t",
+ scopes: [],
+ },
+ headers: new Headers(),
+ } as never);
+ mockGrant
+ .mockRejectedValueOnce(new Error("boom"))
+ .mockResolvedValueOnce({ status: 200, data: [], headers: new Headers() });
+
+ render(<MCPSetupCard output={makeExpertOutput([])} />);
+ fireEvent.click(
+ screen.getByRole("button", { name: /connect example\.com/i }),
+ );
+ await waitFor(() => {
+ expect(screen.getByPlaceholderText(manualTokenPlaceholder)).toBeDefined();
+ });
+ fireEvent.change(screen.getByPlaceholderText(manualTokenPlaceholder), {
+ target: { value: "my-secret-token" },
+ });
+ fireEvent.click(screen.getByRole("button", { name: /use token/i }));
+
+ expect(await screen.findByText(/could not grant/i)).toBeDefined();
+ expect(mockOnSend).not.toHaveBeenCalled();
+
+ fireEvent.click(screen.getByRole("button", { name: /Grant access/ }));
+
+ await waitFor(() => expect(mockOnSend).toHaveBeenCalled());
+ expect(mockGrant).toHaveBeenLastCalledWith("expert-maria", {
+ credential_ids: ["cred-new"],
+ });
+ });
+
+ it("grants a freshly connected credential to the expert", async () => {
+ const {
+ postV2InitiateOauthLoginForAnMcpServer,
+ postV2DiscoverAvailableToolsOnAnMcpServer,
+ postV2StoreABearerTokenForAnMcpServer,
+ } = await import("@/app/api/__generated__/endpoints/mcp/mcp");
+ vi.mocked(postV2InitiateOauthLoginForAnMcpServer).mockResolvedValueOnce({
+ status: 400,
+ data: { detail: { code: "no_oauth", message: "No OAuth" } },
+ headers: new Headers(),
+ } as never);
+ vi.mocked(postV2DiscoverAvailableToolsOnAnMcpServer).mockResolvedValueOnce({
+ status: 200,
+ data: { tools: [], server_url: "https://mcp.example.com/mcp" },
+ headers: new Headers(),
+ } as never);
+ vi.mocked(postV2StoreABearerTokenForAnMcpServer).mockResolvedValueOnce({
+ status: 200,
+ data: {
+ id: "cred-new",
+ provider: "mcp",
+ type: "oauth2",
+ title: "t",
+ scopes: [],
+ },
+ headers: new Headers(),
+ } as never);
+ mockGrant.mockResolvedValue({
+ status: 200,
+ data: [],
+ headers: new Headers(),
+ });
+
+ render(<MCPSetupCard output={makeExpertOutput([])} />);
+ fireEvent.click(
+ screen.getByRole("button", { name: /connect example\.com/i }),
+ );
+ await waitFor(() => {
+ expect(screen.getByPlaceholderText(manualTokenPlaceholder)).toBeDefined();
+ });
+ fireEvent.change(screen.getByPlaceholderText(manualTokenPlaceholder), {
+ target: { value: "my-secret-token" },
+ });
+ fireEvent.click(screen.getByRole("button", { name: /use token/i }));
+
+ await waitFor(() =>
+ expect(mockGrant).toHaveBeenCalledWith("expert-maria", {
+ credential_ids: ["cred-new"],
+ }),
+ );
+ await waitFor(() => expect(mockOnSend).toHaveBeenCalled());
+ });
+
+ it("keeps the connection and shows the failure when the grant fails", async () => {
+ mockGrant.mockRejectedValue(new Error("boom"));
+ render(
+ <MCPSetupCard
+ output={makeExpertOutput([{ id: "cred-existing", title: "Sentry" }])}
+ />,
+ );
+
+ fireEvent.click(
+ await screen.findByRole("button", { name: /Grant access/ }),
+ );
+
+ expect((await screen.findByRole("alert")).textContent).toMatch(
+ /could not grant/i,
+ );
+ expect(screen.getByRole("button", { name: /Grant access/ })).toBeDefined();
+ expect(mockOnSend).not.toHaveBeenCalled();
+ });
});
diff --git a/autogpt_platform/frontend/src/app/(platform)/marketplace/skills/[slug]/components/SkillPage.tsx b/autogpt_platform/frontend/src/app/(platform)/marketplace/skills/[slug]/components/SkillPage.tsx
index 5934fdc9ec..f5670759c3 100644
--- a/autogpt_platform/frontend/src/app/(platform)/marketplace/skills/[slug]/components/SkillPage.tsx
+++ b/autogpt_platform/frontend/src/app/(platform)/marketplace/skills/[slug]/components/SkillPage.tsx
@@ -268,6 +268,7 @@ export function SkillPage({ slug }: Props) {
/>
<ConnectServiceDialog
+ preferMcp
open={isConnectOpen}
onOpenChange={setIsConnectOpen}
title={`Connect ${formatProviderList(providers)}`}
diff --git a/autogpt_platform/frontend/src/app/(platform)/settings/integrations/__tests__/main.test.tsx b/autogpt_platform/frontend/src/app/(platform)/settings/integrations/__tests__/main.test.tsx
index 8780b5c91d..d3606159d1 100644
--- a/autogpt_platform/frontend/src/app/(platform)/settings/integrations/__tests__/main.test.tsx
+++ b/autogpt_platform/frontend/src/app/(platform)/settings/integrations/__tests__/main.test.tsx
@@ -109,6 +109,57 @@ describe("SettingsIntegrationsPage — list", () => {
expect(screen.getByText("OpenAI")).toBeDefined();
});
+ test("marks a vendor sign-in as for chats and says it does not connect that vendor's blocks", async () => {
+ server.use(
+ getGetV1ListCredentialsMockHandler([
+ makeCred({
+ id: "key",
+ provider: "linear",
+ title: "Linear key",
+ service: "linear",
+ service_icon: "linear",
+ }),
+ makeCred({
+ id: "linear-sign-in",
+ provider: "mcp",
+ type: "oauth2",
+ title: "MCP: mcp.linear.app",
+ service: "linear",
+ service_name: "Linear",
+ service_icon: "linear",
+ }),
+ makeCred({
+ id: "sentry-sign-in",
+ provider: "mcp",
+ type: "oauth2",
+ title: "MCP: mcp.sentry.dev",
+ service: "sentry",
+ service_name: "Sentry",
+ service_icon: "sentry",
+ }),
+ ]),
+ getGetV1ListProvidersMockHandler([
+ makeProvider({
+ name: "linear",
+ supported_auth_types: ["api_key"],
+ service: "linear",
+ }),
+ ]),
+ );
+
+ render(<SettingsIntegrationsPage />);
+
+ expect(
+ await screen.findByText(
+ "Linear blocks in agents need their own connection.",
+ ),
+ ).toBeDefined();
+ expect(screen.getAllByText("For chats")).toHaveLength(2);
+ expect(screen.getByText("API Key")).toBeDefined();
+ // Sentry ships no blocks, so its sign-in has nothing to warn about.
+ expect(screen.queryByText(/Sentry blocks/)).toBeNull();
+ });
+
test("renders an error card on 401 instead of the empty state", async () => {
server.use(getGetV1ListCredentialsMockHandler401());
diff --git a/autogpt_platform/frontend/src/app/(platform)/settings/integrations/__tests__/mcp-auth-fixtures.ts b/autogpt_platform/frontend/src/app/(platform)/settings/integrations/__tests__/mcp-auth-fixtures.ts
index 9b96382b10..fcad7e3eed 100644
--- a/autogpt_platform/frontend/src/app/(platform)/settings/integrations/__tests__/mcp-auth-fixtures.ts
+++ b/autogpt_platform/frontend/src/app/(platform)/settings/integrations/__tests__/mcp-auth-fixtures.ts
@@ -18,7 +18,10 @@ function preset(
name: `mcp_${slug}`,
display_name: name,
description: `${name} account and data tools`,
- supported_auth_types: ["oauth2"],
+ supported_auth_types: [],
+ service: slug,
+ service_name: name,
+ service_icon: metadata.icon_id ?? null,
mcp_server: {
server_url: `https://mcp.${slug}.example.com/mcp`,
documentation_url: `https://docs.example.com/${slug}`,
diff --git a/autogpt_platform/frontend/src/app/(platform)/settings/integrations/__tests__/mcp-auth-options.test.tsx b/autogpt_platform/frontend/src/app/(platform)/settings/integrations/__tests__/mcp-auth-options.test.tsx
index acd6f1b788..888136a09c 100644
--- a/autogpt_platform/frontend/src/app/(platform)/settings/integrations/__tests__/mcp-auth-options.test.tsx
+++ b/autogpt_platform/frontend/src/app/(platform)/settings/integrations/__tests__/mcp-auth-options.test.tsx
@@ -158,7 +158,7 @@ describe("MCP preset access options", () => {
test("Customer.io defaults to read access and adds only documented draft writes when selected", async () => {
const dialog = await openPreset("Customer.io");
- const changes = within(dialog).getByRole("checkbox", {
+ const changes = within(dialog).getByRole("switch", {
name: /allow changes/i,
});
expect(changes.getAttribute("aria-checked")).toBe("false");
diff --git a/autogpt_platform/frontend/src/app/(platform)/settings/integrations/__tests__/mcp-catalog.test.tsx b/autogpt_platform/frontend/src/app/(platform)/settings/integrations/__tests__/mcp-catalog.test.tsx
index 6f17ee5de3..1e3775264b 100644
--- a/autogpt_platform/frontend/src/app/(platform)/settings/integrations/__tests__/mcp-catalog.test.tsx
+++ b/autogpt_platform/frontend/src/app/(platform)/settings/integrations/__tests__/mcp-catalog.test.tsx
@@ -40,6 +40,23 @@ beforeEach(() => {
);
});
+function shippedCatalogProvider(name: string): ProviderMetadata {
+ const catalog: ProviderMetadata[] = JSON.parse(
+ readFileSync(
+ resolve("../backend/backend/integrations/mcp_catalog.json"),
+ "utf8",
+ ),
+ );
+ const entry = catalog.find((item) => item.name === name);
+ expect(entry).toBeDefined();
+ return {
+ ...entry!,
+ service: entry!.mcp_server?.provider ?? name.replace(/^mcp_/, ""),
+ service_name: entry!.display_name,
+ service_icon: entry!.mcp_server?.icon_id ?? null,
+ };
+}
+
async function openPicker() {
const buttons = await screen.findAllByRole("button", {
name: /connect.*service/i,
@@ -50,18 +67,12 @@ async function openPicker() {
describe("SettingsIntegrationsPage — MCP catalogue", () => {
test("shows PostHog branding and connection options from the shipped catalog", async () => {
- const catalog: ProviderMetadata[] = JSON.parse(
- readFileSync(
- resolve("../backend/backend/integrations/mcp_catalog.json"),
- "utf8",
- ),
+ server.use(
+ getGetV1ListProvidersMockHandler([shippedCatalogProvider("mcp_posthog")]),
);
- const posthog = catalog.find((entry) => entry.name === "mcp_posthog");
- expect(posthog).toBeDefined();
- server.use(getGetV1ListProvidersMockHandler([posthog!]));
render(<SettingsIntegrationsPage />);
- const row = await screen.findByRole("button", { name: /posthog.*mcp/i });
+ const row = await screen.findByRole("button", { name: /posthog/i });
expect(row.querySelector("img")?.getAttribute("src")).toBe(
"/integrations/posthog.png",
);
@@ -82,18 +93,12 @@ describe("SettingsIntegrationsPage — MCP catalogue", () => {
});
test("opens OpenSEO on its cloud server and lets self-hosters change the URL", async () => {
- const catalog: ProviderMetadata[] = JSON.parse(
- readFileSync(
- resolve("../backend/backend/integrations/mcp_catalog.json"),
- "utf8",
- ),
+ server.use(
+ getGetV1ListProvidersMockHandler([shippedCatalogProvider("mcp_openseo")]),
);
- const openseo = catalog.find((entry) => entry.name === "mcp_openseo");
- expect(openseo).toBeDefined();
- server.use(getGetV1ListProvidersMockHandler([openseo!]));
render(<SettingsIntegrationsPage />);
- const row = await screen.findByRole("button", { name: /openseo.*mcp/i });
+ const row = await screen.findByRole("button", { name: /openseo/i });
expect(within(row).queryByText("Setup required")).toBeNull();
fireEvent.click(row);
@@ -122,7 +127,7 @@ describe("SettingsIntegrationsPage — MCP catalogue", () => {
const preset = await screen.findByRole("button", {
name: /agentmail.*account/i,
});
- expect(within(preset).getByText("MCP", { exact: true })).toBeDefined();
+ expect(within(preset).queryByText("MCP", { exact: true })).toBeNull();
expect(preset.querySelector("img")?.getAttribute("src")).toBe(
"/integrations/agent_mail.png",
);
@@ -229,9 +234,8 @@ describe("SettingsIntegrationsPage — MCP catalogue", () => {
: "Connected, but this server returned no tools.",
);
expect(
- within(dialog).getByText(/no connection was saved/i),
+ within(dialog).getByText(/needs no sign-in, so nothing was saved/i),
).toBeDefined();
- expect(within(dialog).getByText(/use this server url/i)).toBeDefined();
expect(discoveryRequest).toHaveBeenCalledWith({
server_url: "https://search.parallel.ai/mcp",
use_saved_credentials: false,
diff --git a/autogpt_platform/frontend/src/app/(platform)/team/[expertId]/__tests__/integrations.test.tsx b/autogpt_platform/frontend/src/app/(platform)/team/[expertId]/__tests__/integrations.test.tsx
index 1e35d994dc..62b74afad5 100644
--- a/autogpt_platform/frontend/src/app/(platform)/team/[expertId]/__tests__/integrations.test.tsx
+++ b/autogpt_platform/frontend/src/app/(platform)/team/[expertId]/__tests__/integrations.test.tsx
@@ -106,6 +106,9 @@ const linkedin: ExpertCredentialRef = {
provider: "linkedin",
title: "Work LinkedIn",
type: "oauth2",
+ service: "linkedin",
+ service_name: null,
+ service_icon: "linkedin",
};
beforeEach(() => {
@@ -474,24 +477,45 @@ describe("managing an expert's integrations", () => {
expect(within(list).queryByRole("button", { name: /Slack/ })).toBeNull();
});
- it("excludes MCP presets from the native-method picker", async () => {
+ it("offers a vendor once and opens its sign-in first, with an API key alternative", async () => {
server.use(
getListExpertCredentialsMockHandler([]),
http.get("*/api/integrations/providers", () =>
HttpResponse.json([
{
- name: "notion",
- description: "Docs and databases",
+ name: "linear",
+ description: "Issues and projects",
supported_auth_types: ["api_key"],
+ service: "linear",
+ service_name: null,
+ service_icon: "linear",
+ },
+ {
+ name: "mcp_linear",
+ display_name: "Linear",
+ supported_auth_types: [],
+ service: "linear",
+ service_name: "Linear",
+ service_icon: "linear",
+ mcp_server: {
+ server_url: "https://mcp.linear.app/mcp",
+ documentation_url: "https://linear.app/docs",
+ setup_instructions: "Sign in to Linear.",
+ connection_mode: "hosted",
+ auth_methods: ["oauth"],
+ },
},
{
- name: "mcp_airtable",
- display_name: "Airtable",
+ name: "mcp_sentry",
+ display_name: "Sentry",
supported_auth_types: [],
+ service: "sentry",
+ service_name: "Sentry",
+ service_icon: "sentry",
mcp_server: {
- server_url: "https://mcp.airtable.com/mcp",
- documentation_url: "https://support.airtable.com",
- setup_instructions: "Sign in to Airtable.",
+ server_url: "https://mcp.sentry.dev/mcp",
+ documentation_url: "https://docs.sentry.io",
+ setup_instructions: "Sign in to Sentry.",
connection_mode: "hosted",
auth_methods: ["oauth"],
},
@@ -508,11 +532,112 @@ describe("managing an expert's integrations", () => {
const dialog = await screen.findByRole("dialog");
const list = await within(dialog).findByRole("list", { name: "Services" });
- expect(within(list).queryByRole("button", { name: /Airtable/ })).toBeNull();
- await userEvent.click(within(list).getByRole("button", { name: /Notion/ }));
+ expect(
+ within(list).getAllByRole("button", { name: /Linear/ }),
+ ).toHaveLength(1);
+ expect(within(list).getByRole("button", { name: /Sentry/ })).toBeDefined();
+ expect(within(dialog).queryByText("MCP")).toBeNull();
+
+ await userEvent.click(within(list).getByRole("button", { name: /Linear/ }));
+ expect(await within(dialog).findByText("Sign in to Linear.")).toBeDefined();
+ expect(
+ within(dialog).getByRole("button", { name: "More ways to connect" }),
+ ).toBeDefined();
+
+ await userEvent.click(
+ within(dialog).getByRole("button", { name: "More ways to connect" }),
+ );
expect(
await within(dialog).findByRole("button", { name: /API Key/ }),
).toBeDefined();
+ expect(
+ within(dialog).getByRole("button", {
+ name: "Use the Linear sign-in instead",
+ }),
+ ).toBeDefined();
+ });
+
+ it("grants a credential connected through the service sign-in", async () => {
+ let granted: string[] = [];
+ server.use(
+ getListExpertCredentialsMockHandler([]),
+ http.get("*/api/integrations/providers", () =>
+ HttpResponse.json([
+ {
+ name: "mcp_sentry",
+ display_name: "Sentry",
+ supported_auth_types: [],
+ service: "sentry",
+ service_name: "Sentry",
+ service_icon: "sentry",
+ mcp_server: {
+ server_url: "https://mcp.sentry.dev/mcp",
+ documentation_url: "https://docs.sentry.io",
+ setup_instructions: "Paste your Sentry token.",
+ connection_mode: "hosted",
+ auth_methods: ["bearer"],
+ },
+ },
+ ]),
+ ),
+ http.post("*/api/mcp/discover-tools", () =>
+ HttpResponse.json({
+ tools: [],
+ server_url: "https://mcp.sentry.dev/mcp",
+ }),
+ ),
+ http.post("*/api/mcp/token", () =>
+ HttpResponse.json({
+ id: "cred-sentry",
+ provider: "mcp",
+ type: "oauth2",
+ title: "MCP: mcp.sentry.dev",
+ host: "https://mcp.sentry.dev/mcp",
+ service: "sentry",
+ service_name: "Sentry",
+ service_icon: "sentry",
+ }),
+ ),
+ http.post(
+ "*/api/experts/expert-maria/credentials",
+ async ({ request }) => {
+ const body = (await request.json()) as { credential_ids: string[] };
+ granted = body.credential_ids;
+ return HttpResponse.json([
+ {
+ credential_id: "cred-sentry",
+ provider: "mcp",
+ title: "MCP: mcp.sentry.dev",
+ type: "oauth2",
+ service: "sentry",
+ service_name: "Sentry",
+ service_icon: "sentry",
+ },
+ ]);
+ },
+ ),
+ );
+
+ render(<ExpertDetailPage />);
+ await openIntegrationsTab();
+ await userEvent.click(
+ await screen.findByRole("button", { name: /Add integration/ }),
+ );
+ const dialog = await screen.findByRole("dialog");
+ await userEvent.click(
+ within(
+ await within(dialog).findByRole("list", { name: "Services" }),
+ ).getByRole("button", { name: /Sentry/ }),
+ );
+ await userEvent.type(
+ await within(dialog).findByLabelText("API token"),
+ "sntrys_token_value",
+ );
+ await userEvent.click(
+ within(dialog).getByRole("button", { name: "Save token" }),
+ );
+
+ await waitFor(() => expect(granted).toEqual(["cred-sentry"]));
});
it("grants only the credential the dialog created", async () => {
@@ -739,25 +864,115 @@ describe("managing an expert's integrations", () => {
expect(grantAttempts).toBe(0);
});
- it("names an MCP credential after the service behind it", async () => {
+ it("files an MCP credential under its service, with no MCP wording", async () => {
server.use(
getListExpertCredentialsMockHandler([
{
credential_id: "cred-mcp",
provider: "mcp",
title: "MCP: mcp.sentry.dev",
- type: "host_scoped",
+ type: "oauth2",
+ service: "sentry",
+ service_name: "Sentry",
+ service_icon: "sentry",
},
]),
);
render(<ExpertDetailPage />);
-
await openIntegrationsTab();
const section = await screen.findByTestId("expert-integrations-section");
expect(await within(section).findByText("Sentry")).toBeDefined();
- expect(within(section).getByText("MCP server")).toBeDefined();
+ expect(within(section).queryByText(/MCP/)).toBeNull();
expect(within(section).getByText("Ready")).toBeDefined();
+ expect(
+ within(section)
+ .getByRole("img", { name: "Sentry logo" })
+ .getAttribute("src"),
+ ).toContain("sentry.png");
+ });
+
+ it("files a self-hosted MCP credential under its hostname", async () => {
+ server.use(
+ getListExpertCredentialsMockHandler([
+ {
+ credential_id: "cred-mcp-custom",
+ provider: "mcp",
+ title: "MCP: mcp.internal.example",
+ type: "oauth2",
+ service: "mcp:mcp.internal.example",
+ service_name: "mcp.internal.example",
+ service_icon: null,
+ },
+ ]),
+ );
+
+ render(<ExpertDetailPage />);
+ await openIntegrationsTab();
+
+ const section = await screen.findByTestId("expert-integrations-section");
+ expect(
+ await within(section).findAllByText("mcp.internal.example"),
+ ).toHaveLength(2);
+ expect(
+ within(section).getByRole("img", { name: "mcp.internal.example logo" }),
+ ).toBeDefined();
+ expect(within(section).queryByText(/MCP server/)).toBeNull();
+ });
+
+ it("groups an MCP credential and an API key for the same vendor together", async () => {
+ server.use(
+ getListExpertCredentialsMockHandler([
+ {
+ credential_id: "cred-linear-key",
+ provider: "linear",
+ title: "Linear key",
+ type: "api_key",
+ service: "linear",
+ service_name: null,
+ service_icon: "linear",
+ },
+ {
+ credential_id: "cred-linear-mcp",
+ provider: "mcp",
+ title: "MCP: mcp.linear.app",
+ type: "oauth2",
+ service: "linear",
+ service_name: "Linear",
+ service_icon: "linear",
+ },
+ {
+ credential_id: "cred-posthog-key",
+ provider: "posthog",
+ title: "PostHog key",
+ type: "api_key",
+ service: "posthog",
+ service_name: null,
+ service_icon: null,
+ },
+ {
+ credential_id: "cred-posthog-mcp",
+ provider: "mcp",
+ title: "MCP: mcp.posthog.com",
+ type: "oauth2",
+ service: "posthog",
+ service_name: "PostHog",
+ service_icon: "posthog",
+ },
+ ]),
+ );
+
+ render(<ExpertDetailPage />);
+ await openIntegrationsTab();
+
+ const section = await screen.findByTestId("expert-integrations-section");
+ const rows = await within(section).findAllByTestId(
+ "expert-integration-row",
+ );
+ expect(rows).toHaveLength(4);
+ expect(within(section).getAllByText("Linear")).toHaveLength(1);
+ expect(within(section).getAllByText("PostHog")).toHaveLength(1);
+ expect(within(section).queryByText("Posthog")).toBeNull();
});
});
diff --git a/autogpt_platform/frontend/src/app/(platform)/team/[expertId]/components/ExpertIntegrationsSection/ExpertConnectServiceDialog.tsx b/autogpt_platform/frontend/src/app/(platform)/team/[expertId]/components/ExpertIntegrationsSection/ExpertConnectServiceDialog.tsx
index af4bf72acc..6ac513fa76 100644
--- a/autogpt_platform/frontend/src/app/(platform)/team/[expertId]/components/ExpertIntegrationsSection/ExpertConnectServiceDialog.tsx
+++ b/autogpt_platform/frontend/src/app/(platform)/team/[expertId]/components/ExpertIntegrationsSection/ExpertConnectServiceDialog.tsx
@@ -66,9 +66,12 @@ export function ExpertConnectServiceDialog({
refetch,
selectedProvider,
direction,
- connectedProviders,
+ connectedServices,
selectedMethod,
setSelectedMethod,
+ showNative,
+ setShowNative,
+ isMcpStep,
apiKeyForm,
handleApiKeySubmit,
showContinue,
@@ -88,7 +91,7 @@ export function ExpertConnectServiceDialog({
return (
<Dialog
variant="compact"
- styling={{ maxWidth: "40rem", maxHeight: "60vh" }}
+ styling={{ maxWidth: "40rem", maxHeight: "85vh" }}
controlled={{
isOpen: open,
set: (next) => {
@@ -99,11 +102,11 @@ export function ExpertConnectServiceDialog({
<Dialog.Content>
<div className="flex flex-col gap-4">
<motion.div
- className="relative overflow-hidden"
+ className="relative -m-1 overflow-hidden"
animate={{ height: contentHeight ?? "auto" }}
transition={reduceMotion ? { duration: 0 } : HEIGHT_TRANSITION}
>
- <div ref={contentRef}>
+ <div ref={contentRef} className="p-1">
<AnimatePresence mode="wait" initial={false} custom={direction}>
{selectedProvider ? (
<motion.div
@@ -122,6 +125,11 @@ export function ExpertConnectServiceDialog({
apiKeyForm={apiKeyForm}
onApiKeySubmit={handleApiKeySubmit}
onInlineConnectSuccess={handleSuccess}
+ mcpSignIn={{
+ showNative,
+ onShowNativeChange: setShowNative,
+ onBack: handleBackToList,
+ }}
/>
</motion.div>
) : (
@@ -214,8 +222,8 @@ export function ExpertConnectServiceDialog({
provider={provider}
className="rounded-lg"
onSelect={handleSelect}
- isConnected={connectedProviders.has(
- provider.id,
+ isConnected={connectedServices.has(
+ provider.serviceId,
)}
/>
</li>
@@ -240,34 +248,36 @@ export function ExpertConnectServiceDialog({
</div>
</motion.div>
- <div className="flex items-center justify-end gap-3">
- {selectedProvider ? (
- <>
- <Button
- variant="secondary"
- size="small"
- onClick={handleBackToList}
- >
- Back
- </Button>
- {showContinue ? (
+ {isMcpStep ? null : (
+ <div className="flex items-center justify-end gap-3">
+ {selectedProvider ? (
+ <>
<Button
- variant="primary"
+ variant="secondary"
size="small"
- disabled={isContinueDisabled}
- loading={isConnecting}
- onClick={handleContinue}
+ onClick={handleBackToList}
>
- {isConnecting ? "Connecting…" : "Continue"}
+ Back
</Button>
- ) : null}
- </>
- ) : (
- <Button variant="secondary" size="small" onClick={onClose}>
- Cancel
- </Button>
- )}
- </div>
+ {showContinue ? (
+ <Button
+ variant="primary"
+ size="small"
+ disabled={isContinueDisabled}
+ loading={isConnecting}
+ onClick={handleContinue}
+ >
+ {isConnecting ? "Connecting…" : "Continue"}
+ </Button>
+ ) : null}
+ </>
+ ) : (
+ <Button variant="secondary" size="small" onClick={onClose}>
+ Cancel
+ </Button>
+ )}
+ </div>
+ )}
</div>
</Dialog.Content>
</Dialog>
diff --git a/autogpt_platform/frontend/src/app/(platform)/team/[expertId]/components/ExpertIntegrationsSection/ExpertIntegrationGroups.tsx b/autogpt_platform/frontend/src/app/(platform)/team/[expertId]/components/ExpertIntegrationsSection/ExpertIntegrationGroups.tsx
index fe5568cc5f..488778e85d 100644
--- a/autogpt_platform/frontend/src/app/(platform)/team/[expertId]/components/ExpertIntegrationsSection/ExpertIntegrationGroups.tsx
+++ b/autogpt_platform/frontend/src/app/(platform)/team/[expertId]/components/ExpertIntegrationsSection/ExpertIntegrationGroups.tsx
@@ -5,8 +5,8 @@ import { Icon } from "@/components/atoms/Icon/Icon";
import { Text } from "@/components/atoms/Text/Text";
import {
formatCredentialName,
- formatCredentialSource,
- formatProviderName,
+ groupServiceIdentity,
+ serviceKey,
} from "@/components/contextual/IntegrationsPanel/helpers";
import {
Accordion,
@@ -34,11 +34,6 @@ const CONNECTION_LABELS: Record<string, string> = {
device_code: "Connected via device auth",
};
-function formatConnection(integration: ExpertCredentialRef): string {
- if (integration.provider === "mcp") return formatCredentialSource("mcp");
- return CONNECTION_LABELS[integration.type] ?? "Configured";
-}
-
const CONTAINER_VARIANTS: Variants = {
hidden: {},
show: { transition: { staggerChildren: 0.08, delayChildren: 0.05 } },
@@ -59,22 +54,22 @@ const REDUCED_ITEM_VARIANTS: Variants = {
interface Group {
id: string;
name: string;
+ icon: string;
integrations: ExpertCredentialRef[];
}
export function groupExpertIntegrations(
integrations: ExpertCredentialRef[],
): Group[] {
- const byProvider = new Map<string, ExpertCredentialRef[]>();
+ const byService = new Map<string, ExpertCredentialRef[]>();
for (const integration of integrations) {
- const id =
- integration.provider === "codex" ? "openai" : integration.provider;
- byProvider.set(id, [...(byProvider.get(id) ?? []), integration]);
+ const id = serviceKey(integration);
+ byService.set(id, [...(byService.get(id) ?? []), integration]);
}
- return [...byProvider.entries()]
+ return [...byService.entries()]
.map(([id, list]) => ({
id,
- name: formatProviderName(id),
+ ...groupServiceIdentity(list),
integrations: list,
}))
.sort((a, b) => a.name.localeCompare(b.name));
@@ -116,7 +111,7 @@ export function ExpertIntegrationGroups({
<AccordionTrigger className="px-3 py-2.5 pr-4 hover:no-underline [&>svg]:size-4 [&>svg]:text-zinc-500">
<div className="flex items-center gap-2.5">
<IntegrationLogo
- provider={group.id}
+ provider={group.icon}
alt={`${group.name} logo`}
size={20}
className="rounded-full bg-white"
@@ -182,7 +177,7 @@ function ExpertIntegrationRow({ integration, isRemoving, onRemove }: RowProps) {
</Text>
</div>
<Text variant="body" as="span" tone="muted">
- {formatConnection(integration)}
+ {CONNECTION_LABELS[integration.type] ?? "Configured"}
</Text>
</div>
<div className="flex items-center gap-3">
diff --git a/autogpt_platform/frontend/src/app/(platform)/team/[expertId]/components/ExpertIntegrationsSection/UseExistingCredentialsDialog.tsx b/autogpt_platform/frontend/src/app/(platform)/team/[expertId]/components/ExpertIntegrationsSection/UseExistingCredentialsDialog.tsx
index 7b9b724a10..b8848db9cb 100644
--- a/autogpt_platform/frontend/src/app/(platform)/team/[expertId]/components/ExpertIntegrationsSection/UseExistingCredentialsDialog.tsx
+++ b/autogpt_platform/frontend/src/app/(platform)/team/[expertId]/components/ExpertIntegrationsSection/UseExistingCredentialsDialog.tsx
@@ -7,7 +7,9 @@ import { Icon } from "@/components/atoms/Icon/Icon";
import { Text } from "@/components/atoms/Text/Text";
import {
formatCredentialName,
- formatProviderName,
+ groupServiceIdentity,
+ serviceIcon,
+ serviceKey,
} from "@/components/contextual/IntegrationsPanel/helpers";
import type { ConnectableProvider } from "@/components/contextual/IntegrationsPanel/components/ConnectServiceDialog/helpers";
import { Dialog } from "@/components/molecules/Dialog/Dialog";
@@ -38,16 +40,23 @@ function groupByProvider(
): ProviderGroup[] {
const groups = new Map<string, CredentialsMetaResponse[]>();
for (const credential of credentials) {
- groups.set(credential.provider, [
- ...(groups.get(credential.provider) ?? []),
- credential,
- ]);
+ const id = serviceKey(credential);
+ groups.set(id, [...(groups.get(id) ?? []), credential]);
}
return [...groups.entries()]
- .map(([id, list]) => ({
- provider: { id, name: formatProviderName(id), supportedAuthTypes: [] },
- credentials: list,
- }))
+ .map(([id, list]) => {
+ const { name, icon } = groupServiceIdentity(list);
+ return {
+ provider: {
+ id,
+ serviceId: id,
+ name,
+ supportedAuthTypes: [],
+ iconId: icon,
+ },
+ credentials: list,
+ };
+ })
.sort((a, b) => a.provider.name.localeCompare(b.provider.name));
}
@@ -140,7 +149,7 @@ export function UseExistingCredentialsDialog({
className="flex items-center gap-3 rounded-xl bg-neutral-100 px-3 py-2.5"
>
<IntegrationLogo
- provider={credential.provider}
+ provider={serviceIcon(credential)}
size={24}
/>
<Text
@@ -202,7 +211,7 @@ export function UseExistingCredentialsDialog({
? formatCredentialName(
group.credentials[0].title ??
group.provider.name,
- group.provider.id,
+ group.credentials[0].provider,
)
: `${group.credentials.length} connections · choose one`
}
diff --git a/autogpt_platform/frontend/src/app/(platform)/team/[expertId]/components/ExpertIntegrationsSection/useExpertConnectServiceDialog.ts b/autogpt_platform/frontend/src/app/(platform)/team/[expertId]/components/ExpertIntegrationsSection/useExpertConnectServiceDialog.ts
index 492330e261..83e73b7f91 100644
--- a/autogpt_platform/frontend/src/app/(platform)/team/[expertId]/components/ExpertIntegrationsSection/useExpertConnectServiceDialog.ts
+++ b/autogpt_platform/frontend/src/app/(platform)/team/[expertId]/components/ExpertIntegrationsSection/useExpertConnectServiceDialog.ts
@@ -3,15 +3,18 @@ import {
useGetV1ListProviders,
} from "@/app/api/__generated__/endpoints/integrations/integrations";
import type { CredentialsMetaResponse } from "@/app/api/__generated__/models/credentialsMetaResponse";
+import { filterSystemCredentials } from "@/components/contextual/CredentialsInput/helpers";
import { useApiKeyConnectForm } from "@/components/contextual/IntegrationsPanel/components/ConnectServiceDialog/components/DetailView/useApiKeyConnectForm";
import { useOAuthConnect } from "@/components/contextual/IntegrationsPanel/components/ConnectServiceDialog/components/DetailView/useOAuthConnect";
import {
AuthType,
filterConnectableProviders,
+ opensOnNativeMethods,
toConnectableProviders,
type AuthMethod,
type ConnectableProvider,
} from "@/components/contextual/IntegrationsPanel/components/ConnectServiceDialog/helpers";
+import { serviceKey } from "@/components/contextual/IntegrationsPanel/helpers";
import { useDebouncedValue } from "@/hooks/useDebouncedValue";
import { useEffect, useState } from "react";
@@ -44,6 +47,7 @@ export function useExpertConnectServiceDialog({
const [selectedId, setSelectedId] = useState<string | null>(null);
const [selectedMethod, setSelectedMethod] = useState<AuthMethod | null>(null);
const [direction, setDirection] = useState<1 | -1>(1);
+ const [nativeOverride, setNativeOverride] = useState<boolean | null>(null);
const providersQuery = useGetV1ListProviders({
query: {
@@ -64,37 +68,43 @@ export function useExpertConnectServiceDialog({
setFilter("all");
setSelectedId(null);
setSelectedMethod(null);
+ setNativeOverride(null);
return;
}
if (initialProviderId) {
setDirection(1);
setSelectedId(initialProviderId);
setSelectedMethod(null);
+ setNativeOverride(null);
}
}, [open, initialProviderId]);
- const allProviders = toConnectableProviders(
- (providersQuery.data ?? []).filter((provider) => !provider.mcp_server),
- );
- const credentials = credentialsQuery.data ?? [];
- const connectedProviders = new Set(
- credentials.map((credential) => credential.provider),
- );
+ const allProviders = toConnectableProviders(providersQuery.data ?? []);
+ const credentials = filterSystemCredentials(credentialsQuery.data ?? []);
+ const connectedServices = new Set(credentials.map(serviceKey));
const providers = filterConnectableProviders(
allProviders,
debouncedQuery,
).filter((provider) => {
if (filter === "all") return true;
- const isConnected = connectedProviders.has(provider.id);
+ const isConnected = connectedServices.has(provider.serviceId);
return filter === "connected" ? isConnected : !isConnected;
});
const selectedProvider: ConnectableProvider | null = selectedId
? (allProviders.find((provider) => provider.id === selectedId) ?? null)
: null;
+ const showNative =
+ nativeOverride ??
+ (selectedProvider
+ ? opensOnNativeMethods(true, selectedProvider.supportedAuthTypes.length)
+ : false);
+ const isMcpStep = Boolean(selectedProvider?.mcpServer) && !showNative;
+
function handleSuccess(credential?: CredentialsMetaResponse) {
setDirection(-1);
setSelectedId(null);
setSelectedMethod(null);
+ setNativeOverride(null);
if (credential) onConnected(credential);
}
@@ -111,6 +121,7 @@ export function useExpertConnectServiceDialog({
setDirection(1);
setSelectedId(providerId);
setSelectedMethod(null);
+ setNativeOverride(null);
apiKey.form.reset();
}
@@ -118,6 +129,7 @@ export function useExpertConnectServiceDialog({
setDirection(-1);
setSelectedId(null);
setSelectedMethod(null);
+ setNativeOverride(null);
}
function handleContinue() {
@@ -141,15 +153,19 @@ export function useExpertConnectServiceDialog({
refetch: providersQuery.refetch,
selectedProvider,
direction,
- connectedProviders,
+ connectedServices,
selectedMethod,
setSelectedMethod,
+ showNative,
+ setShowNative: setNativeOverride,
+ isMcpStep,
apiKeyForm: apiKey.form,
handleApiKeySubmit: apiKey.handleSubmit,
showContinue:
- !selectedMethod ||
- selectedMethod === AuthType.oauth2 ||
- selectedMethod === AuthType.api_key,
+ !isMcpStep &&
+ (!selectedMethod ||
+ selectedMethod === AuthType.oauth2 ||
+ selectedMethod === AuthType.api_key),
isContinueDisabled:
!selectedMethod ||
(selectedMethod === AuthType.api_key && !apiKey.form.formState.isValid),
diff --git a/autogpt_platform/frontend/src/app/(platform)/team/__tests__/main.test.tsx b/autogpt_platform/frontend/src/app/(platform)/team/__tests__/main.test.tsx
index 856aa17d61..c03ed82778 100644
--- a/autogpt_platform/frontend/src/app/(platform)/team/__tests__/main.test.tsx
+++ b/autogpt_platform/frontend/src/app/(platform)/team/__tests__/main.test.tsx
@@ -1216,7 +1216,7 @@ describe("TeamPage - setup needed card", () => {
expect(within(card).queryByRole("button", { name: "Connect" })).toBeNull();
});
- test("excludes MCP presets from native setup actions while keeping the unmet item", async () => {
+ test("offers Connect for a service reached only through its own sign-in", async () => {
server.use(
getListExpertSetupItemsMockHandler([
makeSetupItem({ providers: ["mcp_notion"] }),
@@ -1240,8 +1240,15 @@ describe("TeamPage - setup needed card", () => {
const card = await screen.findByTestId("setup-needed");
expect(within(card).getByText("Setup needed (1)")).toBeDefined();
- expect(await within(card).findByText("Needs a platform key")).toBeDefined();
- expect(within(card).queryByRole("button", { name: "Connect" })).toBeNull();
+ fireEvent.click(
+ await within(card).findByRole("button", { name: "Connect" }),
+ );
+
+ const dialog = await screen.findByRole("dialog");
+ expect(await within(dialog).findByText("Sign in to Notion.")).toBeDefined();
+ expect(
+ within(dialog).queryByRole("button", { name: "Continue" }),
+ ).toBeNull();
});
test("Allow grants the existing credential to that expert", async () => {
diff --git a/autogpt_platform/frontend/src/app/(platform)/team/components/ExpertTeamCard/components/IntegrationIcons.tsx b/autogpt_platform/frontend/src/app/(platform)/team/components/ExpertTeamCard/components/IntegrationIcons.tsx
index d249054a2c..72e5720009 100644
--- a/autogpt_platform/frontend/src/app/(platform)/team/components/ExpertTeamCard/components/IntegrationIcons.tsx
+++ b/autogpt_platform/frontend/src/app/(platform)/team/components/ExpertTeamCard/components/IntegrationIcons.tsx
@@ -6,7 +6,7 @@ import {
TooltipContent,
TooltipTrigger,
} from "@/components/atoms/Tooltip/BaseTooltip";
-import { formatProviderName } from "@/components/contextual/IntegrationsPanel/helpers";
+import { serviceLabelFromIcon } from "@/components/contextual/IntegrationsPanel/helpers";
import Image from "next/image";
import { useState } from "react";
@@ -25,7 +25,7 @@ export function IntegrationIcons({ expertName, providers }: Props) {
if (providers.length === 0) return null;
const shown = providers.slice(0, VISIBLE_LOGOS);
const hidden = providers.slice(VISIBLE_LOGOS);
- const hiddenNames = hidden.map(formatProviderName).join(", ");
+ const hiddenNames = hidden.map(serviceLabelFromIcon).join(", ");
return (
<ul aria-label="Integrations" className="flex shrink-0 items-center gap-1">
@@ -38,7 +38,7 @@ export function IntegrationIcons({ expertName, providers }: Props) {
</span>
</TooltipTrigger>
<TooltipContent>
- {expertName} has access to your {formatProviderName(provider)}{" "}
+ {expertName} has access to your {serviceLabelFromIcon(provider)}{" "}
account
</TooltipContent>
</Tooltip>
@@ -71,7 +71,7 @@ interface LogoProps {
function ProviderLogo({ provider }: LogoProps) {
const [isBroken, setIsBroken] = useState(false);
- const name = formatProviderName(provider);
+ const name = serviceLabelFromIcon(provider);
if (isBroken) {
return (
diff --git a/autogpt_platform/frontend/src/app/(platform)/team/components/SetupNeeded/useSetupNeeded.ts b/autogpt_platform/frontend/src/app/(platform)/team/components/SetupNeeded/useSetupNeeded.ts
index 15dab7ce20..b5f0bad9b0 100644
--- a/autogpt_platform/frontend/src/app/(platform)/team/components/SetupNeeded/useSetupNeeded.ts
+++ b/autogpt_platform/frontend/src/app/(platform)/team/components/SetupNeeded/useSetupNeeded.ts
@@ -7,7 +7,7 @@ import type { CredentialsMetaResponse } from "@/app/api/__generated__/models/cre
import type { ExpertSetupItem } from "@/app/api/__generated__/models/expertSetupItem";
import { okData } from "@/app/api/helpers";
import { toConnectableProviders } from "@/components/contextual/IntegrationsPanel/components/ConnectServiceDialog/helpers";
-import { formatProviderName } from "@/components/contextual/IntegrationsPanel/helpers";
+import { serviceName } from "@/components/contextual/IntegrationsPanel/helpers";
import { useToast } from "@/components/molecules/Toast/use-toast";
import { invalidateExpertGrantQueries } from "@/services/experts/invalidate-experts";
import { useQueryClient } from "@tanstack/react-query";
@@ -32,9 +32,7 @@ export function useSetupNeeded({ enabled }: Args) {
},
});
const connectable = new Set(
- toConnectableProviders(
- (providersQuery.data ?? []).filter((provider) => !provider.mcp_server),
- ).map((p) => p.id),
+ toConnectableProviders(providersQuery.data ?? []).map((p) => p.id),
);
const { mutate: grant, isPending: isGranting } = useGrantExpertCredentials({
@@ -48,12 +46,21 @@ export function useSetupNeeded({ enabled }: Args) {
function grantTo(
item: ExpertSetupItem,
- credential: { id: string; provider?: string },
+ credential: {
+ id: string;
+ provider?: string;
+ service?: string;
+ service_name?: string | null;
+ },
) {
// A row can name a credential without naming its provider, and half a
// sentence is worse than a general one.
const service = credential.provider
- ? formatProviderName(credential.provider)
+ ? serviceName({
+ provider: credential.provider,
+ service: credential.service,
+ service_name: credential.service_name,
+ })
: "this service";
grant(
{ expertId: item.expert_id, data: { credential_ids: [credential.id] } },
diff --git a/autogpt_platform/frontend/src/app/api/openapi.json b/autogpt_platform/frontend/src/app/api/openapi.json
index 871855cecf..2736285dca 100644
--- a/autogpt_platform/frontend/src/app/api/openapi.json
+++ b/autogpt_platform/frontend/src/app/api/openapi.json
@@ -20633,6 +20633,15 @@
"type": "boolean",
"title": "Is Managed",
"default": false
+ },
+ "service": { "type": "string", "title": "Service", "default": "" },
+ "service_name": {
+ "anyOf": [{ "type": "string" }, { "type": "null" }],
+ "title": "Service Name"
+ },
+ "service_icon": {
+ "anyOf": [{ "type": "string" }, { "type": "null" }],
+ "title": "Service Icon"
}
},
"type": "object",
@@ -22217,7 +22226,16 @@
"credential_id": { "type": "string", "title": "Credential Id" },
"provider": { "type": "string", "title": "Provider" },
"title": { "type": "string", "title": "Title" },
- "type": { "type": "string", "title": "Type" }
+ "type": { "type": "string", "title": "Type" },
+ "service": { "type": "string", "title": "Service", "default": "" },
+ "service_name": {
+ "anyOf": [{ "type": "string" }, { "type": "null" }],
+ "title": "Service Name"
+ },
+ "service_icon": {
+ "anyOf": [{ "type": "string" }, { "type": "null" }],
+ "title": "Service Icon"
+ }
},
"type": "object",
"required": ["credential_id", "provider", "title", "type"],
@@ -28095,6 +28113,20 @@
"type": "array",
"title": "Supported Auth Types",
"description": "Credential types this provider accepts. Drives which connection tabs the settings UI renders for the provider. Empty list means no auth types declared."
+ },
+ "service": {
+ "type": "string",
+ "title": "Service",
+ "description": "Grouping key shared by a block provider and its MCP server.",
+ "default": ""
+ },
+ "service_name": {
+ "anyOf": [{ "type": "string" }, { "type": "null" }],
+ "title": "Service Name"
+ },
+ "service_icon": {
+ "anyOf": [{ "type": "string" }, { "type": "null" }],
+ "title": "Service Icon"
}
},
"type": "object",
diff --git a/autogpt_platform/frontend/src/components/contextual/CredentialsInput/components/ConnectCredentialDialog/ConnectCredentialDialog.tsx b/autogpt_platform/frontend/src/components/contextual/CredentialsInput/components/ConnectCredentialDialog/ConnectCredentialDialog.tsx
index 7f92573272..c5e2407ebf 100644
--- a/autogpt_platform/frontend/src/components/contextual/CredentialsInput/components/ConnectCredentialDialog/ConnectCredentialDialog.tsx
+++ b/autogpt_platform/frontend/src/components/contextual/CredentialsInput/components/ConnectCredentialDialog/ConnectCredentialDialog.tsx
@@ -139,6 +139,7 @@ export function ConnectCredentialDialog({
const connectable: ConnectableProvider = {
id: provider,
+ serviceId: provider,
name: displayName,
description: null,
supportedAuthTypes: getConnectableCredentialTypes(
diff --git a/autogpt_platform/frontend/src/components/contextual/IntegrationsPanel/IntegrationsPanel.tsx b/autogpt_platform/frontend/src/components/contextual/IntegrationsPanel/IntegrationsPanel.tsx
index c22d28d176..24e0b73673 100644
--- a/autogpt_platform/frontend/src/components/contextual/IntegrationsPanel/IntegrationsPanel.tsx
+++ b/autogpt_platform/frontend/src/components/contextual/IntegrationsPanel/IntegrationsPanel.tsx
@@ -1,5 +1,6 @@
"use client";
+import type { CredentialsMetaResponse } from "@/app/api/__generated__/models/credentialsMetaResponse";
import { useState } from "react";
import { Text } from "@/components/atoms/Text/Text";
@@ -10,11 +11,25 @@ import { IntegrationsHeader } from "./components/IntegrationsHeader/Integrations
import { IntegrationsList } from "./components/IntegrationsList/IntegrationsList";
import { AvailableIntegrations } from "./components/AvailableIntegrations/AvailableIntegrations";
+const SURFACE_BACKGROUND = {
+ page: "bg-[#F9F9FA]",
+ dialog: "bg-white",
+} as const;
+
interface Props {
withHeading?: boolean;
+ /** What the panel sits on, so the sticky search matches it. */
+ surface?: keyof typeof SURFACE_BACKGROUND;
+ preferMcp?: boolean;
+ onConnected?: (credential: CredentialsMetaResponse) => void;
}
-export function IntegrationsPanel({ withHeading = true }: Props) {
+export function IntegrationsPanel({
+ withHeading = true,
+ surface = "page",
+ preferMcp,
+ onConnected,
+}: Props) {
const [isConnectOpen, setIsConnectOpen] = useState(false);
const [selectedProviderId, setSelectedProviderId] = useState<string | null>(
null,
@@ -42,13 +57,19 @@ export function IntegrationsPanel({ withHeading = true }: Props) {
>
Tools your agents use
</Text>
- <IntegrationsList query={query} onQueryChange={setQuery} />
+ <IntegrationsList
+ query={query}
+ onQueryChange={setQuery}
+ stickyClassName={SURFACE_BACKGROUND[surface]}
+ />
</section>
<AvailableIntegrations query={query} onSelect={openConnect} />
<ConnectServiceDialog
open={isConnectOpen}
onOpenChange={setIsConnectOpen}
initialProviderId={selectedProviderId}
+ preferMcp={preferMcp}
+ onConnected={onConnected}
/>
</>
);
diff --git a/autogpt_platform/frontend/src/components/contextual/IntegrationsPanel/__tests__/helpers.test.ts b/autogpt_platform/frontend/src/components/contextual/IntegrationsPanel/__tests__/helpers.test.ts
index eed78ec50b..7c2c536028 100644
--- a/autogpt_platform/frontend/src/components/contextual/IntegrationsPanel/__tests__/helpers.test.ts
+++ b/autogpt_platform/frontend/src/components/contextual/IntegrationsPanel/__tests__/helpers.test.ts
@@ -36,6 +36,8 @@ function makeView(overrides: Partial<CredentialView> = {}): CredentialView {
username: null,
host: null,
isManaged: false,
+ isSignIn: false,
+ blocksNote: null,
...overrides,
};
}
@@ -45,9 +47,6 @@ describe("formatProviderName", () => {
expect(formatProviderName("github")).toBe("GitHub");
expect(formatProviderName("d_id")).toBe("D-ID");
expect(formatProviderName("twitter")).toBe("X");
- // "MCP" is an acronym — without an override the title-caser would
- // emit the awkward "Mcp" we shipped before; keep the override.
- expect(formatProviderName("mcp")).toBe("MCP");
});
test("title-cases unknown snake_case slugs", () => {
@@ -131,8 +130,37 @@ describe("groupCredentialsByProvider", () => {
expect(groups[0].credentials[0].title).toBe("GitHub");
});
+ test("files a credential under the service the backend names", () => {
+ const groups = groupCredentialsByProvider([
+ makeCred({
+ id: "key",
+ provider: "linear",
+ title: "Linear key",
+ service: "linear",
+ service_icon: "linear",
+ }),
+ makeCred({
+ id: "server",
+ provider: "mcp",
+ type: "oauth2",
+ title: "MCP: mcp.linear.app",
+ service: "linear",
+ service_name: "Linear",
+ service_icon: "linear",
+ }),
+ ]);
+
+ expect(groups).toHaveLength(1);
+ expect(groups[0]).toMatchObject({
+ id: "linear",
+ name: "Linear",
+ logoUrl: "/integrations/linear.png",
+ });
+ expect(groups[0].credentials.map((c) => c.id)).toEqual(["key", "server"]);
+ });
+
test("strips redundant '<ProviderName>: ' prefix from per-credential titles", () => {
- // The row already lives under the provider group, so a title like
+ // The row already lives under the service group, so a title like
// ``"MCP: <hostname>"`` or ``"GitHub: octocat"`` duplicates the
// group label. Strip generically using the formatted provider name.
const groups = groupCredentialsByProvider([
@@ -140,6 +168,9 @@ describe("groupCredentialsByProvider", () => {
id: "1",
provider: "mcp",
title: "MCP: mcp.sentry.dev",
+ service: "sentry",
+ service_name: "Sentry",
+ service_icon: "sentry",
}),
makeCred({
id: "2",
@@ -152,9 +183,10 @@ describe("groupCredentialsByProvider", () => {
title: "Personal",
}),
]);
- const mcp = groups.find((g) => g.id === "mcp");
+ const sentry = groups.find((g) => g.id === "sentry");
const github = groups.find((g) => g.id === "github");
- expect(mcp?.credentials[0].title).toBe("mcp.sentry.dev");
+ expect(sentry?.name).toBe("Sentry");
+ expect(sentry?.credentials[0].title).toBe("mcp.sentry.dev");
expect(github?.credentials.find((c) => c.id === "2")?.title).toBe(
"octocat",
);
diff --git a/autogpt_platform/frontend/src/components/contextual/IntegrationsPanel/components/AvailableIntegrations/AvailableIntegrations.tsx b/autogpt_platform/frontend/src/components/contextual/IntegrationsPanel/components/AvailableIntegrations/AvailableIntegrations.tsx
index 3a986450e6..7b468c3ed7 100644
--- a/autogpt_platform/frontend/src/components/contextual/IntegrationsPanel/components/AvailableIntegrations/AvailableIntegrations.tsx
+++ b/autogpt_platform/frontend/src/components/contextual/IntegrationsPanel/components/AvailableIntegrations/AvailableIntegrations.tsx
@@ -30,7 +30,7 @@ export function AvailableIntegrations({ query, onSelect }: Props) {
Available integrations
</Text>
<Text variant="small" className="text-zinc-500">
- Connect your services, including official MCP integrations. Some
+ Connect your services, including official vendor integrations. Some
services need additional setup.
</Text>
</div>
diff --git a/autogpt_platform/frontend/src/components/contextual/IntegrationsPanel/components/ConnectServiceDialog/ConnectServiceDialog.tsx b/autogpt_platform/frontend/src/components/contextual/IntegrationsPanel/components/ConnectServiceDialog/ConnectServiceDialog.tsx
index a73d3756ad..019cae8434 100644
--- a/autogpt_platform/frontend/src/components/contextual/IntegrationsPanel/components/ConnectServiceDialog/ConnectServiceDialog.tsx
+++ b/autogpt_platform/frontend/src/components/contextual/IntegrationsPanel/components/ConnectServiceDialog/ConnectServiceDialog.tsx
@@ -23,6 +23,7 @@ interface Props {
description?: string;
onConnected?: (credential: CredentialsMetaResponse) => void;
initialProviderId?: string | null;
+ preferMcp?: boolean;
}
const DEFAULT_TITLE = "Connect a service";
@@ -54,6 +55,7 @@ export function ConnectServiceDialog({
description = DEFAULT_DESCRIPTION,
onConnected,
initialProviderId,
+ preferMcp,
}: Props) {
const {
query,
@@ -142,6 +144,7 @@ export function ConnectServiceDialog({
provider={selectedProvider!}
onBack={handleBack}
onSuccess={handleSuccess}
+ preferMcp={preferMcp}
/>
</motion.div>
)}
diff --git a/autogpt_platform/frontend/src/components/contextual/IntegrationsPanel/components/ConnectServiceDialog/__tests__/helpers.test.ts b/autogpt_platform/frontend/src/components/contextual/IntegrationsPanel/components/ConnectServiceDialog/__tests__/helpers.test.ts
index 69ee7c4b76..6918cb894e 100644
--- a/autogpt_platform/frontend/src/components/contextual/IntegrationsPanel/components/ConnectServiceDialog/__tests__/helpers.test.ts
+++ b/autogpt_platform/frontend/src/components/contextual/IntegrationsPanel/components/ConnectServiceDialog/__tests__/helpers.test.ts
@@ -18,7 +18,7 @@ function makeMeta(overrides: Partial<ProviderMetadata> = {}): ProviderMetadata {
}
describe("toConnectableProviders", () => {
- test("keeps official MCP presets separate from native auth providers", () => {
+ test("merges a vendor's block provider and its sign-in into one service", () => {
const mcpServer = {
server_url: "https://mcp.notion.com/mcp",
documentation_url: "https://developers.notion.com/docs/mcp",
@@ -27,29 +27,66 @@ describe("toConnectableProviders", () => {
auth_methods: ["oauth" as const],
icon_id: "notion",
};
+ const block = makeMeta({
+ name: "notion",
+ description: "Docs and databases",
+ service: "notion",
+ service_name: null,
+ service_icon: "notion",
+ });
const preset = {
name: "mcp_notion",
display_name: "Notion",
description: "Search and edit workspace content",
supported_auth_types: [],
mcp_server: mcpServer,
+ service: "notion",
+ service_name: "Notion",
+ service_icon: "notion",
};
- const result = toConnectableProviders([
- makeMeta({ name: "notion" }),
- preset,
- ]);
-
- expect(result).toHaveLength(2);
- expect(
- result.find((provider) => provider.id === "mcp_notion"),
- ).toMatchObject({
+ const merged = {
+ id: "notion",
+ serviceId: "notion",
name: "Notion",
+ description: "Docs and databases",
+ supportedAuthTypes: ["oauth2", "api_key"],
mcpServer,
+ iconId: "notion",
+ };
+
+ const blockFirst = toConnectableProviders([block, preset]);
+ expect(blockFirst).toHaveLength(1);
+ expect(blockFirst[0]).toMatchObject(merged);
+
+ const catalogFirst = toConnectableProviders([preset, block]);
+ expect(catalogFirst).toHaveLength(1);
+ expect(catalogFirst[0]).toMatchObject(merged);
+ });
+
+ test("keeps a service reached only through its sign-in under its catalog name", () => {
+ const result = toConnectableProviders([
+ {
+ name: "mcp_sentry",
+ display_name: "Sentry",
+ supported_auth_types: [],
+ service: "sentry",
+ service_name: "Sentry",
+ service_icon: "sentry",
+ mcp_server: {
+ server_url: "https://mcp.sentry.dev/mcp",
+ documentation_url: "https://docs.sentry.io",
+ setup_instructions: "Sign in to Sentry.",
+ connection_mode: "hosted",
+ auth_methods: ["oauth"],
+ },
+ },
+ ]);
+ expect(result[0]).toMatchObject({
+ id: "mcp_sentry",
+ serviceId: "sentry",
+ name: "Sentry",
supportedAuthTypes: [],
});
- expect(
- result.find((provider) => provider.id === "notion")?.supportedAuthTypes,
- ).toEqual(["oauth2", "api_key"]);
});
test("formats provider name and preserves description and supported types", () => {
@@ -59,9 +96,11 @@ describe("toConnectableProviders", () => {
expect(result).toEqual([
{
id: "github",
+ serviceId: "github",
name: "GitHub",
description: "Issues and PRs",
supportedAuthTypes: ["oauth2", "api_key"],
+ iconId: "github",
},
]);
});
@@ -121,18 +160,21 @@ describe("filterConnectableProviders", () => {
const providers: ConnectableProvider[] = [
{
id: "github",
+ serviceId: "github",
name: "GitHub",
description: "Issues and PRs",
supportedAuthTypes: ["oauth2", "api_key"],
},
{
id: "acai-juice",
+ serviceId: "acai-juice",
name: "Açaí",
description: "Bowls",
supportedAuthTypes: ["api_key"],
},
{
id: "linear",
+ serviceId: "linear",
name: "Linear",
description: "Project tracking",
supportedAuthTypes: ["oauth2"],
diff --git a/autogpt_platform/frontend/src/components/contextual/IntegrationsPanel/components/ConnectServiceDialog/components/ConnectMethodView/ConnectMethodView.tsx b/autogpt_platform/frontend/src/components/contextual/IntegrationsPanel/components/ConnectServiceDialog/components/ConnectMethodView/ConnectMethodView.tsx
index ec46f749af..5370ff5350 100644
--- a/autogpt_platform/frontend/src/components/contextual/IntegrationsPanel/components/ConnectServiceDialog/components/ConnectMethodView/ConnectMethodView.tsx
+++ b/autogpt_platform/frontend/src/components/contextual/IntegrationsPanel/components/ConnectServiceDialog/components/ConnectMethodView/ConnectMethodView.tsx
@@ -2,14 +2,17 @@
import type { CredentialsMetaResponse } from "@/app/api/__generated__/models/credentialsMetaResponse";
import { AutoGPTLogo } from "@/components/atoms/AutoGPTLogo/AutoGPTLogo";
+import { Button } from "@/components/atoms/Button/Button";
import { Icon } from "@/components/atoms/Icon/Icon";
import { Text } from "@/components/atoms/Text/Text";
import { DeviceAuthConnectButton } from "@/components/contextual/DeviceAuth/DeviceAuthConnectButton";
+import { McpFirstPanel } from "@/components/contextual/IntegrationsPanel/components/ConnectServiceDialog/components/DetailView/McpFirstPanel";
import { ProviderAvatar } from "@/components/contextual/IntegrationsPanel/components/ConnectServiceDialog/components/DetailView/ProviderAvatar";
import type { ApiKeyConnectFormValues } from "@/components/contextual/IntegrationsPanel/components/ConnectServiceDialog/components/DetailView/schema";
import { UnsupportedNotice } from "@/components/contextual/IntegrationsPanel/components/ConnectServiceDialog/components/DetailView/UnsupportedNotice";
import {
AuthType,
+ getSignInFallbackLabel,
type AuthMethod,
type ConnectableProvider,
} from "@/components/contextual/IntegrationsPanel/components/ConnectServiceDialog/helpers";
@@ -30,7 +33,7 @@ import { AnimatePresence, domAnimation, LazyMotion, m } from "framer-motion";
interface Props {
provider: ConnectableProvider;
selectedMethod: AuthMethod | null;
- onSelectMethod: (method: AuthMethod) => void;
+ onSelectMethod: (method: AuthMethod | null) => void;
apiKeyForm: UseFormReturn<ApiKeyConnectFormValues>;
onApiKeySubmit: (values: ApiKeyConnectFormValues) => void;
/** The host the requesting block will call, when one is in scope. */
@@ -38,6 +41,13 @@ interface Props {
/** A method that completes inside this view rather than through the
* panel footer's Continue: device auth, host-scoped, user/password. */
onInlineConnectSuccess: (credential?: CredentialsMetaResponse) => void;
+ /** Offers the vendor's own sign-in beside the block methods. The host
+ * owns which side shows, since the sign-in carries its own Back. */
+ mcpSignIn?: {
+ showNative: boolean;
+ onShowNativeChange: (showNative: boolean) => void;
+ onBack: () => void;
+ };
}
export const METHOD_ORDER: AuthMethod[] = [
@@ -96,10 +106,18 @@ export function ConnectMethodView({
onApiKeySubmit,
hostScopedHost,
onInlineConnectSuccess,
+ mcpSignIn,
}: Props) {
const methods = METHOD_ORDER.filter((method) =>
provider.supportedAuthTypes.includes(method),
);
+ const offersMcp = Boolean(provider.mcpServer && mcpSignIn);
+ const showMcp = offersMcp && !mcpSignIn?.showNative;
+
+ function handleUseSignIn() {
+ onSelectMethod(null);
+ mcpSignIn?.onShowNativeChange(false);
+ }
return (
// `m` + a local provider, so this renders both standalone and inside
@@ -122,121 +140,148 @@ export function ConnectMethodView({
))}
</span>
<span className="flex h-20 w-20 items-center justify-center rounded-full bg-white shadow-[0_8px_24px_rgba(0,0,0,0.08)] ring-1 ring-zinc-100">
- <ProviderAvatar id={provider.id} name={provider.name} />
+ <ProviderAvatar
+ id={provider.iconId ?? provider.id}
+ name={provider.name}
+ />
</span>
</div>
<div className="flex flex-col gap-1.5 text-center">
<Text variant="h3" className="!text-[1.25rem] text-zinc-900">
- Connect AutoGPT to {provider.name}
- </Text>
- <Text variant="body" className="!text-zinc-500">
- Choose how you&apos;d like to connect your {provider.name} account.
+ {showMcp
+ ? `Connect ${provider.name}`
+ : `Connect AutoGPT to ${provider.name}`}
</Text>
+ {showMcp ? null : (
+ <Text variant="body" className="!text-zinc-500">
+ Choose how you&apos;d like to connect your {provider.name}{" "}
+ account.
+ </Text>
+ )}
</div>
- <div className="flex flex-col gap-1 rounded-2xl bg-neutral-100 p-1.5">
- {methods.map((method) => {
- const copy = METHOD_COPY[method];
- const isSelected = selectedMethod === method;
- const hasInlineForm = method !== AuthType.oauth2;
- return (
- <div
- key={method}
- className={isSelected ? "rounded-xl bg-white shadow-sm" : ""}
- >
- <button
- type="button"
- onClick={() => onSelectMethod(method)}
- className={
- isSelected
- ? "flex w-full items-center gap-3 rounded-xl p-3 text-left"
- : "flex w-full items-center gap-3 rounded-xl p-3 text-left transition-colors hover:bg-white/60"
- }
- >
- <span className="flex h-11 w-11 shrink-0 items-center justify-center rounded-lg bg-white shadow-sm">
- <Icon
- icon={copy.icon}
- size={22}
- className="text-zinc-700"
- />
- </span>
- <span className="flex min-w-0 flex-1 flex-col gap-0.5">
- <span className="flex items-center gap-2">
- <span className="text-sm font-semibold text-zinc-900">
- {copy.label}
- </span>
- {copy.recommended && (
- <span className="rounded-md bg-violet-100 px-1.5 py-0.5 text-[10px] font-semibold tracking-wide text-violet-700">
- RECOMMENDED
- </span>
- )}
- </span>
- <span className="text-xs text-zinc-500">
- {copy.description}
- </span>
- </span>
- <span
- aria-hidden
+ {showMcp && provider.mcpServer ? (
+ <McpFirstPanel
+ server={provider.mcpServer}
+ nativeMethods={methods}
+ onUseNative={() => mcpSignIn?.onShowNativeChange(true)}
+ onSuccess={onInlineConnectSuccess}
+ onBack={mcpSignIn?.onBack}
+ />
+ ) : (
+ <div className="flex flex-col gap-4">
+ <div className="flex flex-col gap-1 rounded-2xl bg-neutral-100 p-1.5">
+ {methods.map((method) => {
+ const copy = METHOD_COPY[method];
+ const isSelected = selectedMethod === method;
+ const hasInlineForm = method !== AuthType.oauth2;
+ return (
+ <div
+ key={method}
className={
- isSelected
- ? "flex h-5 w-5 shrink-0 items-center justify-center rounded-full border-2 border-violet-600"
- : "h-5 w-5 shrink-0 rounded-full border-2 border-zinc-200"
+ isSelected ? "rounded-xl bg-white shadow-sm" : ""
}
>
- {isSelected && (
- <span className="h-2.5 w-2.5 rounded-full bg-violet-600" />
- )}
- </span>
- </button>
- {/* Form methods open in place: the card grows to reveal the
- inputs, submit included — no separate step. */}
- <AnimatePresence initial={false}>
- {isSelected && hasInlineForm && (
- <m.div
- key="form"
- initial={{ height: 0, opacity: 0 }}
- animate={{ height: "auto", opacity: 1 }}
- exit={{ height: 0, opacity: 0 }}
- transition={{ duration: 0.25, ease: [0, 0, 0.2, 1] }}
- className="overflow-hidden"
+ <button
+ type="button"
+ onClick={() => onSelectMethod(method)}
+ className={
+ isSelected
+ ? "flex w-full items-center gap-3 rounded-xl p-3 text-left"
+ : "flex w-full items-center gap-3 rounded-xl p-3 text-left transition-colors hover:bg-white/60"
+ }
>
- <div className="px-3 pb-3">
- {method === AuthType.api_key ? (
- <InlineApiKeyForm
- form={apiKeyForm}
- providerName={provider.name}
- onSubmit={onApiKeySubmit}
- />
- ) : method === AuthType.device_code ? (
- <DeviceAuthConnectButton
- provider={provider.id}
- providerName={provider.name}
- onSuccess={onInlineConnectSuccess}
- />
- ) : method === AuthType.host_scoped ? (
- <InlineHostScopedForm
- provider={provider.id}
- host={hostScopedHost}
- onSuccess={onInlineConnectSuccess}
- />
- ) : method === AuthType.user_password ? (
- <InlineUserPasswordForm
- provider={provider.id}
- providerName={provider.name}
- onSuccess={onInlineConnectSuccess}
- />
- ) : (
- <UnsupportedNotice providerName={provider.name} />
+ <span className="flex h-11 w-11 shrink-0 items-center justify-center rounded-lg bg-white shadow-sm">
+ <Icon
+ icon={copy.icon}
+ size={22}
+ className="text-zinc-700"
+ />
+ </span>
+ <span className="flex min-w-0 flex-1 flex-col gap-0.5">
+ <span className="flex items-center gap-2">
+ <span className="text-sm font-semibold text-zinc-900">
+ {copy.label}
+ </span>
+ {copy.recommended && (
+ <span className="rounded-md bg-violet-100 px-1.5 py-0.5 text-[10px] font-semibold tracking-wide text-violet-700">
+ RECOMMENDED
+ </span>
+ )}
+ </span>
+ <span className="text-xs text-zinc-500">
+ {copy.description}
+ </span>
+ </span>
+ <span
+ aria-hidden
+ className={
+ isSelected
+ ? "flex h-5 w-5 shrink-0 items-center justify-center rounded-full border-2 border-violet-600"
+ : "h-5 w-5 shrink-0 rounded-full border-2 border-zinc-200"
+ }
+ >
+ {isSelected && (
+ <span className="h-2.5 w-2.5 rounded-full bg-violet-600" />
)}
- </div>
- </m.div>
- )}
- </AnimatePresence>
- </div>
- );
- })}
- </div>
+ </span>
+ </button>
+ {/* Form methods open in place: the card grows to reveal the
+ inputs, submit included — no separate step. */}
+ <AnimatePresence initial={false}>
+ {isSelected && hasInlineForm && (
+ <m.div
+ key="form"
+ initial={{ height: 0, opacity: 0 }}
+ animate={{ height: "auto", opacity: 1 }}
+ exit={{ height: 0, opacity: 0 }}
+ transition={{ duration: 0.25, ease: [0, 0, 0.2, 1] }}
+ className="overflow-hidden"
+ >
+ <div className="px-3 pb-3">
+ {method === AuthType.api_key ? (
+ <InlineApiKeyForm
+ form={apiKeyForm}
+ providerName={provider.name}
+ onSubmit={onApiKeySubmit}
+ />
+ ) : method === AuthType.device_code ? (
+ <DeviceAuthConnectButton
+ provider={provider.id}
+ providerName={provider.name}
+ onSuccess={onInlineConnectSuccess}
+ />
+ ) : method === AuthType.host_scoped ? (
+ <InlineHostScopedForm
+ provider={provider.id}
+ host={hostScopedHost}
+ onSuccess={onInlineConnectSuccess}
+ />
+ ) : method === AuthType.user_password ? (
+ <InlineUserPasswordForm
+ provider={provider.id}
+ providerName={provider.name}
+ onSuccess={onInlineConnectSuccess}
+ />
+ ) : (
+ <UnsupportedNotice providerName={provider.name} />
+ )}
+ </div>
+ </m.div>
+ )}
+ </AnimatePresence>
+ </div>
+ );
+ })}
+ </div>
+ {offersMcp ? (
+ <Button variant="ghost" size="small" onClick={handleUseSignIn}>
+ {getSignInFallbackLabel(provider)}
+ </Button>
+ ) : null}
+ </div>
+ )}
</div>
</LazyMotion>
);
diff --git a/autogpt_platform/frontend/src/components/contextual/IntegrationsPanel/components/ConnectServiceDialog/components/DetailView/DetailView.tsx b/autogpt_platform/frontend/src/components/contextual/IntegrationsPanel/components/ConnectServiceDialog/components/DetailView/DetailView.tsx
index 875d4a069e..928b126b4c 100644
--- a/autogpt_platform/frontend/src/components/contextual/IntegrationsPanel/components/ConnectServiceDialog/components/DetailView/DetailView.tsx
+++ b/autogpt_platform/frontend/src/components/contextual/IntegrationsPanel/components/ConnectServiceDialog/components/DetailView/DetailView.tsx
@@ -1,5 +1,6 @@
"use client";
import { motion, useReducedMotion } from "framer-motion";
+import { useState } from "react";
import type { CredentialsMetaResponse } from "@/app/api/__generated__/models/credentialsMetaResponse";
import { Button } from "@/components/atoms/Button/Button";
@@ -11,9 +12,15 @@ import {
TabsLineTrigger,
} from "@/components/molecules/TabsLine/TabsLine";
-import { AuthType, ConnectableProvider, type AuthMethod } from "../../helpers";
+import {
+ AuthType,
+ ConnectableProvider,
+ getSignInFallbackLabel,
+ opensOnNativeMethods,
+ type AuthMethod,
+} from "../../helpers";
import { McpConnectPanel } from "./McpConnectPanel";
-import { MCPPresetPanel } from "./MCPPresetPanel";
+import { McpFirstPanel } from "./McpFirstPanel";
import { getAuthMethodLabel, MethodPanel } from "./MethodPanel";
import { ProviderAvatar } from "./ProviderAvatar";
import { UnsupportedNotice } from "./UnsupportedNotice";
@@ -26,6 +33,7 @@ interface Props {
provider: ConnectableProvider;
onBack: () => void;
onSuccess: (credential?: CredentialsMetaResponse) => void;
+ preferMcp?: boolean;
}
const TAB_PRIORITY: AuthMethod[] = [
@@ -43,7 +51,12 @@ const lastTabByProvider = new Map<string, AuthMethod>();
// Standard product-UI ease-out — keep transitions under Emil's 300ms ceiling.
const PANEL_TRANSITION = { duration: 0.18, ease: [0, 0, 0.2, 1] as const };
-export function DetailView({ provider, onBack, onSuccess }: Props) {
+export function DetailView({
+ provider,
+ onBack,
+ onSuccess,
+ preferMcp = false,
+}: Props) {
const description = provider.description;
const reduceMotion = useReducedMotion();
const tabs = TAB_PRIORITY.filter((method) =>
@@ -53,6 +66,9 @@ export function DetailView({ provider, onBack, onSuccess }: Props) {
const remembered = lastTabByProvider.get(provider.id);
const defaultTab =
remembered && tabs.includes(remembered) ? remembered : tabs[0];
+ const [showNative, setShowNative] = useState(
+ opensOnNativeMethods(preferMcp, tabs.length),
+ );
return (
<div className="flex flex-col gap-5 pl-1">
@@ -68,10 +84,7 @@ export function DetailView({ provider, onBack, onSuccess }: Props) {
<Icon icon={ArrowLeft02Icon} size={18} />
</Button>
<ProviderAvatar
- id={
- provider.mcpServer?.icon_id ??
- (provider.mcpServer ? "mcp" : provider.id)
- }
+ id={provider.iconId ?? provider.id}
name={provider.name}
/>
<div className="flex min-w-0 flex-col gap-1">
@@ -86,53 +99,72 @@ export function DetailView({ provider, onBack, onSuccess }: Props) {
</div>
</div>
- {provider.mcpServer ? (
- <MCPPresetPanel server={provider.mcpServer} onSuccess={onSuccess} />
+ {provider.mcpServer && !showNative ? (
+ <McpFirstPanel
+ server={provider.mcpServer}
+ nativeMethods={tabs}
+ onUseNative={() => setShowNative(true)}
+ onSuccess={onSuccess}
+ />
) : provider.id === MCP_PROVIDER_ID ? (
<McpConnectPanel onSuccess={onSuccess} />
) : tabs.length === 0 ? (
<UnsupportedNotice providerName={provider.name} />
- ) : tabs.length === 1 ? (
- <MethodPanel
- method={tabs[0]}
- provider={provider}
- onSuccess={onSuccess}
- />
) : (
- <TabsLine
- defaultValue={defaultTab}
- onValueChange={(value) => {
- const next = value as AuthMethod;
- if (tabs.includes(next)) lastTabByProvider.set(provider.id, next);
- }}
- >
- <TabsLineList>
- {tabs.map((method) => (
- <TabsLineTrigger key={method} value={method}>
- {getAuthMethodLabel(provider, method)}
- </TabsLineTrigger>
- ))}
- </TabsLineList>
- {tabs.map((method) => (
- <TabsLineContent key={method} value={method}>
- <motion.div
- initial={
- reduceMotion
- ? { opacity: 0 }
- : { opacity: 0, x: 6, filter: "blur(2px)" }
- }
- animate={{ opacity: 1, x: 0, filter: "blur(0px)" }}
- transition={PANEL_TRANSITION}
- >
- <MethodPanel
- method={method}
- provider={provider}
- onSuccess={onSuccess}
- />
- </motion.div>
- </TabsLineContent>
- ))}
- </TabsLine>
+ <div className="flex flex-col gap-4">
+ {tabs.length === 1 ? (
+ <MethodPanel
+ method={tabs[0]}
+ provider={provider}
+ onSuccess={onSuccess}
+ />
+ ) : (
+ <TabsLine
+ defaultValue={defaultTab}
+ onValueChange={(value) => {
+ const next = value as AuthMethod;
+ if (tabs.includes(next))
+ lastTabByProvider.set(provider.id, next);
+ }}
+ >
+ <TabsLineList>
+ {tabs.map((method) => (
+ <TabsLineTrigger key={method} value={method}>
+ {getAuthMethodLabel(provider, method)}
+ </TabsLineTrigger>
+ ))}
+ </TabsLineList>
+ {tabs.map((method) => (
+ <TabsLineContent key={method} value={method}>
+ <motion.div
+ initial={
+ reduceMotion
+ ? { opacity: 0 }
+ : { opacity: 0, x: 6, filter: "blur(2px)" }
+ }
+ animate={{ opacity: 1, x: 0, filter: "blur(0px)" }}
+ transition={PANEL_TRANSITION}
+ >
+ <MethodPanel
+ method={method}
+ provider={provider}
+ onSuccess={onSuccess}
+ />
+ </motion.div>
+ </TabsLineContent>
+ ))}
+ </TabsLine>
+ )}
+ {provider.mcpServer ? (
+ <Button
+ variant="ghost"
+ size="small"
+ onClick={() => setShowNative(false)}
+ >
+ {getSignInFallbackLabel(provider)}
+ </Button>
+ ) : null}
+ </div>
)}
</div>
);
diff --git a/autogpt_platform/frontend/src/components/contextual/IntegrationsPanel/components/ConnectServiceDialog/components/DetailView/MCPPresetPanel.tsx b/autogpt_platform/frontend/src/components/contextual/IntegrationsPanel/components/ConnectServiceDialog/components/DetailView/MCPPresetPanel.tsx
index e97cf49e2b..51a37de56f 100644
--- a/autogpt_platform/frontend/src/components/contextual/IntegrationsPanel/components/ConnectServiceDialog/components/DetailView/MCPPresetPanel.tsx
+++ b/autogpt_platform/frontend/src/components/contextual/IntegrationsPanel/components/ConnectServiceDialog/components/DetailView/MCPPresetPanel.tsx
@@ -4,6 +4,7 @@ import type { CredentialsMetaResponse } from "@/app/api/__generated__/models/cre
import type { ProviderMetadata } from "@/app/api/__generated__/models/providerMetadata";
import { Link } from "@/components/atoms/Link/Link";
import { Text } from "@/components/atoms/Text/Text";
+import type { ReactNode } from "react";
import {
TabsLine,
TabsLineList,
@@ -27,9 +28,11 @@ const METHOD_LABELS: Record<AuthMethod, string> = {
interface Props {
server: NonNullable<ProviderMetadata["mcp_server"]>;
onSuccess: (credential?: CredentialsMetaResponse) => void;
+ /** Extra buttons for the row that holds Connect. */
+ actions?: ReactNode;
}
-export function MCPPresetPanel({ server, onSuccess }: Props) {
+export function MCPPresetPanel({ server, onSuccess, actions }: Props) {
const methods = server.auth_methods;
return (
<div className="flex flex-col gap-4">
@@ -44,6 +47,7 @@ export function MCPPresetPanel({ server, onSuccess }: Props) {
server={server}
onSuccess={onSuccess}
method={methods[0]}
+ actions={actions}
/>
) : (
<TabsLine defaultValue={methods[0]}>
@@ -60,6 +64,7 @@ export function MCPPresetPanel({ server, onSuccess }: Props) {
server={server}
onSuccess={onSuccess}
method={method}
+ actions={actions}
/>
</TabsLineContent>
))}
@@ -73,10 +78,11 @@ function PresetMethod({
server,
onSuccess,
method,
+ actions,
}: Props & { method: AuthMethod }) {
if (method === "none") {
return server.server_url ? (
- <PublicMCPPanel serverURL={server.server_url} />
+ <PublicMCPPanel serverURL={server.server_url} actions={actions} />
) : null;
}
return (
@@ -94,6 +100,7 @@ function PresetMethod({
oauthScopes={server.oauth_scopes}
oauthWriteScopes={server.oauth_write_scopes}
serverURLOptions={server.server_url_options}
+ actions={actions}
/>
);
}
diff --git a/autogpt_platform/frontend/src/components/contextual/IntegrationsPanel/components/ConnectServiceDialog/components/DetailView/McpConnectPanel.tsx b/autogpt_platform/frontend/src/components/contextual/IntegrationsPanel/components/ConnectServiceDialog/components/DetailView/McpConnectPanel.tsx
index 4f2a27e775..0edd4af220 100644
--- a/autogpt_platform/frontend/src/components/contextual/IntegrationsPanel/components/ConnectServiceDialog/components/DetailView/McpConnectPanel.tsx
+++ b/autogpt_platform/frontend/src/components/contextual/IntegrationsPanel/components/ConnectServiceDialog/components/DetailView/McpConnectPanel.tsx
@@ -3,6 +3,7 @@
import type { CredentialsMetaResponse } from "@/app/api/__generated__/models/credentialsMetaResponse";
import { Button } from "@/components/atoms/Button/Button";
import { Input } from "@/components/atoms/Input/Input";
+import { Switch } from "@/components/atoms/Switch/Switch";
import { Text } from "@/components/atoms/Text/Text";
import { MCPAuthSchemeField } from "@/components/contextual/MCPAuthSchemeField/MCPAuthSchemeField";
import {
@@ -13,8 +14,8 @@ import {
import { useMCPConnectPanel } from "./useMCPConnectPanel";
import type { MCPAuthScheme } from "@/lib/mcp-auth";
import { MCPServerURLField } from "./MCPServerURLField";
-import { MultiToggle } from "@/components/molecules/MultiToggle/MultiToggle";
import { noPasswordManager } from "./helpers";
+import type { ReactNode } from "react";
interface Props {
onSuccess: (credential?: CredentialsMetaResponse) => void;
@@ -24,6 +25,8 @@ interface Props {
oauthScopes?: string[] | null;
oauthWriteScopes?: string[];
serverURLOptions?: { label: string; url: string }[];
+ /** Extra buttons for the row that holds Connect. */
+ actions?: ReactNode;
}
export function McpConnectPanel({
@@ -34,6 +37,7 @@ export function McpConnectPanel({
oauthScopes,
oauthWriteScopes = [],
serverURLOptions,
+ actions,
}: Props) {
const state = useMCPConnectPanel({
onSuccess,
@@ -58,17 +62,22 @@ export function McpConnectPanel({
options={serverURLOptions}
/>
{state.phase === "form" && oauthWriteScopes.length > 0 && (
- <MultiToggle
- items={[
- {
- value: "write",
- label: "Allow changes",
- disabled: state.isSubmitting,
- },
- ]}
- selectedValues={state.allowChanges ? ["write"] : []}
- onChange={(values) => state.setAllowChanges(values.includes("write"))}
- />
+ <label className="flex cursor-pointer items-start gap-3">
+ <Switch
+ checked={state.allowChanges}
+ onCheckedChange={state.setAllowChanges}
+ disabled={state.isSubmitting}
+ className="mt-0.5"
+ />
+ <span className="flex flex-col">
+ <Text variant="body-medium" as="span">
+ Allow changes
+ </Text>
+ <Text variant="small" as="span" tone="muted">
+ Without this it can only read, not create or edit.
+ </Text>
+ </span>
+ </label>
)}
{state.phase === "manual-token" && (
<>
@@ -111,6 +120,7 @@ export function McpConnectPanel({
</div>
)}
<div className="flex items-center justify-end gap-2">
+ {actions}
{state.phase === "form" && state.manualSchemes.length > 0 && (
<Button
variant="secondary"
diff --git a/autogpt_platform/frontend/src/components/contextual/IntegrationsPanel/components/ConnectServiceDialog/components/DetailView/McpFirstPanel.tsx b/autogpt_platform/frontend/src/components/contextual/IntegrationsPanel/components/ConnectServiceDialog/components/DetailView/McpFirstPanel.tsx
new file mode 100644
index 0000000000..0f31f44713
--- /dev/null
+++ b/autogpt_platform/frontend/src/components/contextual/IntegrationsPanel/components/ConnectServiceDialog/components/DetailView/McpFirstPanel.tsx
@@ -0,0 +1,55 @@
+"use client";
+
+import type { CredentialsMetaResponse } from "@/app/api/__generated__/models/credentialsMetaResponse";
+import type { ProviderMetadata } from "@/app/api/__generated__/models/providerMetadata";
+import { Button } from "@/components/atoms/Button/Button";
+import { MoreHorizontalCircle01Icon } from "@hugeicons/core-free-icons";
+import { withoutDuplicateKeyMethod, type AuthMethod } from "../../helpers";
+import { MCPPresetPanel } from "./MCPPresetPanel";
+
+interface Props {
+ server: NonNullable<ProviderMetadata["mcp_server"]>;
+ /** The vendor's block credential methods, if it also ships any. */
+ nativeMethods: AuthMethod[];
+ onUseNative: () => void;
+ onSuccess: (credential?: CredentialsMetaResponse) => void;
+ /** Puts a Back button beside Connect, for hosts without a header arrow. */
+ onBack?: () => void;
+}
+
+/** The service's own sign-in, shown first, with the block credential one
+ * click away when the vendor also ships one. */
+export function McpFirstPanel({
+ server,
+ nativeMethods,
+ onUseNative,
+ onSuccess,
+ onBack,
+}: Props) {
+ return (
+ <MCPPresetPanel
+ server={withoutDuplicateKeyMethod(server, nativeMethods)}
+ onSuccess={onSuccess}
+ actions={
+ <>
+ {nativeMethods.length > 0 ? (
+ <Button
+ variant="ghost"
+ size="small"
+ className="mr-auto"
+ leadingIcon={MoreHorizontalCircle01Icon}
+ onClick={onUseNative}
+ >
+ More ways to connect
+ </Button>
+ ) : null}
+ {onBack ? (
+ <Button variant="secondary" size="small" onClick={onBack}>
+ Back
+ </Button>
+ ) : null}
+ </>
+ }
+ />
+ );
+}
diff --git a/autogpt_platform/frontend/src/components/contextual/IntegrationsPanel/components/ConnectServiceDialog/components/DetailView/PublicMCPPanel.tsx b/autogpt_platform/frontend/src/components/contextual/IntegrationsPanel/components/ConnectServiceDialog/components/DetailView/PublicMCPPanel.tsx
index a7ca788b00..3c80f77f65 100644
--- a/autogpt_platform/frontend/src/components/contextual/IntegrationsPanel/components/ConnectServiceDialog/components/DetailView/PublicMCPPanel.tsx
+++ b/autogpt_platform/frontend/src/components/contextual/IntegrationsPanel/components/ConnectServiceDialog/components/DetailView/PublicMCPPanel.tsx
@@ -3,13 +3,15 @@
import { Button } from "@/components/atoms/Button/Button";
import { Input } from "@/components/atoms/Input/Input";
import { Text } from "@/components/atoms/Text/Text";
+import type { ReactNode } from "react";
import { useCheckMCPConnection } from "./useCheckMCPConnection";
interface Props {
serverURL: string;
+ actions?: ReactNode;
}
-export function PublicMCPPanel({ serverURL }: Props) {
+export function PublicMCPPanel({ serverURL, actions }: Props) {
const { check, isPending, toolCount, error } =
useCheckMCPConnection(serverURL);
return (
@@ -33,8 +35,8 @@ export function PublicMCPPanel({ serverURL }: Props) {
)}
{toolCount !== null && (
<Text variant="small" className="text-zinc-600">
- No connection was saved. Use this server URL when adding MCP tools to
- an agent.
+ This service needs no sign-in, so nothing was saved. Add it to an
+ agent or ask an expert to use it.
</Text>
)}
{error && (
@@ -42,14 +44,17 @@ export function PublicMCPPanel({ serverURL }: Props) {
{error}
</Text>
)}
- <Button
- variant="primary"
- size="small"
- onClick={check}
- loading={isPending}
- >
- Check connection
- </Button>
+ <div className="flex items-center justify-end gap-2">
+ {actions}
+ <Button
+ variant="primary"
+ size="small"
+ onClick={check}
+ loading={isPending}
+ >
+ Check connection
+ </Button>
+ </div>
</div>
);
}
diff --git a/autogpt_platform/frontend/src/components/contextual/IntegrationsPanel/components/ConnectServiceDialog/components/DetailView/__tests__/MethodPanel.test.tsx b/autogpt_platform/frontend/src/components/contextual/IntegrationsPanel/components/ConnectServiceDialog/components/DetailView/__tests__/MethodPanel.test.tsx
index c3045a1b95..232e0c82dd 100644
--- a/autogpt_platform/frontend/src/components/contextual/IntegrationsPanel/components/ConnectServiceDialog/components/DetailView/__tests__/MethodPanel.test.tsx
+++ b/autogpt_platform/frontend/src/components/contextual/IntegrationsPanel/components/ConnectServiceDialog/components/DetailView/__tests__/MethodPanel.test.tsx
@@ -14,6 +14,7 @@ vi.mock("../useOAuthConnect", () => ({
const openaiProvider: ConnectableProvider = {
id: "openai",
+ serviceId: "openai",
name: "OpenAI",
description: "OpenAI models via API key or your ChatGPT subscription",
supportedAuthTypes: [AuthType.oauth2, AuthType.api_key],
@@ -131,6 +132,7 @@ describe("MethodPanel", () => {
method={AuthType.oauth2}
provider={{
id: "notion",
+ serviceId: "notion",
name: "Notion",
description: "Notion",
supportedAuthTypes: [AuthType.oauth2],
diff --git a/autogpt_platform/frontend/src/components/contextual/IntegrationsPanel/components/ConnectServiceDialog/components/ListView.tsx b/autogpt_platform/frontend/src/components/contextual/IntegrationsPanel/components/ConnectServiceDialog/components/ListView.tsx
index 8e62b130bb..05a7c4461e 100644
--- a/autogpt_platform/frontend/src/components/contextual/IntegrationsPanel/components/ConnectServiceDialog/components/ListView.tsx
+++ b/autogpt_platform/frontend/src/components/contextual/IntegrationsPanel/components/ConnectServiceDialog/components/ListView.tsx
@@ -56,7 +56,9 @@ export function ListView({
</div>
) : (
<div className="relative">
- <ScrollArea className="h-[380px] pr-2">
+ {/* Radix wraps the list in a `display: table` div that grows to fit
+ each row's full description, pushing cards past the edge. */}
+ <ScrollArea className="h-[380px] pr-2 [&_[data-radix-scroll-area-viewport]>div]:!block">
<ul className="flex flex-col gap-2 pb-4">
{providers.map((provider) => (
<li key={provider.id}>
diff --git a/autogpt_platform/frontend/src/components/contextual/IntegrationsPanel/components/ConnectServiceDialog/components/ProviderRow.tsx b/autogpt_platform/frontend/src/components/contextual/IntegrationsPanel/components/ConnectServiceDialog/components/ProviderRow.tsx
index f8792fecd5..a3783181ea 100644
--- a/autogpt_platform/frontend/src/components/contextual/IntegrationsPanel/components/ConnectServiceDialog/components/ProviderRow.tsx
+++ b/autogpt_platform/frontend/src/components/contextual/IntegrationsPanel/components/ConnectServiceDialog/components/ProviderRow.tsx
@@ -14,9 +14,7 @@ interface Props {
}
export function ProviderRow({ provider, onSelect }: Props) {
- const src = integrationIconSrc(
- provider.mcpServer?.icon_id ?? (provider.mcpServer ? "mcp" : provider.id),
- );
+ const src = integrationIconSrc(provider.iconId ?? provider.id);
const [brokenSrc, setBrokenSrc] = useState<string | null>(null);
return (
@@ -46,11 +44,6 @@ export function ProviderRow({ provider, onSelect }: Props) {
<span className="flex min-w-0 flex-1 flex-col gap-0.5">
<span className="flex flex-wrap items-center gap-x-2 gap-y-1 text-[14px] font-medium leading-[22px] text-zinc-800">
<span>{provider.name}</span>
- {provider.mcpServer && (
- <Badge variant="info" size="small">
- MCP
- </Badge>
- )}
{provider.mcpServer &&
provider.mcpServer.connection_mode !== "hosted" && (
<Badge variant="warning" size="small">
diff --git a/autogpt_platform/frontend/src/components/contextual/IntegrationsPanel/components/ConnectServiceDialog/helpers.ts b/autogpt_platform/frontend/src/components/contextual/IntegrationsPanel/components/ConnectServiceDialog/helpers.ts
index 77eaa6e785..c02a1b31c9 100644
--- a/autogpt_platform/frontend/src/components/contextual/IntegrationsPanel/components/ConnectServiceDialog/helpers.ts
+++ b/autogpt_platform/frontend/src/components/contextual/IntegrationsPanel/components/ConnectServiceDialog/helpers.ts
@@ -1,7 +1,7 @@
import type { ProviderMetadata } from "@/app/api/__generated__/models/providerMetadata";
import { ProviderMetadataSupportedAuthTypesItem as AuthType } from "@/app/api/__generated__/models/providerMetadataSupportedAuthTypesItem";
-import { formatProviderName } from "../../helpers";
+import { serviceIcon, serviceKey, serviceName } from "../../helpers";
export type AuthMethod = (typeof AuthType)[keyof typeof AuthType];
@@ -9,12 +9,14 @@ export { AuthType };
export interface ConnectableProvider {
id: string;
+ serviceId: string;
name: string;
description?: string | null;
supportedAuthTypes: AuthMethod[];
authProviderByType?: Partial<Record<AuthMethod, string>>;
searchTerms?: string[];
mcpServer?: ProviderMetadata["mcp_server"];
+ iconId?: string;
}
const KNOWN_AUTH_METHODS: ReadonlySet<AuthMethod> = new Set(
@@ -28,31 +30,80 @@ function normalizeAuthTypes(
return raw.filter((t) => KNOWN_AUTH_METHODS.has(t));
}
+export function opensOnNativeMethods(
+ preferMcp: boolean,
+ nativeMethodCount: number,
+): boolean {
+ if (nativeMethodCount === 0) return false;
+ return !preferMcp;
+}
+
+// A vendor's MCP token and its block API key are the same key, so when the
+// block takes one the server's token method is dropped and the key is asked
+// for once.
+export function withoutDuplicateKeyMethod(
+ server: NonNullable<ProviderMetadata["mcp_server"]>,
+ nativeMethods: readonly AuthMethod[],
+): NonNullable<ProviderMetadata["mcp_server"]> {
+ if (!nativeMethods.includes(AuthType.api_key)) return server;
+ const authMethods = server.auth_methods.filter(
+ (method) => method !== "bearer",
+ );
+ return authMethods.length ? { ...server, auth_methods: authMethods } : server;
+}
+
+export function getSignInFallbackLabel(provider: ConnectableProvider): string {
+ if (provider.mcpServer?.auth_methods.includes("oauth")) {
+ return `Use the ${provider.name} sign-in instead`;
+ }
+ const article = /^[aeiou]/i.test(provider.name) ? "an" : "a";
+ return `Use ${article} ${provider.name} token instead`;
+}
+
export function toConnectableProviders(
metadata: ProviderMetadata[],
): ConnectableProvider[] {
const seen = new Set<string>();
- const byDisplayProvider = new Map<string, ConnectableProvider>();
+ const byService = new Map<string, ConnectableProvider>();
for (const item of metadata) {
if (seen.has(item.name)) continue;
seen.add(item.name);
const displayProvider = item.name === "codex" ? "openai" : item.name;
+ const ref = {
+ provider: item.name,
+ service: item.service,
+ service_name: item.service_name,
+ service_icon: item.service_icon,
+ };
+ const key = serviceKey(ref);
const authTypes = normalizeAuthTypes(item.supported_auth_types);
- const existing = byDisplayProvider.get(displayProvider);
- const provider = existing ?? {
- id: displayProvider,
- name: item.display_name ?? formatProviderName(displayProvider),
+ const existing = byService.get(key);
+ const provider: ConnectableProvider = existing ?? {
+ id: item.mcp_server ? item.name : displayProvider,
+ serviceId: key,
+ name: serviceName(ref),
description: item.description,
supportedAuthTypes: [],
+ iconId: serviceIcon(ref),
};
- if (item.mcp_server) provider.mcpServer = item.mcp_server;
+ if (item.mcp_server) {
+ provider.mcpServer = item.mcp_server;
+ if (existing) {
+ provider.searchTerms = Array.from(
+ new Set([...(provider.searchTerms ?? []), item.name]),
+ );
+ }
+ } else if (existing?.mcpServer && provider.id !== displayProvider) {
+ provider.searchTerms = Array.from(
+ new Set([...(provider.searchTerms ?? []), provider.id]),
+ );
+ provider.id = displayProvider;
+ }
for (const authType of authTypes) {
const alreadySupported = provider.supportedAuthTypes.includes(authType);
- if (!alreadySupported) {
- provider.supportedAuthTypes.push(authType);
- }
+ if (!alreadySupported) provider.supportedAuthTypes.push(authType);
if (item.name === displayProvider) {
delete provider.authProviderByType?.[authType];
} else if (!alreadySupported) {
@@ -62,24 +113,24 @@ export function toConnectableProviders(
};
}
}
- if (item.name !== displayProvider) {
+ if (item.name !== displayProvider && !item.mcp_server) {
provider.searchTerms = Array.from(
new Set([...(provider.searchTerms ?? []), item.name]),
);
}
- if (item.name === displayProvider) {
+ if (item.name === displayProvider && !item.mcp_server) {
provider.description = item.description;
}
- byDisplayProvider.set(displayProvider, provider);
+ byService.set(key, provider);
}
- const openai = byDisplayProvider.get("openai");
+ const openai = byService.get("openai");
if (openai?.authProviderByType?.oauth2 === "codex") {
openai.description =
"OpenAI models via API key or your ChatGPT subscription";
}
- const result = Array.from(byDisplayProvider.values());
+ const result = Array.from(byService.values());
result.sort((a, b) => a.name.localeCompare(b.name));
return result;
}
diff --git a/autogpt_platform/frontend/src/components/contextual/IntegrationsPanel/components/CredentialRow/CredentialRow.tsx b/autogpt_platform/frontend/src/components/contextual/IntegrationsPanel/components/CredentialRow/CredentialRow.tsx
index 3570d55c2e..00762f9d96 100644
--- a/autogpt_platform/frontend/src/components/contextual/IntegrationsPanel/components/CredentialRow/CredentialRow.tsx
+++ b/autogpt_platform/frontend/src/components/contextual/IntegrationsPanel/components/CredentialRow/CredentialRow.tsx
@@ -69,12 +69,14 @@ export function CredentialRow({
{credential.title}
</span>
<span className="inline-flex items-center justify-center rounded-[10px] bg-[#EFF1F4] px-2 py-[2px] text-[12px] font-medium leading-[20px] text-[#505057]">
- {typeBadgeLabel(credential.type)}
+ {credential.isSignIn
+ ? "For chats"
+ : typeBadgeLabel(credential.type)}
</span>
</div>
<div className="flex items-center gap-3 leading-[20px]">
<span className="text-[11px] font-medium uppercase tracking-[1.1px] text-[#505057]">
- {formatMaskedValue(credential)}
+ {credential.blocksNote ?? formatMaskedValue(credential)}
</span>
</div>
</div>
diff --git a/autogpt_platform/frontend/src/components/contextual/IntegrationsPanel/components/IntegrationsList/IntegrationsList.tsx b/autogpt_platform/frontend/src/components/contextual/IntegrationsPanel/components/IntegrationsList/IntegrationsList.tsx
index 2c0d3e2baa..eb1b437fae 100644
--- a/autogpt_platform/frontend/src/components/contextual/IntegrationsPanel/components/IntegrationsList/IntegrationsList.tsx
+++ b/autogpt_platform/frontend/src/components/contextual/IntegrationsPanel/components/IntegrationsList/IntegrationsList.tsx
@@ -5,6 +5,7 @@ import { AnimatePresence, motion, useReducedMotion } from "framer-motion";
import type { Variants } from "framer-motion";
import { ErrorCard } from "@/components/molecules/ErrorCard/ErrorCard";
+import { cn } from "@/lib/utils";
import { DeleteConfirmDialog } from "../DeleteConfirmDialog/DeleteConfirmDialog";
import { IntegrationsListEmpty } from "../IntegrationsListEmpty/IntegrationsListEmpty";
@@ -38,9 +39,15 @@ const REDUCED_MOTION_ITEM_VARIANTS: Variants = {
interface Props {
query: string;
onQueryChange: (query: string) => void;
+ /** Background for the sticky rows; it must match the surface below. */
+ stickyClassName: string;
}
-export function IntegrationsList({ query, onQueryChange: setQuery }: Props) {
+export function IntegrationsList({
+ query,
+ onQueryChange: setQuery,
+ stickyClassName,
+}: Props) {
const {
providers,
isLoading,
@@ -116,7 +123,12 @@ export function IntegrationsList({ query, onQueryChange: setQuery }: Props) {
return (
<div className="flex w-full flex-col gap-3">
- <div className="sticky top-0 z-10 -mx-1 bg-[#F9F9FA] px-1 pb-1 pt-1">
+ <div
+ className={cn(
+ "sticky top-0 z-10 -mx-1 px-1 pb-1 pt-1",
+ stickyClassName,
+ )}
+ >
<IntegrationsSearch value={query} onChange={setQuery} />
</div>
@@ -140,7 +152,7 @@ export function IntegrationsList({ query, onQueryChange: setQuery }: Props) {
: { opacity: 0, height: 0, marginBottom: -12 }
}
transition={{ duration: 0.2, ease: [0, 0, 0.2, 1] }}
- className="sticky top-2 z-20 bg-[#F9F9FA] sm:top-0"
+ className={cn("sticky top-2 z-20 sm:top-0", stickyClassName)}
style={{ overflow: "hidden" }}
>
<IntegrationsSelectionBar
diff --git a/autogpt_platform/frontend/src/components/contextual/IntegrationsPanel/components/IntegrationsList/useIntegrationsList.ts b/autogpt_platform/frontend/src/components/contextual/IntegrationsPanel/components/IntegrationsList/useIntegrationsList.ts
index 83535de41f..98b15ac0ca 100644
--- a/autogpt_platform/frontend/src/components/contextual/IntegrationsPanel/components/IntegrationsList/useIntegrationsList.ts
+++ b/autogpt_platform/frontend/src/components/contextual/IntegrationsPanel/components/IntegrationsList/useIntegrationsList.ts
@@ -1,9 +1,13 @@
"use client";
-import { useGetV1ListCredentials } from "@/app/api/__generated__/endpoints/integrations/integrations";
+import {
+ useGetV1ListCredentials,
+ useGetV1ListProviders,
+} from "@/app/api/__generated__/endpoints/integrations/integrations";
import { filterSystemCredentials } from "@/components/contextual/CredentialsInput/helpers";
import {
+ blockServiceKeys,
filterProviders,
groupCredentialsByProvider,
type ProviderGroupView,
@@ -25,9 +29,17 @@ export function useIntegrationsList(query: string) {
},
});
+ const providersQuery = useGetV1ListProviders({
+ query: {
+ select: (response) => (response.status === 200 ? response.data : []),
+ },
+ });
+
const credentials = credentialsQuery.data ?? [];
- const allProviders: ProviderGroupView[] =
- groupCredentialsByProvider(credentials);
+ const allProviders: ProviderGroupView[] = groupCredentialsByProvider(
+ credentials,
+ blockServiceKeys(providersQuery.data ?? []),
+ );
const providers = filterProviders(allProviders, debouncedQuery);
const allCredentialIds = allProviders.flatMap((p) =>
diff --git a/autogpt_platform/frontend/src/components/contextual/IntegrationsPanel/components/IntegrationsListEmpty/IntegrationsListEmpty.tsx b/autogpt_platform/frontend/src/components/contextual/IntegrationsPanel/components/IntegrationsListEmpty/IntegrationsListEmpty.tsx
index 5b78864b73..24c9e37200 100644
--- a/autogpt_platform/frontend/src/components/contextual/IntegrationsPanel/components/IntegrationsListEmpty/IntegrationsListEmpty.tsx
+++ b/autogpt_platform/frontend/src/components/contextual/IntegrationsPanel/components/IntegrationsListEmpty/IntegrationsListEmpty.tsx
@@ -8,19 +8,28 @@ interface Props {
}
export function IntegrationsListEmpty({ query }: Props) {
- const hasQuery = query.trim().length > 0;
+ const trimmed = query.trim();
+
+ // A search usually lands in Available integrations below, so a miss here
+ // is one quiet line rather than the full empty state.
+ if (trimmed) {
+ return (
+ <Text variant="body" className="px-4 text-zinc-500">
+ {`None of your connected integrations match "${trimmed}".`}
+ </Text>
+ );
+ }
return (
<div className="flex flex-col items-center justify-center gap-4 px-6 py-10 text-center">
<IntegrationsMarquee />
<div className="flex flex-col items-center gap-1">
<Text variant="large-medium" as="span" className="text-textBlack">
- {hasQuery ? "No integrations found" : "No integration connected"}
+ No integration connected
</Text>
<Text variant="body" className="max-w-[360px] text-zinc-500">
- {hasQuery
- ? `No integrations match "${query.trim()}". Try a different search.`
- : "Connect a service to let your agents use third-party tools like GitHub, Gmail, or Figma."}
+ Connect a service to let your agents use third-party tools like
+ GitHub, Gmail, or Figma.
</Text>
</div>
</div>
diff --git a/autogpt_platform/frontend/src/components/contextual/IntegrationsPanel/components/IntegrationsListEmpty/__tests__/IntegrationsListEmpty.test.tsx b/autogpt_platform/frontend/src/components/contextual/IntegrationsPanel/components/IntegrationsListEmpty/__tests__/IntegrationsListEmpty.test.tsx
index c38f088b31..d1f986b975 100644
--- a/autogpt_platform/frontend/src/components/contextual/IntegrationsPanel/components/IntegrationsListEmpty/__tests__/IntegrationsListEmpty.test.tsx
+++ b/autogpt_platform/frontend/src/components/contextual/IntegrationsPanel/components/IntegrationsListEmpty/__tests__/IntegrationsListEmpty.test.tsx
@@ -20,11 +20,11 @@ describe("IntegrationsListEmpty", () => {
expect(screen.getByText("No integration connected")).toBeDefined();
});
- test("renders no-results copy and echoes the trimmed query", () => {
+ test("renders a one-line miss that echoes the trimmed query", () => {
render(<IntegrationsListEmpty query=" notion " />);
- expect(screen.getByText("No integrations found")).toBeDefined();
expect(
- screen.getByText(/No integrations match "notion"\. Try a different/i),
+ screen.getByText('None of your connected integrations match "notion".'),
).toBeDefined();
+ expect(screen.queryByText("No integration connected")).toBeNull();
});
});
diff --git a/autogpt_platform/frontend/src/components/contextual/IntegrationsPanel/helpers.ts b/autogpt_platform/frontend/src/components/contextual/IntegrationsPanel/helpers.ts
index 83fa89d03f..d14d40b5e7 100644
--- a/autogpt_platform/frontend/src/components/contextual/IntegrationsPanel/helpers.ts
+++ b/autogpt_platform/frontend/src/components/contextual/IntegrationsPanel/helpers.ts
@@ -1,5 +1,7 @@
+import type { ProviderMetadata } from "@/app/api/__generated__/models/providerMetadata";
import type { CredentialsMetaResponse } from "@/app/api/__generated__/models/credentialsMetaResponse";
import { CredentialsMetaResponseType } from "@/app/api/__generated__/models/credentialsMetaResponseType";
+import { integrationIconSrc } from "@/components/molecules/IntegrationLogo/helpers";
export type CredentialType = CredentialsMetaResponseType;
@@ -11,6 +13,10 @@ export interface CredentialView {
username: string | null;
host: string | null;
isManaged: boolean;
+ /** A vendor sign-in (MCP) rather than a block credential. */
+ isSignIn: boolean;
+ /** Set when the vendor also has blocks, which this sign-in does not cover. */
+ blocksNote: string | null;
}
export interface ProviderGroupView {
@@ -46,7 +52,6 @@ const PROVIDER_DISPLAY_NAME_OVERRIDES: Record<string, string> = {
ideogram: "Ideogram",
jina: "Jina",
linkedin: "LinkedIn",
- mcp: "MCP",
twitter: "X",
zerobounce: "ZeroBounce",
};
@@ -63,6 +68,40 @@ export function formatProviderName(slug: unknown): string {
.join(" ");
}
+export interface ServiceRef {
+ provider: string;
+ service?: string;
+ service_name?: string | null;
+ service_icon?: string | null;
+}
+
+// The backend names the service behind every credential and provider; these
+// read it with the one display alias the backend does not know about.
+export function serviceKey(ref: ServiceRef): string {
+ const key = ref.service || ref.provider;
+ return key === "codex" ? "openai" : key;
+}
+
+export function serviceName(ref: ServiceRef): string {
+ return ref.service_name || formatProviderName(serviceKey(ref));
+}
+
+export function serviceIcon(ref: ServiceRef): string {
+ return ref.service_icon || serviceKey(ref);
+}
+
+export function groupServiceIdentity(refs: ServiceRef[]) {
+ const named = refs.find((ref) => ref.service_name) ?? refs[0];
+ const withIcon = refs.find((ref) => ref.service_icon) ?? refs[0];
+ return { name: serviceName(named), icon: serviceIcon(withIcon) };
+}
+
+export function serviceLabelFromIcon(id: string): string {
+ return id.startsWith("mcp:")
+ ? id.slice("mcp:".length)
+ : formatProviderName(id);
+}
+
export function formatMaskedValue(credential: CredentialView): string {
if (credential.username) return `Username: ${credential.username}`;
if (credential.host) return credential.host;
@@ -85,51 +124,19 @@ export function stripProviderPrefix(title: string, provider: string): string {
: title;
}
-const MCP_PROVIDER = "mcp";
-
-// Labels that route the request rather than name the service behind it.
-const MCP_HOST_NOISE = new Set(["mcp", "api", "www", "server"]);
-
-function toHostname(value: string): string | null {
- try {
- const url = new URL(value.includes("://") ? value : `https://${value}`);
- return url.hostname || null;
- } catch {
- return null;
- }
-}
-
-function mcpServiceName(value: string): string | null {
- const host = toHostname(value);
- if (!host) return null;
- // Drop the TLD, then the routing noise, so ``mcp.sentry.dev`` reads as the
- // service a person recognises rather than the URL we happen to call.
- const name = host
- .split(".")
- .filter(Boolean)
- .slice(0, -1)
- .find((label) => !MCP_HOST_NOISE.has(label));
- return name ? formatProviderName(name) : null;
-}
-
-// The credential's own name, said the way a person would. MCP credentials are
-// titled after the server URL, which is the one case where the stored title is
-// an address rather than a name.
export function formatCredentialName(title: string, provider: string): string {
- const stripped = stripProviderPrefix(title, provider);
- if (provider !== MCP_PROVIDER) return stripped;
- return mcpServiceName(stripped) ?? stripped;
+ return stripProviderPrefix(title, provider);
}
-// Where the credential comes from, for the line under its name.
-export function formatCredentialSource(provider: string): string {
- return provider === MCP_PROVIDER
- ? "MCP server"
- : formatProviderName(provider);
-}
+const SIGN_IN_PROVIDER = "mcp";
-function toCredentialView(cred: CredentialsMetaResponse): CredentialView {
- const rawTitle = cred.title ?? formatProviderName(cred.provider);
+function toCredentialView(
+ cred: CredentialsMetaResponse,
+ serviceLabel: string,
+ hasBlocks: boolean,
+): CredentialView {
+ const rawTitle = cred.title ?? serviceName(cred);
+ const isSignIn = cred.provider === SIGN_IN_PROVIDER;
return {
id: cred.id,
provider: cred.provider,
@@ -138,27 +145,46 @@ function toCredentialView(cred: CredentialsMetaResponse): CredentialView {
username: cred.username ?? null,
host: cred.host ?? null,
isManaged: cred.is_managed ?? false,
+ isSignIn,
+ blocksNote:
+ isSignIn && hasBlocks
+ ? `${serviceLabel} blocks in agents need their own connection.`
+ : null,
};
}
+// The services a block provider covers, so a sign-in for one of them can say
+// it does not connect those blocks.
+export function blockServiceKeys(providers: ProviderMetadata[]): Set<string> {
+ return new Set(
+ providers
+ .filter((item) => !item.mcp_server)
+ .map((item) =>
+ serviceKey({ provider: item.name, service: item.service }),
+ ),
+ );
+}
+
export function groupCredentialsByProvider(
credentials: CredentialsMetaResponse[],
+ blockServices: ReadonlySet<string> = new Set(),
): ProviderGroupView[] {
- const byProvider = new Map<string, CredentialView[]>();
+ const byService = new Map<string, CredentialsMetaResponse[]>();
for (const cred of credentials) {
- const displayProvider =
- cred.provider === "codex" ? "openai" : cred.provider;
- const list = byProvider.get(displayProvider) ?? [];
- list.push(toCredentialView(cred));
- byProvider.set(displayProvider, list);
+ const key = serviceKey(cred);
+ byService.set(key, [...(byService.get(key) ?? []), cred]);
}
const groups: ProviderGroupView[] = [];
- for (const [provider, creds] of byProvider) {
+ for (const [id, creds] of byService) {
+ const identity = groupServiceIdentity(creds);
groups.push({
- id: provider,
- name: formatProviderName(provider),
- credentials: creds,
+ id,
+ name: identity.name,
+ logoUrl: integrationIconSrc(identity.icon) ?? undefined,
+ credentials: creds.map((cred) =>
+ toCredentialView(cred, identity.name, blockServices.has(id)),
+ ),
});
}
groups.sort((a, b) => a.name.localeCompare(b.name));
diff --git a/autogpt_platform/frontend/src/services/experts/grant-to-expert.ts b/autogpt_platform/frontend/src/services/experts/grant-to-expert.ts
new file mode 100644
index 0000000000..a25b3946fb
--- /dev/null
+++ b/autogpt_platform/frontend/src/services/experts/grant-to-expert.ts
@@ -0,0 +1,23 @@
+import { grantExpertCredentials } from "@/app/api/__generated__/endpoints/experts/experts";
+import type { QueryClient } from "@tanstack/react-query";
+import { invalidateExpertGrantQueries } from "./invalidate-experts";
+
+/** Grants one credential to an expert and refreshes every list that shows
+ * it. Returns false when the grant did not land; the caller keeps the
+ * credential and tells the user, since the connection itself succeeded. */
+export async function grantToExpert(
+ queryClient: QueryClient,
+ expertId: string,
+ credentialId: string,
+): Promise<boolean> {
+ try {
+ const response = await grantExpertCredentials(expertId, {
+ credential_ids: [credentialId],
+ });
+ if (response.status !== 200) return false;
+ } catch {
+ return false;
+ }
+ await invalidateExpertGrantQueries(queryClient, expertId);
+ return true;
+}