: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.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
feat(mcp-store): connect to custom API key servers with your own key (#93430)
Chris Volzer55a22a023836
diff --git a/frontend/snapshots.yml b/frontend/snapshots.ymlindex ca0e1fa92355..8d212fb65b8f 100644--- a/frontend/snapshots.yml+++ b/frontend/snapshots.yml@@ -7680,6 +7680,22 @@ snapshots:hash: v1.k794b7964.204bddb0ec47c7a02409a9f49859ba7043d999b47fd909ac945277859bac2d0a.OGBvspVEX9BnlqZ6lq0amBQE5_vNK0DQ4VaUcdwtBtYscenes-app-mcp-analytics-tool-quality-charts--settled-window--light:hash: v1.k794b7964.d6be31937ca7321d00b299c38f6ba24480b8f1db772edce08c5c501d03694892.aSRmrM3xFQg0JNbAWh8tsjnN1GKBG1QlMLGOTK67oPo+ scenes-app-mcp-servers-connect-server-modal--catalog-api-key-template--dark:+ hash: v1.k794b7964.88b9762624eed0dad1e68107a83d764446614ec109f78047d3cb7932cbf8512c.1zVCJCmQ7XSt2Cw7Yz8Lqv_GPYFPE8PL0k8tHi_b6Lc+ scenes-app-mcp-servers-connect-server-modal--catalog-api-key-template--light:+ hash: v1.k794b7964.b705f5e8ab7938b793f4f633caed7a25a60413a781f95f1b788ec92aed1ae79a.z45sCOBKWiu6mwRvUunSPy_iLvYMTJbE81sVaw9cM7E+ scenes-app-mcp-servers-connect-server-modal--custom-server-added-with-api-key--dark:+ hash: v1.k794b7964.5d24904ab52b9c1dbd8703f26e8c2546af8285668759da5e479b7af1f23b861b.gpKmZAnQoYxVs3-lxCISOCriOUzOFfeBbPUYXkt0vUM+ scenes-app-mcp-servers-connect-server-modal--custom-server-added-with-api-key--light:+ hash: v1.k794b7964.94e4938f1f553657d1659aecb8b4cb6fb4eb7b5aeb2c5d7ba28e922f11fdca2a.If3EXAGE_yuYk4MQH1_6xGpfentsdZF-9gZjYq2tQm4+ scenes-app-mcp-servers-connect-server-modal--custom-server-added-with-o-auth--dark:+ hash: v1.k794b7964.848ede74b10c9c077e587ee1870e858179d21e1ee800000fe62ca222281818e2.g0JG4PbFojPv0ZJIef2RKVteHXT5JQJrgXur7YdKTp4+ scenes-app-mcp-servers-connect-server-modal--custom-server-added-with-o-auth--light:+ hash: v1.k794b7964.f0bddf2130b941ba3c8f42e811fda8950c0d0f3fed684e4937f28502b231a877.DCxDyW6MJcd3ZeQQgErTOJgiBhGrRSWnGA1ZGxWfMrQ+ scenes-app-mcp-servers-connect-server-modal--custom-server-without-recorded-auth-type--dark:+ hash: v1.k794b7964.4faa82bf59db418403a0b28d8124704b9c85fcc2a2bec5972a908634df209e84.Eu4aIjVfV37IpoHd8CVf9q8l5gi81p8rAy5bPHScb1s+ scenes-app-mcp-servers-connect-server-modal--custom-server-without-recorded-auth-type--light:+ hash: v1.k794b7964.db5fa21534ba04f6a8f5b352da7f7c2fe04d8f8fc3027093dc3157d30c25ce51.pFkNBfksp7dVX80g7MyMlD9ypiUajQ_mQ4ASWjTPrrcscenes-app-notebooks--bullet-list--dark:hash: v1.k794b7964.5122612e1f1257f266064fbfa67da4c92ba7d8668d79a368bbb6f8f2fe280e3f.gLB6PS_LpzmNHo6fU2VPQGcfR7NTJLUS8zO06U9b62sscenes-app-notebooks--bullet-list--light:diff --git a/products/desktop/packages/api-client/src/mcp-gateway.ts b/products/desktop/packages/api-client/src/mcp-gateway.tsindex ae515f89c25e..3acbc3b2570f 100644--- a/products/desktop/packages/api-client/src/mcp-gateway.ts+++ b/products/desktop/packages/api-client/src/mcp-gateway.ts@@ -77,6 +77,12 @@ export interface McpGatewayServer {* servers, where each member chooses when connecting.*/template_auth_type: McpAuthType | null;+ /**+ * How members connect: the template's type for catalog servers, or the+ * type a custom server was added with. Null only for custom servers+ * registered before the type was recorded; members then choose.+ */+ auth_type: McpAuthType | null;tool_count: number;/** Members with a connection to this server. Admin-only; empty for members. */connections: McpGatewayConnection[];diff --git a/products/desktop/packages/core/src/mcp-gateway/gatewayConnect.test.ts b/products/desktop/packages/core/src/mcp-gateway/gatewayConnect.test.tsindex 67a27f7e1f13..73844f479833 100644--- a/products/desktop/packages/core/src/mcp-gateway/gatewayConnect.test.ts+++ b/products/desktop/packages/core/src/mcp-gateway/gatewayConnect.test.ts@@ -40,22 +40,36 @@ describe("gatewayConnectAuthType", () => {it.each([["oauth template",- { template_id: "t1", template_auth_type: "oauth" },+ { template_id: "t1", template_auth_type: "oauth", auth_type: "oauth" },"oauth",],["api-key template",- { template_id: "t1", template_auth_type: "api_key" },+ {+ template_id: "t1",+ template_auth_type: "api_key",+ auth_type: "api_key",+ },"api_key",],["template with no reported type",- { template_id: "t1", template_auth_type: null },+ { template_id: "t1", template_auth_type: null, auth_type: null },"oauth",],[- "custom server — member chooses",- { template_id: null, template_auth_type: null },+ "custom server added with an API key",+ { template_id: null, template_auth_type: null, auth_type: "api_key" },+ "api_key",+ ],+ [+ "custom server added with OAuth",+ { template_id: null, template_auth_type: null, auth_type: "oauth" },+ "oauth",+ ],+ [+ "custom server with no recorded type — member chooses",+ { template_id: null, template_auth_type: null, auth_type: null },null,],] as const)("%s", (_label, server, expected) => {@@ -67,17 +81,31 @@ describe("gatewayConnectNeedsCredentials", () => {it.each([["oauth template connects directly",- { template_id: "t1", template_auth_type: "oauth" },+ { template_id: "t1", template_auth_type: "oauth", auth_type: "oauth" },false,],["api-key template asks for the key",- { template_id: "t1", template_auth_type: "api_key" },+ {+ template_id: "t1",+ template_auth_type: "api_key",+ auth_type: "api_key",+ },+ true,+ ],+ [+ "custom api-key server asks for the member's own key",+ { template_id: null, template_auth_type: null, auth_type: "api_key" },+ true,+ ],+ [+ "custom oauth server offers the optional client first",+ { template_id: null, template_auth_type: null, auth_type: "oauth" },true,],[- "custom server asks the member to choose",- { template_id: null, template_auth_type: null },+ "custom server with no recorded type asks the member to choose",+ { template_id: null, template_auth_type: null, auth_type: null },true,],] as const)("%s", (_label, server, expected) => {diff --git a/products/desktop/packages/core/src/mcp-gateway/gatewayConnect.ts b/products/desktop/packages/core/src/mcp-gateway/gatewayConnect.tsindex 798b4d87fae7..c35befd06b14 100644--- a/products/desktop/packages/core/src/mcp-gateway/gatewayConnect.ts+++ b/products/desktop/packages/core/src/mcp-gateway/gatewayConnect.ts@@ -28,29 +28,31 @@ export const GATEWAY_CONNECT_DEFAULTS: GatewayConnectCredentials = {type GatewayConnectServer = Pick<McpGatewayServer,- "template_id" | "template_auth_type"+ "template_id" | "template_auth_type" | "auth_type">;/**- * The auth mechanism a connection must use: catalog templates fix it, custom- * servers leave it null — every credential is personal, so each member picks- * their own mechanism when they connect.+ * The auth mechanism a connection must use: catalog templates fix it, and a+ * custom server keeps the mechanism it was added with. Null only for custom+ * servers registered before that was recorded; the member then picks one.*/export function gatewayConnectAuthType(server: GatewayConnectServer,): McpAuthType | null {+ if (server.auth_type) return server.auth_type;return server.template_id ? (server.template_auth_type ?? "oauth") : null;}/**- * OAuth connects need no input up front — the browser round-trip collects the- * grant. Everything else (API-key templates, custom servers where the member- * chooses) must collect credentials before installing.+ * OAuth template connects need no input up front — the browser round-trip+ * collects the grant. Everything else must collect credentials before+ * installing: API-key servers ask for the member's own key, and custom OAuth+ * servers offer the optional client id and secret.*/export function gatewayConnectNeedsCredentials(server: GatewayConnectServer,): boolean {- return gatewayConnectAuthType(server) !== "oauth";+ return !server.template_id || gatewayConnectAuthType(server) !== "oauth";}/** Same decision for a catalog template with no gateway row yet. */diff --git a/products/desktop/packages/core/src/mcp-gateway/gatewayServers.test.ts b/products/desktop/packages/core/src/mcp-gateway/gatewayServers.test.tsindex e4be219d718e..5ba461b3bead 100644--- a/products/desktop/packages/core/src/mcp-gateway/gatewayServers.test.ts+++ b/products/desktop/packages/core/src/mcp-gateway/gatewayServers.test.ts@@ -86,6 +86,7 @@ function server(overrides: Partial<McpGatewayServer>): McpGatewayServer {docs_url: "",template_id: null,template_auth_type: null,+ auth_type: null,tool_count: 0,connections: [],your_connection: null,diff --git a/products/desktop/packages/core/src/mcp-gateway/gatewayToolDiscovery.test.ts b/products/desktop/packages/core/src/mcp-gateway/gatewayToolDiscovery.test.tsindex d90e8004c266..0074ac636945 100644--- a/products/desktop/packages/core/src/mcp-gateway/gatewayToolDiscovery.test.ts+++ b/products/desktop/packages/core/src/mcp-gateway/gatewayToolDiscovery.test.ts@@ -35,6 +35,7 @@ function server(overrides: Partial<McpGatewayServer> = {}): McpGatewayServer {docs_url: "",template_id: null,template_auth_type: null,+ auth_type: null,tool_count: 0,connections: [],your_connection: null,diff --git a/products/desktop/packages/ui/src/features/mcp-gateway/components/parts/GatewayAddServer.tsx b/products/desktop/packages/ui/src/features/mcp-gateway/components/parts/GatewayAddServer.tsxindex 80a52756b362..af522bc0f66e 100644--- a/products/desktop/packages/ui/src/features/mcp-gateway/components/parts/GatewayAddServer.tsx+++ b/products/desktop/packages/ui/src/features/mcp-gateway/components/parts/GatewayAddServer.tsx@@ -165,7 +165,7 @@ export function GatewayAddServer({value={values.apiKey}onChange={(e) => set("apiKey", e.target.value)}type={showKey ? "text" : "password"}- placeholder="sk-…"+ placeholder="Enter API key"spellCheck={false}className="font-mono">diff --git a/products/desktop/packages/ui/src/features/mcp-gateway/components/parts/GatewayConnectDialog.stories.tsx b/products/desktop/packages/ui/src/features/mcp-gateway/components/parts/GatewayConnectDialog.stories.tsxnew file mode 100644index 000000000000..6df4e3fc8766--- /dev/null+++ b/products/desktop/packages/ui/src/features/mcp-gateway/components/parts/GatewayConnectDialog.stories.tsx@@ -0,0 +1,35 @@+import type { Meta, StoryObj } from "@storybook/react-vite";+import { GatewayConnectDialog } from "./GatewayConnectDialog";++const meta = {+ title: "MCP gateway/GatewayConnectDialog",+ component: GatewayConnectDialog,+ args: {+ open: true,+ serverName: "Internal wiki",+ onSubmit: () => {},+ onClose: () => {},+ },+} satisfies Meta<typeof GatewayConnectDialog>;++export default meta;+type Story = StoryObj<typeof meta>;++/** A teammate added this custom server with an API key: each member enters their own. */+export const CustomServerAddedWithApiKey: Story = {+ args: { fixedAuthType: "api_key", isCustomServer: true },+};++/** A custom OAuth server keeps the optional client id and secret. */+export const CustomServerAddedWithOAuth: Story = {+ args: { fixedAuthType: "oauth", isCustomServer: true },+};++/** Custom servers registered before their auth type was recorded still let the member choose. */+export const CustomServerWithoutRecordedAuthType: Story = {+ args: { fixedAuthType: null, isCustomServer: true },+};++export const CatalogApiKeyTemplate: Story = {+ args: { fixedAuthType: "api_key", serverName: "Linear" },+};diff --git a/products/desktop/packages/ui/src/features/mcp-gateway/components/parts/GatewayConnectDialog.test.tsx b/products/desktop/packages/ui/src/features/mcp-gateway/components/parts/GatewayConnectDialog.test.tsxindex 21bf5c507fe6..3f4fbd43eadb 100644--- a/products/desktop/packages/ui/src/features/mcp-gateway/components/parts/GatewayConnectDialog.test.tsx+++ b/products/desktop/packages/ui/src/features/mcp-gateway/components/parts/GatewayConnectDialog.test.tsx@@ -31,6 +31,57 @@ describe("GatewayConnectDialog", () => {});});+ it("asks a custom api-key server's member for their own key without offering a choice", async () => {+ const user = userEvent.setup();+ const onSubmit = vi.fn();+ render(+ <Theme>+ <GatewayConnectDialog+ open+ serverName="Internal Wiki"+ fixedAuthType="api_key"+ isCustomServer+ onSubmit={onSubmit}+ onClose={vi.fn()}+ />+ </Theme>,+ );++ expect(screen.queryByText("Authentication")).not.toBeInTheDocument();+ expect(+ screen.getByText(+ "This server uses an API key. Enter your own key to connect.",+ ),+ ).toBeInTheDocument();+ await user.type(screen.getByPlaceholderText("Enter API key"), "sk-mine");+ await user.click(screen.getByRole("button", { name: "Connect" }));++ expect(onSubmit).toHaveBeenCalledWith({+ authType: "api_key",+ apiKey: "sk-mine",+ clientId: "",+ clientSecret: "",+ });+ });++ it("keeps the optional OAuth client for a custom OAuth server without offering a choice", () => {+ render(+ <Theme>+ <GatewayConnectDialog+ open+ serverName="Internal Wiki"+ fixedAuthType="oauth"+ isCustomServer+ onSubmit={vi.fn()}+ onClose={vi.fn()}+ />+ </Theme>,+ );++ expect(screen.queryByText("Authentication")).not.toBeInTheDocument();+ expect(screen.getByText("Optional")).toBeInTheDocument();+ });+it("requires the key for an api-key server and submits it", async () => {const user = userEvent.setup();const onSubmit = vi.fn();@@ -51,7 +102,7 @@ describe("GatewayConnectDialog", () => {const connect = screen.getByRole("button", { name: "Connect" });expect(connect).toBeDisabled();- await user.type(screen.getByPlaceholderText("sk-…"), "sk-secret");+ await user.type(screen.getByPlaceholderText("Enter API key"), "sk-secret");await user.click(connect);expect(onSubmit).toHaveBeenCalledWith({diff --git a/products/desktop/packages/ui/src/features/mcp-gateway/components/parts/GatewayConnectDialog.tsx b/products/desktop/packages/ui/src/features/mcp-gateway/components/parts/GatewayConnectDialog.tsxindex 354496bd5df8..06bbb2b1a008 100644--- a/products/desktop/packages/ui/src/features/mcp-gateway/components/parts/GatewayConnectDialog.tsx+++ b/products/desktop/packages/ui/src/features/mcp-gateway/components/parts/GatewayConnectDialog.tsx@@ -23,20 +23,24 @@ interface GatewayConnectDialogProps {* where the member chooses their own.*/fixedAuthType: McpAuthType | null;+ /** Custom servers may need a member-supplied OAuth client. */+ isCustomServer?: boolean;onSubmit: (credentials: GatewayConnectCredentials) => void;onClose: () => void;}/*** Collects the caller's personal credentials before connecting: the API key- * for api-key servers, and — for custom servers, which have no fixed auth- * mechanism — the choice between OAuth and API key. Plain OAuth templates- * never open this; they go straight to the browser round-trip.+ * for api-key servers, the optional OAuth client for custom OAuth servers,+ * and — for custom servers with no recorded auth mechanism — the choice+ * between OAuth and API key. Plain OAuth templates never open this; they go+ * straight to the browser round-trip.*/export function GatewayConnectDialog({open,serverName,fixedAuthType,+ isCustomServer = false,onSubmit,onClose,}: GatewayConnectDialogProps) {@@ -68,7 +72,9 @@ export function GatewayConnectDialog({<Dialog.Description color="gray" className="text-sm">{memberChooses? "Choose how this server authenticates, then enter your personal credentials."- : "Enter the credentials for your personal connection."}+ : values.authType === "api_key"+ ? "This server uses an API key. Enter your own key to connect."+ : "Enter the credentials for your personal connection."}</Dialog.Description><form onSubmit={submit}><Flex direction="column" gap="3" mt="4">@@ -100,7 +106,7 @@ export function GatewayConnectDialog({value={values.apiKey}onChange={(e) => set("apiKey", e.target.value)}type={showKey ? "text" : "password"}- placeholder="sk-…"+ placeholder="Enter API key"spellCheck={false}autoFocusclassName="font-mono"@@ -119,7 +125,7 @@ export function GatewayConnectDialog({</TextField.Root></Field>) : (- memberChooses && (+ isCustomServer && (<div className="rounded-md border border-gray-5 bg-gray-2"><buttontype="button"diff --git a/products/desktop/packages/ui/src/features/mcp-gateway/components/parts/GatewayRail.test.tsx b/products/desktop/packages/ui/src/features/mcp-gateway/components/parts/GatewayRail.test.tsxindex 6493ad8c54e5..73085c62f8d2 100644--- a/products/desktop/packages/ui/src/features/mcp-gateway/components/parts/GatewayRail.test.tsx+++ b/products/desktop/packages/ui/src/features/mcp-gateway/components/parts/GatewayRail.test.tsx@@ -20,6 +20,7 @@ function server(overrides: Partial<McpGatewayServer> = {}): McpGatewayServer {docs_url: "",template_id: null,template_auth_type: null,+ auth_type: null,tool_count: 0,connections: [],your_connection: null,diff --git a/products/desktop/packages/ui/src/features/mcp-gateway/components/parts/GatewayServerDetail.test.tsx b/products/desktop/packages/ui/src/features/mcp-gateway/components/parts/GatewayServerDetail.test.tsxindex d03e2be71084..e30f25beb00e 100644--- a/products/desktop/packages/ui/src/features/mcp-gateway/components/parts/GatewayServerDetail.test.tsx+++ b/products/desktop/packages/ui/src/features/mcp-gateway/components/parts/GatewayServerDetail.test.tsx@@ -73,6 +73,7 @@ const server = {docs_url: "",template_id: null,template_auth_type: null,+ auth_type: null,tool_count: 0,connections: [{diff --git a/products/desktop/packages/ui/src/features/mcp-gateway/components/parts/GatewayServerDetail.tsx b/products/desktop/packages/ui/src/features/mcp-gateway/components/parts/GatewayServerDetail.tsxindex cbbb930c6f43..a0f6485be3de 100644--- a/products/desktop/packages/ui/src/features/mcp-gateway/components/parts/GatewayServerDetail.tsx+++ b/products/desktop/packages/ui/src/features/mcp-gateway/components/parts/GatewayServerDetail.tsx@@ -626,6 +626,7 @@ export function GatewayServerDetail({openserverName={server.name}fixedAuthType={gatewayConnectAuthType(server)}+ isCustomServer={!server.template_id}onSubmit={handleConnectSubmit}onClose={() => setConnectOpen(false)}/>diff --git a/products/desktop/packages/ui/src/features/mcp-gateway/components/parts/GatewayServersHome.tsx b/products/desktop/packages/ui/src/features/mcp-gateway/components/parts/GatewayServersHome.tsxindex 193d1b8d8f6e..470c35a0ae58 100644--- a/products/desktop/packages/ui/src/features/mcp-gateway/components/parts/GatewayServersHome.tsx+++ b/products/desktop/packages/ui/src/features/mcp-gateway/components/parts/GatewayServersHome.tsx@@ -274,6 +274,9 @@ export function GatewayServersHome({? gatewayConnectAuthType(connectTarget.server): (connectTarget.template.auth_type ?? "oauth")}+ isCustomServer={+ connectTarget.kind === "server" && !connectTarget.server.template_id+ }onSubmit={handleConnectSubmit}onClose={() => setConnectTarget(null)}/>diff --git a/products/desktop/packages/ui/src/features/mcp-gateway/components/parts/GatewayTeamSettings.test.tsx b/products/desktop/packages/ui/src/features/mcp-gateway/components/parts/GatewayTeamSettings.test.tsxindex 00c7170fcf98..31636663d9d7 100644--- a/products/desktop/packages/ui/src/features/mcp-gateway/components/parts/GatewayTeamSettings.test.tsx+++ b/products/desktop/packages/ui/src/features/mcp-gateway/components/parts/GatewayTeamSettings.test.tsx@@ -53,6 +53,7 @@ const server = {docs_url: "",template_id: null,template_auth_type: null,+ auth_type: null,tool_count: 0,connections: [],your_connection: null,diff --git a/products/desktop/packages/ui/src/features/mcp-gateway/components/parts/GiveAccessDialog.test.tsx b/products/desktop/packages/ui/src/features/mcp-gateway/components/parts/GiveAccessDialog.test.tsxindex 149927c5eae4..1e26255d1e1f 100644--- a/products/desktop/packages/ui/src/features/mcp-gateway/components/parts/GiveAccessDialog.test.tsx+++ b/products/desktop/packages/ui/src/features/mcp-gateway/components/parts/GiveAccessDialog.test.tsx@@ -22,6 +22,7 @@ const server: McpGatewayServer = {docs_url: "",template_id: "template-1",template_auth_type: null,+ auth_type: null,tool_count: 0,connections: [],your_connection: null,diff --git a/products/desktop/packages/ui/src/features/mcp-gateway/hooks/useRegisterGatewayServer.test.tsx b/products/desktop/packages/ui/src/features/mcp-gateway/hooks/useRegisterGatewayServer.test.tsxindex eadda047bbf5..d42a4e6eda36 100644--- a/products/desktop/packages/ui/src/features/mcp-gateway/hooks/useRegisterGatewayServer.test.tsx+++ b/products/desktop/packages/ui/src/features/mcp-gateway/hooks/useRegisterGatewayServer.test.tsx@@ -58,6 +58,7 @@ function gatewayServer(overrides: Record<string, unknown> = {}) {docs_url: "",template_id: null,template_auth_type: null,+ auth_type: null,tool_count: 0,connections: [],your_connection: {diff --git a/products/mcp_store/README.md b/products/mcp_store/README.mdindex 0721e89b079c..2f450e4e1b43 100644--- a/products/mcp_store/README.md+++ b/products/mcp_store/README.md@@ -35,6 +35,8 @@ The gateway experience has these pages and workflows:- **MCP servers**: Browse the catalog, search by server details, filter by category, and see connection status.Users with permission can add a hosted custom server and choose OAuth or API key authentication.+ The server keeps that choice: a teammate who connects later follows it, so a server added with an API key asks each member for their own key instead of starting an OAuth flow.+ Connecting to a registered custom server is not gated by the "members can add custom servers" setting.Admins can set its team availability.Every connection is shared with the built-in PostHog agents automatically when the connecting user may manage agent access (admins always, members while team settings allow it).The built-in agents are the support agent, the scout agent, and the workflow agent, which runs the "Create AI task" step of a workflow; a step picks among the servers shared with the whole project, the same way a scout does.diff --git a/products/mcp_store/backend/gateway.py b/products/mcp_store/backend/gateway.pyindex 9f1964f8c3be..1f6f7996d305 100644--- a/products/mcp_store/backend/gateway.py+++ b/products/mcp_store/backend/gateway.py@@ -65,6 +65,7 @@ def link_installation_to_gateway(installation: MCPServerInstallation, created_by"description": installation.description,"template": template,"category": template.category if template else "dev",+ "auth_type": installation.auth_type,"created_by": created_by,},)@@ -73,6 +74,10 @@ def link_installation_to_gateway(installation: MCPServerInstallation, created_byif template is not None and server.template_id is None:server.template = templateupdate_fields.append("template")+ # Rows created before auth_type existed learn it from the next credential.+ if not server.auth_type:+ server.auth_type = installation.auth_type+ update_fields.append("auth_type")if update_fields:server.save(update_fields=[*update_fields, "updated_at"])diff --git a/products/mcp_store/backend/migrations/0027_gateway_server_auth_type.py b/products/mcp_store/backend/migrations/0027_gateway_server_auth_type.pynew file mode 100644index 000000000000..917509140a8e--- /dev/null+++ b/products/mcp_store/backend/migrations/0027_gateway_server_auth_type.py@@ -0,0 +1,28 @@+from django.db import migrations, models+++class Migration(migrations.Migration):+ """Record how members authenticate to a custom gateway server.++ Additive: the column carries a Postgres-level default, so pods on the+ previous release keep inserting rows without it while the deploy rolls.+ The backfill lives in 0028 so this ALTER's lock commits before it runs.+ """++ dependencies = [+ ("mcp_store", "0026_agent_grant_scope"),+ ]++ operations = [+ migrations.AddField(+ model_name="mcpgatewayserver",+ name="auth_type",+ field=models.CharField(+ blank=True,+ choices=[("api_key", "API Key"), ("oauth", "OAuth")],+ db_default="",+ default="",+ max_length=20,+ ),+ ),+ ]diff --git a/products/mcp_store/backend/migrations/0028_backfill_gateway_server_auth_type.py b/products/mcp_store/backend/migrations/0028_backfill_gateway_server_auth_type.pynew file mode 100644index 000000000000..efc323992e80--- /dev/null+++ b/products/mcp_store/backend/migrations/0028_backfill_gateway_server_auth_type.py@@ -0,0 +1,32 @@+from django.db import migrations+++def backfill_auth_type(apps, schema_editor):+ MCPGatewayServer = apps.get_model("mcp_store", "MCPGatewayServer")+ MCPServerInstallation = apps.get_model("mcp_store", "MCPServerInstallation")+ for server in MCPGatewayServer.objects.filter(template__isnull=True, auth_type="").iterator(chunk_size=500):+ installation = (+ MCPServerInstallation.objects.filter(gateway_server_id=server.id)+ .order_by("created_at")+ .only("auth_type")+ .first()+ )+ if installation is None:+ continue+ server.auth_type = installation.auth_type+ server.save(update_fields=["auth_type"])+++class Migration(migrations.Migration):+ """Copy the auth type from the credential that registered each custom row.++ Rows with no credential left stay blank and members choose.+ """++ dependencies = [+ ("mcp_store", "0027_gateway_server_auth_type"),+ ]++ operations = [+ migrations.RunPython(backfill_auth_type, migrations.RunPython.noop),+ ]diff --git a/products/mcp_store/backend/migrations/max_migration.txt b/products/mcp_store/backend/migrations/max_migration.txtindex 63f332a4cee2..e6e31e834994 100644--- a/products/mcp_store/backend/migrations/max_migration.txt+++ b/products/mcp_store/backend/migrations/max_migration.txt@@ -1 +1 @@-0026_agent_grant_scope+0028_backfill_gateway_server_auth_typediff --git a/products/mcp_store/backend/models.py b/products/mcp_store/backend/models.pyindex 1352383bbb7e..94e82dd2fdff 100644--- a/products/mcp_store/backend/models.py+++ b/products/mcp_store/backend/models.py@@ -328,6 +328,11 @@ class MCPGatewayServer(TeamScopedRootMixin, UUIDModel):template = models.ForeignKey(MCPServerTemplate, on_delete=models.SET_NULL, related_name="gateway_servers", null=True, blank=True)+ # How members authenticate to a custom server, copied from the credential+ # that registered the row. Later connections follow it instead of asking+ # each member to guess. Templates carry their own auth_type. Blank on rows+ # that predate the column; members then choose.+ auth_type = models.CharField(max_length=20, choices=AUTH_TYPE_CHOICES, blank=True, default="", db_default="")created_by = models.ForeignKey("posthog.User", on_delete=models.SET_NULL, null=True, blank=True, related_name="+", db_constraint=False)diff --git a/products/mcp_store/backend/presentation/gateway_views.py b/products/mcp_store/backend/presentation/gateway_views.pyindex 8370bd16b7f7..1545c711c46d 100644--- a/products/mcp_store/backend/presentation/gateway_views.py+++ b/products/mcp_store/backend/presentation/gateway_views.py@@ -261,6 +261,13 @@ class MCPGatewayServerSerializer(serializers.ModelSerializer):default=None,help_text="Fixed authentication type for catalog templates. Null for custom servers, where members choose.",)+ auth_type = serializers.SerializerMethodField(+ help_text=(+ "How members connect to this server: the template's type for catalog servers, or the type the "+ "custom server was added with. Null only for custom servers registered before the type was "+ "recorded; members then choose."+ )+ )icon_key = serializers.CharField(source="template.icon_key",read_only=True,@@ -306,6 +313,7 @@ class MCPGatewayServerSerializer(serializers.ModelSerializer):"description","category","template_auth_type",+ "auth_type","is_team_enabled","icon_key","icon_domain",@@ -332,6 +340,12 @@ class MCPGatewayServerSerializer(serializers.ModelSerializer):"updated_at",]+ @extend_schema_field(serializers.ChoiceField(choices=AUTH_TYPE_CHOICES, allow_null=True))+ def get_auth_type(self, obj: MCPGatewayServer) -> str | None:+ if obj.template is not None:+ return obj.template.auth_type+ return obj.auth_type or None+@extend_schema_field(serializers.IntegerField())def get_tool_count(self, obj: MCPGatewayServer) -> int:annotated = getattr(obj, "tool_count_annotated", None)diff --git a/products/mcp_store/backend/presentation/views.py b/products/mcp_store/backend/presentation/views.pyindex ab8410324e9d..90fe45ded493 100644--- a/products/mcp_store/backend/presentation/views.py+++ b/products/mcp_store/backend/presentation/views.py@@ -1569,7 +1569,10 @@ class MCPServerInstallationViewSet(TeamAndOrgViewSetMixin, viewsets.ModelViewSetuser_client_secret = (data.get("client_secret") or "").strip()scope = data.get("scope", "personal")self._require_admin_for_shared_scope(scope)- self._require_custom_servers_allowed()+ # Connecting to a server a teammate already registered is not adding+ # one, so the team's custom-server setting does not apply.+ if not MCPGatewayServer.objects.for_team(self.team_id).filter(url=url).exists():+ self._require_custom_servers_allowed()self._validate_gateway_options(data)install_source = data.get("install_source", "posthog")diff --git a/products/mcp_store/backend/test/test_api.py b/products/mcp_store/backend/test/test_api.pyindex f01dc193d3e1..af5d3c5c4ec8 100644--- a/products/mcp_store/backend/test/test_api.py+++ b/products/mcp_store/backend/test/test_api.py@@ -360,7 +360,7 @@ class TestMCPGatewayServerAPI(APIBaseTest):assert [result["id"] for result in response.json()["results"]] == [str(registered.id)]assert not MCPGatewayServer.objects.for_team(self.team.id).filter(url=untouched.url).exists()- def test_list_exposes_template_auth_type_and_leaves_custom_auth_choice_open(self) -> None:+ def test_list_exposes_the_auth_type_members_connect_with(self) -> None:self._make_admin()template = self._template("API key", auth_type="api_key")template_server = MCPGatewayServer.objects.for_team(self.team.id).create(@@ -374,6 +374,13 @@ class TestMCPGatewayServerAPI(APIBaseTest):team=self.team,name="Custom",url="https://mcp.custom-auth.gateway-test.example.com/mcp",+ auth_type="api_key",+ created_by=self.user,+ )+ legacy_custom = MCPGatewayServer.objects.for_team(self.team.id).create(+ team=self.team,+ name="Legacy custom",+ url="https://mcp.legacy-auth.gateway-test.example.com/mcp",created_by=self.user,)@@ -382,7 +389,10 @@ class TestMCPGatewayServerAPI(APIBaseTest):assert response.status_code == status.HTTP_200_OKby_id = {result["id"]: result for result in response.json()["results"]}assert by_id[str(template_server.id)]["template_auth_type"] == "api_key"+ assert by_id[str(template_server.id)]["auth_type"] == "api_key"assert by_id[str(custom.id)]["template_auth_type"] is None+ assert by_id[str(custom.id)]["auth_type"] == "api_key"+ assert by_id[str(legacy_custom.id)]["auth_type"] is Nonedef test_disabled_catalog_server_is_hidden_from_members_but_visible_to_admins(self) -> None:self._make_admin()@@ -2702,6 +2712,40 @@ class TestInstallCustomAPI(ClickhouseTestMixin, APIBaseTest, QueryMatchingTest):assert response.json()["url"] == "https://mcp.custom.com"assert response.json()["auth_type"] == "api_key"+ @ALLOW_URL+ def test_teammate_connects_to_registered_api_key_server_with_own_key(self, _mock):+ url = "https://mcp.team-key.com"+ response = self.client.post(+ f"/api/environments/{self.team.id}/mcp_server_installations/install_custom/",+ data={"name": "Team key server", "url": url, "auth_type": "api_key", "api_key": "sk-owner"},+ format="json",+ )+ assert response.status_code == status.HTTP_201_CREATED+ server = MCPGatewayServer.objects.for_team(self.team.id).get(url=url)+ assert server.auth_type == "api_key"++ TeamMCPGatewayConfig.objects.for_team(self.team.id).create(team=self.team, allow_custom_servers=False)+ teammate = User.objects.create_and_join(self.organization, "[email protected]", "password")+ self.client.force_login(teammate)++ blocked = self.client.post(+ f"/api/environments/{self.team.id}/mcp_server_installations/install_custom/",+ data={"name": "New server", "url": "https://mcp.new-server.com", "auth_type": "api_key"},+ format="json",+ )+ assert blocked.status_code == status.HTTP_403_FORBIDDEN++ connected = self.client.post(+ f"/api/environments/{self.team.id}/mcp_server_installations/install_custom/",+ data={"name": "Team key server", "url": url, "auth_type": "api_key", "api_key": "sk-teammate"},+ format="json",+ )+ assert connected.status_code == status.HTTP_201_CREATED+ installation = MCPServerInstallation.objects.get(id=connected.json()["id"])+ assert installation.user_id == teammate.id+ assert installation.gateway_server_id == server.id+ assert installation.sensitive_configuration["api_key"] == "sk-teammate"+@ALLOW_URLdef test_install_custom_api_key_server_without_key(self, _mock):response = self.client.post(diff --git a/products/mcp_store/frontend/gateway/GatewayConnectionModal.stories.tsx b/products/mcp_store/frontend/gateway/GatewayConnectionModal.stories.tsxnew file mode 100644index 000000000000..99a48a64929d--- /dev/null+++ b/products/mcp_store/frontend/gateway/GatewayConnectionModal.stories.tsx@@ -0,0 +1,111 @@+import type { Meta, StoryObj } from '@storybook/react'+import { useActions, useValues } from 'kea'+import { useEffect } from 'react'++import { mswDecorator } from '~/mocks/browser'++import { MCPGatewayServerApi, TeamMCPGatewayConfigApi } from '../generated/api.schemas'+import { GatewayConnectionModal } from './GatewayConnectionModal'+import { mcpGatewayLogic } from './mcpGatewayLogic'++const EMPTY_PAGE = { count: 0, next: null, previous: null, results: [] }++const GATEWAY_CONFIG: TeamMCPGatewayConfigApi = {+ allow_custom_servers: true,+ allow_member_agent_access: true,+ default_servers_enabled: true,+ member_default_preset: '',+ agent_default_preset: '',+ registered_template_ids: [],+ is_admin: false,+}++function gatewayServer(overrides: Partial<MCPGatewayServerApi>): MCPGatewayServerApi {+ return {+ id: 'server-id',+ name: 'Internal wiki',+ url: 'https://mcp.wiki.example.com/mcp',+ description: '',+ category: 'productivity',+ template_auth_type: null,+ auth_type: null,+ is_team_enabled: true,+ icon_key: '',+ icon_domain: '',+ docs_url: '',+ template_id: null,+ tool_count: 4,+ connections: [],+ your_connection: null,+ agents: [],+ revoked_user_ids: [],+ is_revoked_for_you: false,+ created_by: null,+ created_at: '2026-01-01T00:00:00Z',+ updated_at: '2026-01-01T00:00:00Z',+ ...overrides,+ }+}++function ConnectOnLoad({ serverId }: { serverId: string }): JSX.Element {+ const { servers } = useValues(mcpGatewayLogic)+ const { connectServer } = useActions(mcpGatewayLogic)+ useEffect(() => {+ if (servers.some((server) => server.id === serverId)) {+ connectServer(serverId)+ }+ }, [servers, serverId, connectServer])+ return <GatewayConnectionModal />+}++function storyFor(server: MCPGatewayServerApi): Story {+ return {+ decorators: [+ mswDecorator({+ get: {+ '/api/projects/:project_id/mcp_gateway/servers/': () => [+ 200,+ { ...EMPTY_PAGE, count: 1, results: [server] },+ ],+ '/api/projects/:project_id/mcp_gateway/config/': () => [200, GATEWAY_CONFIG],+ '/api/projects/:project_id/mcp_gateway/service_accounts/': () => [200, EMPTY_PAGE],+ '/api/projects/:project_id/mcp_gateway/rules/': () => [200, EMPTY_PAGE],+ '/api/projects/:project_id/mcp_servers/': () => [200, EMPTY_PAGE],+ },+ }),+ ],+ render: () => <ConnectOnLoad serverId={server.id} />,+ }+}++type Story = StoryObj<typeof GatewayConnectionModal>+const meta: Meta<typeof GatewayConnectionModal> = {+ title: 'Scenes-App/MCP servers/Connect server modal',+ component: GatewayConnectionModal,+ parameters: {+ layout: 'fullscreen',+ viewMode: 'story',+ mockDate: '2026-01-15',+ },+}++export default meta++/** A teammate added this custom server with an API key: each member enters their own key. */+export const CustomServerAddedWithApiKey: Story = storyFor(gatewayServer({ auth_type: 'api_key' }))++/** A custom OAuth server keeps the optional client id and secret. */+export const CustomServerAddedWithOAuth: Story = storyFor(gatewayServer({ auth_type: 'oauth' }))++/** Custom servers registered before their auth type was recorded still let the member choose. */+export const CustomServerWithoutRecordedAuthType: Story = storyFor(gatewayServer({ auth_type: null }))++export const CatalogApiKeyTemplate: Story = storyFor(+ gatewayServer({+ id: 'template-server',+ name: 'Linear',+ template_id: 'template-id',+ template_auth_type: 'api_key',+ auth_type: 'api_key',+ })+)diff --git a/products/mcp_store/frontend/gateway/GatewayConnectionModal.tsx b/products/mcp_store/frontend/gateway/GatewayConnectionModal.tsxnew file mode 100644index 000000000000..b4a2801fa21b--- /dev/null+++ b/products/mcp_store/frontend/gateway/GatewayConnectionModal.tsx@@ -0,0 +1,170 @@+import { useActions, useValues } from 'kea'++import { LemonButton, LemonCollapse, LemonInput, LemonModal, LemonSelect } from '@posthog/lemon-ui'++import { LemonField } from 'lib/lemon-ui/LemonField'++import { InstallCustomAuthTypeEnumApi } from '../generated/api.schemas'+import { mcpGatewayLogic } from './mcpGatewayLogic'++const AUTH_TYPE_OPTIONS = [+ { value: 'oauth' as const, label: 'OAuth' },+ { value: 'api_key' as const, label: 'API key' },+]++export function GatewayConnectionModal(): JSX.Element | null {+ const {+ connectionModalServer,+ connectionAuthType,+ connectionApiKey,+ connectionClientId,+ connectionClientSecret,+ connectingServerId,+ connectionSubmitDisabledReason,+ } = useValues(mcpGatewayLogic)+ const {+ closeConnectionModal,+ setConnectionAuthType,+ setConnectionApiKey,+ setConnectionClientId,+ setConnectionClientSecret,+ submitConnection,+ } = useActions(mcpGatewayLogic)++ if (!connectionModalServer) {+ return null+ }++ const isCustomServer = !connectionModalServer.template_id+ // Custom servers registered before their auth type was recorded leave the choice to the member.+ const memberChooses = isCustomServer && !connectionModalServer.auth_type+ const connecting = connectingServerId === connectionModalServer.id+ const closeModal = (): void => {+ if (!connecting) {+ closeConnectionModal()+ }+ }++ return (+ <LemonModal+ isOpen+ onClose={closeModal}+ title={`Connect ${connectionModalServer.name}`}+ description={+ memberChooses+ ? 'Choose how this server authenticates, then enter your personal credentials.'+ : connectionAuthType === 'api_key'+ ? 'This server uses an API key. Enter your own key to connect.'+ : 'Enter the credentials for your personal connection.'+ }+ footer={+ <div className="flex items-center justify-end gap-2">+ <LemonButton+ type="secondary"+ onClick={closeModal}+ disabledReason={connecting ? 'Connection in progress' : undefined}+ >+ Cancel+ </LemonButton>+ <LemonButton+ type="primary"+ htmlType="submit"+ form="mcp-gateway-connect-server-form"+ loading={connecting}+ disabledReason={connectionSubmitDisabledReason ?? undefined}+ >+ Connect+ </LemonButton>+ </div>+ }+ width={560}+ >+ <form+ id="mcp-gateway-connect-server-form"+ className="flex flex-col gap-3"+ onSubmit={(event) => {+ event.preventDefault()+ if (!connecting && !connectionSubmitDisabledReason) {+ submitConnection()+ }+ }}+ >+ {memberChooses && (+ <LemonField.Pure label="Authentication" htmlFor="mcp-gateway-connection-authentication">+ <LemonSelect<InstallCustomAuthTypeEnumApi>+ id="mcp-gateway-connection-authentication"+ value={connectionAuthType}+ onChange={setConnectionAuthType}+ options={AUTH_TYPE_OPTIONS}+ fullWidth+ />+ </LemonField.Pure>+ )}++ {connectionAuthType === 'api_key' ? (+ <LemonField.Pure+ label={isCustomServer ? 'API key (optional)' : 'API key'}+ help={+ isCustomServer+ ? 'Leave this blank if the server does not require authentication.'+ : undefined+ }+ htmlFor="mcp-gateway-connection-api-key"+ >+ <LemonInput+ id="mcp-gateway-connection-api-key"+ type="password"+ value={connectionApiKey}+ onChange={setConnectionApiKey}+ placeholder="Enter API key"+ autoFocus+ fullWidth+ />+ </LemonField.Pure>+ ) : (+ isCustomServer && (+ <LemonCollapse+ panels={[+ {+ key: 'oauth-settings',+ header: 'Advanced OAuth settings',+ content: (+ <div className="flex flex-col gap-3">+ <LemonField.Pure+ label="OAuth client ID"+ help="Leave blank to let PostHog register a client for you."+ htmlFor="mcp-gateway-connection-client-id"+ >+ <LemonInput+ id="mcp-gateway-connection-client-id"+ value={connectionClientId}+ onChange={setConnectionClientId}+ placeholder="Optional"+ fullWidth+ />+ </LemonField.Pure>+ <LemonField.Pure+ label="OAuth client secret"+ help="Only needed for confidential clients."+ htmlFor="mcp-gateway-connection-client-secret"+ >+ <LemonInput+ id="mcp-gateway-connection-client-secret"+ type="password"+ value={connectionClientSecret}+ onChange={setConnectionClientSecret}+ placeholder="Optional"+ fullWidth+ />+ </LemonField.Pure>+ </div>+ ),+ },+ ]}+ />+ )+ )}+ </form>+ </LemonModal>+ )+}diff --git a/products/mcp_store/frontend/gateway/GatewayServerScene.tsx b/products/mcp_store/frontend/gateway/GatewayServerScene.tsxindex 724338d7aa87..affcc4e0f3ae 100644--- a/products/mcp_store/frontend/gateway/GatewayServerScene.tsx+++ b/products/mcp_store/frontend/gateway/GatewayServerScene.tsx@@ -24,6 +24,7 @@ import { SceneContent } from '~/layout/scenes/components/SceneContent'import { MCPAuthTypeEnumApi, MCPToolApprovalStateEnumApi, ResolvedToolPolicyApi } from '../generated/api.schemas'import { ServerIcon } from '../scene/icons'+import { GatewayConnectionModal } from './GatewayConnectionModal'import { isPolicyStateAllowedByCeiling } from './gatewayPolicyUtils'import { GatewayRouteGuard } from './GatewayRouteGuard'import { GatewayAccessSection } from './GatewayServerAccess'@@ -120,6 +121,8 @@ export function GatewayServerScene({return (<SceneContent className="mx-auto w-full max-w-[1200px]">+ <GatewayConnectionModal />+<LemonButton size="small" type="tertiary" icon={<IconArrowLeft />} onClick={goBack}>Back to servers</LemonButton>diff --git a/products/mcp_store/frontend/gateway/GatewayServersHome.test.tsx b/products/mcp_store/frontend/gateway/GatewayServersHome.test.tsxindex 961c1841694d..9e3a3715214f 100644--- a/products/mcp_store/frontend/gateway/GatewayServersHome.test.tsx+++ b/products/mcp_store/frontend/gateway/GatewayServersHome.test.tsx@@ -63,6 +63,7 @@ function gatewayServer(): MCPGatewayServerApi {description: '',category: 'dev',template_auth_type: null,+ auth_type: null,is_team_enabled: true,icon_key: '',icon_domain: '',diff --git a/products/mcp_store/frontend/gateway/GatewayServersHome.tsx b/products/mcp_store/frontend/gateway/GatewayServersHome.tsxindex a2ba5135181e..63ebdd4cce13 100644--- a/products/mcp_store/frontend/gateway/GatewayServersHome.tsx+++ b/products/mcp_store/frontend/gateway/GatewayServersHome.tsx@@ -2,35 +2,17 @@ import { useActions, useValues } from 'kea'import { router } from 'kea-router'import { IconGear, IconPlus } from '@posthog/icons'-import {- LemonBanner,- LemonButton,- LemonCollapse,- LemonInput,- LemonModal,- LemonSelect,- LemonSnack,- LemonTag,- ProfilePicture,- Spinner,- Tooltip,-} from '@posthog/lemon-ui'+import { LemonBanner, LemonButton, LemonSnack, LemonTag, ProfilePicture, Spinner, Tooltip } from '@posthog/lemon-ui'-import { LemonField } from 'lib/lemon-ui/LemonField'import { urls } from 'scenes/urls'-import { InstallCustomAuthTypeEnumApi } from '../generated/api.schemas'import { ServerIcon } from '../scene/icons'import { GatewayAddServerModal } from './GatewayAddServerModal'+import { GatewayConnectionModal } from './GatewayConnectionModal'import { GatewayServersSearch } from './GatewayServersSearch'import { toProfileUser } from './gatewayUtils'import { GATEWAY_CATEGORY_LABELS, GatewayServerEntry, isTemplateOnlyServer, mcpGatewayLogic } from './mcpGatewayLogic'-const AUTH_TYPE_OPTIONS = [- { value: 'oauth' as const, label: 'OAuth' },- { value: 'api_key' as const, label: 'API key' },-]-export function GatewayServersLoadError({onRetry,serverDetail = false,@@ -278,159 +260,6 @@ export function GatewayServerCard({)}-function GatewayConnectionModal(): JSX.Element | null {- const {- connectionModalServer,- connectionAuthType,- connectionApiKey,- connectionClientId,- connectionClientSecret,- connectingServerId,- connectionSubmitDisabledReason,- } = useValues(mcpGatewayLogic)- const {- closeConnectionModal,- setConnectionAuthType,- setConnectionApiKey,- setConnectionClientId,- setConnectionClientSecret,- submitConnection,- } = useActions(mcpGatewayLogic)-- if (!connectionModalServer) {- return null- }-- const isCustomServer = !connectionModalServer.template_id- const connecting = connectingServerId === connectionModalServer.id- const closeModal = (): void => {- if (!connecting) {- closeConnectionModal()- }- }-- return (- <LemonModal- isOpen- onClose={closeModal}- title={`Connect ${connectionModalServer.name}`}- description={- isCustomServer- ? 'Choose how this server authenticates, then enter your personal credentials.'- : 'Enter the credentials for your personal connection.'- }- footer={- <div className="flex items-center justify-end gap-2">- <LemonButton- type="secondary"- onClick={closeModal}- disabledReason={connecting ? 'Connection in progress' : undefined}- >- Cancel- </LemonButton>- <LemonButton- type="primary"- htmlType="submit"- form="mcp-gateway-connect-server-form"- loading={connecting}- disabledReason={connectionSubmitDisabledReason ?? undefined}- >- Connect- </LemonButton>- </div>- }- width={560}- >- <form- id="mcp-gateway-connect-server-form"- className="flex flex-col gap-3"- onSubmit={(event) => {- event.preventDefault()- if (!connecting && !connectionSubmitDisabledReason) {- submitConnection()- }- }}- >- {isCustomServer && (- <LemonField.Pure label="Authentication" htmlFor="mcp-gateway-connection-authentication">- <LemonSelect<InstallCustomAuthTypeEnumApi>- id="mcp-gateway-connection-authentication"- value={connectionAuthType}- onChange={setConnectionAuthType}- options={AUTH_TYPE_OPTIONS}- fullWidth- />- </LemonField.Pure>- )}-- {connectionAuthType === 'api_key' ? (- <LemonField.Pure- label={isCustomServer ? 'API key (optional)' : 'API key'}- help={- isCustomServer- ? 'Leave this blank if the server does not require authentication.'- : undefined- }- htmlFor="mcp-gateway-connection-api-key"- >- <LemonInput- id="mcp-gateway-connection-api-key"- type="password"- value={connectionApiKey}- onChange={setConnectionApiKey}- placeholder="Enter API key"- autoFocus- fullWidth- />- </LemonField.Pure>- ) : (- isCustomServer && (- <LemonCollapse- panels={[- {- key: 'oauth-settings',- header: 'Advanced OAuth settings',- content: (- <div className="flex flex-col gap-3">- <LemonField.Pure- label="OAuth client ID"- help="Leave blank to let PostHog register a client for you."- htmlFor="mcp-gateway-connection-client-id"- >- <LemonInput- id="mcp-gateway-connection-client-id"- value={connectionClientId}- onChange={setConnectionClientId}- placeholder="Optional"- fullWidth- />- </LemonField.Pure>- <LemonField.Pure- label="OAuth client secret"- help="Only needed for confidential clients."- htmlFor="mcp-gateway-connection-client-secret"- >- <LemonInput- id="mcp-gateway-connection-client-secret"- type="password"- value={connectionClientSecret}- onChange={setConnectionClientSecret}- placeholder="Optional"- fullWidth- />- </LemonField.Pure>- </div>- ),- },- ]}- />- )- )}- </form>- </LemonModal>- )-}-function PeopleRow({ server }: { server: GatewayServerEntry }): JSX.Element {if (!server.is_team_enabled) {return <div className="text-xs text-secondary mt-1">Disabled. Enable it in Team settings.</div>diff --git a/products/mcp_store/frontend/gateway/gatewayAgentLogic.test.ts b/products/mcp_store/frontend/gateway/gatewayAgentLogic.test.tsindex 5a4df41032cb..2de3cd797222 100644--- a/products/mcp_store/frontend/gateway/gatewayAgentLogic.test.ts+++ b/products/mcp_store/frontend/gateway/gatewayAgentLogic.test.ts@@ -41,6 +41,7 @@ function gatewayServer(id: string): MCPGatewayServerApi {description: '',category: 'dev',template_auth_type: null,+ auth_type: null,is_team_enabled: true,icon_key: '',icon_domain: '',diff --git a/products/mcp_store/frontend/gateway/gatewayMemberLogic.test.ts b/products/mcp_store/frontend/gateway/gatewayMemberLogic.test.tsindex 0b8934b290b9..e12da26e0e0d 100644--- a/products/mcp_store/frontend/gateway/gatewayMemberLogic.test.ts+++ b/products/mcp_store/frontend/gateway/gatewayMemberLogic.test.ts@@ -67,6 +67,7 @@ function gatewayServer(overrides: Partial<MCPGatewayServerApi>): MCPGatewayServedescription: '',category: 'dev',template_auth_type: null,+ auth_type: null,is_team_enabled: true,icon_key: '',icon_domain: '',diff --git a/products/mcp_store/frontend/gateway/gatewayRailStatus.test.ts b/products/mcp_store/frontend/gateway/gatewayRailStatus.test.tsindex 48780813bdde..83863550f14d 100644--- a/products/mcp_store/frontend/gateway/gatewayRailStatus.test.ts+++ b/products/mcp_store/frontend/gateway/gatewayRailStatus.test.ts@@ -9,6 +9,7 @@ function gatewayServer(overrides: Partial<MCPGatewayServerApi> = {}): MCPGatewaydescription: '',category: 'dev',template_auth_type: null,+ auth_type: null,is_team_enabled: true,icon_key: '',icon_domain: '',diff --git a/products/mcp_store/frontend/gateway/gatewayServerLogic.test.ts b/products/mcp_store/frontend/gateway/gatewayServerLogic.test.tsindex 6f7ba49fd4ff..53a5cd76c22b 100644--- a/products/mcp_store/frontend/gateway/gatewayServerLogic.test.ts+++ b/products/mcp_store/frontend/gateway/gatewayServerLogic.test.ts@@ -79,6 +79,7 @@ function gatewayServer(overrides: Partial<MCPGatewayServerApi> = {}): MCPGatewaydescription: '',category: 'dev',template_auth_type: null,+ auth_type: null,is_team_enabled: true,icon_key: '',icon_domain: '',diff --git a/products/mcp_store/frontend/gateway/gatewayServerRemoval.test.ts b/products/mcp_store/frontend/gateway/gatewayServerRemoval.test.tsindex e6b35d69c733..2459ebcaeb66 100644--- a/products/mcp_store/frontend/gateway/gatewayServerRemoval.test.ts+++ b/products/mcp_store/frontend/gateway/gatewayServerRemoval.test.ts@@ -45,6 +45,7 @@ function server(overrides: Partial<MCPGatewayServerApi> = {}): MCPGatewayServerAdescription: '',category: 'dev',template_auth_type: null,+ auth_type: null,is_team_enabled: true,icon_key: '',icon_domain: '',diff --git a/products/mcp_store/frontend/gateway/mcpGatewayLogic.test.ts b/products/mcp_store/frontend/gateway/mcpGatewayLogic.test.tsindex fe8312a10d5b..dd160fed7168 100644--- a/products/mcp_store/frontend/gateway/mcpGatewayLogic.test.ts+++ b/products/mcp_store/frontend/gateway/mcpGatewayLogic.test.ts@@ -109,6 +109,7 @@ function gatewayServer(overrides: Partial<MCPGatewayServerApi>): MCPGatewayServedescription: '',category: 'dev',template_auth_type: null,+ auth_type: null,is_team_enabled: true,icon_key: '',icon_domain: '',@@ -284,6 +285,16 @@ describe('mcpGatewayLogic', () => {)})+ it('presets the connect modal to the auth type a custom server was added with', () => {+ const server = gatewayServer({ id: 'custom-server', auth_type: 'api_key' })+ logic.actions.loadServersSuccess([server])++ logic.actions.connectServer(server.id)++ expect(logic.values.connectionModalServerId).toBe(server.id)+ expect(logic.values.connectionAuthType).toBe('api_key')+ })+it('refreshes tools through the generated installation endpoint', async () => {await expectLogic(logic, () => {logic.actions.refreshServerTools('installation-id')diff --git a/products/mcp_store/frontend/gateway/mcpGatewayLogic.ts b/products/mcp_store/frontend/gateway/mcpGatewayLogic.tsindex be7725812e4e..f54a17f170aa 100644--- a/products/mcp_store/frontend/gateway/mcpGatewayLogic.ts+++ b/products/mcp_store/frontend/gateway/mcpGatewayLogic.ts@@ -95,6 +95,7 @@ function templateAsGatewayServer(template: MCPServerTemplateApi, enabled: booleadescription: template.description ?? '',category: template.category ?? 'dev',template_auth_type: template.auth_type ?? 'oauth',+ auth_type: template.auth_type ?? 'oauth',is_team_enabled: enabled,icon_key: template.icon_key,icon_domain: template.icon_domain,@@ -1392,7 +1393,7 @@ export const mcpGatewayLogic = kea<mcpGatewayLogicType>([return}- actions.openConnectionModal(serverId, server.template_auth_type ?? 'oauth')+ actions.openConnectionModal(serverId, server.auth_type ?? server.template_auth_type ?? 'oauth')},reconnectServer: ({ installationId }) => {window.location.href = getMcpServerInstallationsAuthorizeRetrieveUrl(currentProjectId(), {diff --git a/products/mcp_store/frontend/generated/api.schemas.ts b/products/mcp_store/frontend/generated/api.schemas.tsindex 7e3f486a07d8..166126d9d5e4 100644--- a/products/mcp_store/frontend/generated/api.schemas.ts+++ b/products/mcp_store/frontend/generated/api.schemas.ts@@ -499,6 +499,8 @@ export interface MCPGatewayServerApi {* * `api_key` - API Key* * `oauth` - OAuth */readonly template_auth_type: MCPAuthTypeEnumApi | null+ /** How members connect to this server: the template's type for catalog servers, or the type the custom server was added with. Null only for custom servers registered before the type was recorded; members then choose. */+ readonly auth_type: MCPAuthTypeEnumApi | nullreadonly is_team_enabled: boolean/** Deprecated brand icon key from the linked template. Empty for custom servers. */readonly icon_key: stringdiff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.tsindex 2f091ceb55b9..239c59cb9971 100644--- a/services/mcp/src/api/generated.ts+++ b/services/mcp/src/api/generated.ts@@ -49848,6 +49848,8 @@ export namespace Schemas {* * `api_key` - API Key* * `oauth` - OAuth */readonly template_auth_type: MCPAuthTypeEnum | null;+ /** How members connect to this server: the template's type for catalog servers, or the type the custom server was added with. Null only for custom servers registered before the type was recorded; members then choose. */+ readonly auth_type: MCPAuthTypeEnum | null;readonly is_team_enabled: boolean;/** Deprecated brand icon key from the linked template. Empty for custom servers. */readonly icon_key: string;