Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

fix(mcp-store): allow OAuth access to server icons (#72597)

Chris Volzerea614ceeb208
diff --git a/products/mcp_store/backend/presentation/views.py b/products/mcp_store/backend/presentation/views.py
index d7b6322a8658..5f5cab3a7255 100644
--- a/products/mcp_store/backend/presentation/views.py
+++ b/products/mcp_store/backend/presentation/views.py
@@ -208,7 +208,7 @@ class MCPServerViewSet(TeamAndOrgViewSetMixin, mixins.ListModelMixin, viewsets.G
# Image bytes for <img src>; deliberately outside the typed client surface.
@extend_schema(exclude=True)
- @action(methods=["GET"], detail=False)
+ @action(methods=["GET"], detail=False, required_scopes=["project:read"])
def icon(self, request: Request, *args: Any, **kwargs: Any) -> HttpResponse:
# Canonicalized (lowercase, no FQDN trailing dot) before validation so case variants
# share one cache entry downstream.
diff --git a/products/mcp_store/backend/test/test_api.py b/products/mcp_store/backend/test/test_api.py
index 4836eb113a88..c19f10c00259 100644
--- a/products/mcp_store/backend/test/test_api.py
+++ b/products/mcp_store/backend/test/test_api.py
@@ -1,4 +1,5 @@
import hashlib
+from datetime import timedelta
from urllib.parse import parse_qs, urlparse
from posthog.test.base import APIBaseTest, ClickhouseTestMixin, QueryMatchingTest
@@ -6,11 +7,14 @@ from unittest.mock import patch
from django.http import HttpResponse
from django.test import TestCase
+from django.utils import timezone
from parameterized import parameterized
from rest_framework import status
from rest_framework.test import APIClient
+from posthog.models.oauth import OAuthAccessToken, OAuthApplication
+
from products.mcp_store.backend.models import MCPOAuthState, MCPServerInstallation, MCPServerTemplate
from products.mcp_store.backend.presentation.views import _is_valid_posthog_code_callback_url
@@ -175,6 +179,35 @@ class TestMCPServerAPI(ClickhouseTestMixin, APIBaseTest, QueryMatchingTest):
"linear.app", theme=expected_theme, fallback="404", team_id=self.team.id
)
+ def test_icon_allows_oauth_project_read_scope(self):
+ oauth_application = OAuthApplication.objects.create(
+ name="MCP icon test",
+ client_type=OAuthApplication.CLIENT_CONFIDENTIAL,
+ authorization_grant_type=OAuthApplication.GRANT_AUTHORIZATION_CODE,
+ redirect_uris="https://example.com/callback",
+ algorithm="RS256",
+ organization=self.organization,
+ user=self.user,
+ )
+ access_token = OAuthAccessToken.objects.create(
+ user=self.user,
+ application=oauth_application,
+ token="pha_test_mcp_icon",
+ expires=timezone.now() + timedelta(hours=1),
+ scope="project:read",
+ )
+ client = APIClient()
+
+ with patch("products.mcp_store.backend.presentation.views.CDPIconsService") as service:
+ service.return_value.get_icon_http_response.return_value = HttpResponse(b"png", content_type="image/png")
+ response = client.get(
+ f"/api/environments/{self.team.id}/mcp_servers/icon/",
+ data={"domain": "linear.app"},
+ headers={"authorization": f"Bearer {access_token.token}"},
+ )
+
+ assert response.status_code == status.HTTP_200_OK
+
def test_unauthenticated_access(self):
client = APIClient()
response = client.get(f"/api/environments/{self.team.id}/mcp_servers/")