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.

feat(mcp-analytics): let teams set an icon for a custom harness (#125185)

Paul D'Ambraeab5d2aafdbe
diff --git a/docs/published/docs/mcp-analytics/harness-share.mdx b/docs/published/docs/mcp-analytics/harness-share.mdx
index 06b2ed2048b1..cc2297579ac7 100644
--- a/docs/published/docs/mcp-analytics/harness-share.mdx
+++ b/docs/published/docs/mcp-analytics/harness-share.mdx
@@ -35,6 +35,8 @@ To name an in-house harness, go to **Settings > Environment > MCP analytics > Cu
The custom name shows wherever harness names show, including the harness share card, the activity views, and `properties.$virt_mcp_harness` in SQL. Harness names are cached, so a change can take a few minutes to appear.
A SQL query or insight that already has cached results keeps the old name until those results refresh.
+You can also give a custom harness an icon. Paste a PNG, GIF or WebP image with a transparent background as a data URI, up to 16 KB and 256 by 256 pixels. The icon shows in one color, like the built-in harness logos, so it stays visible in light and dark themes. An image without a transparent background can't be saved, because it would show as a solid square.
+
## Harness labels in SQL
`properties.$virt_mcp_harness` returns the resolved harness label as a string on MCP events, and `NULL` on other events.
diff --git a/frontend/snapshots.yml b/frontend/snapshots.yml
index a0f8b00abdb3..2f2a87eee9a4 100644
--- a/frontend/snapshots.yml
+++ b/frontend/snapshots.yml
@@ -11649,7 +11649,7 @@ snapshots:
scenes-app-experiments--experiment-results-row-recording-links-unselectable-metric--dark:
hash: v1.k794b7964.699fac736eb89506d1e816e355f1ba10fcf8193182e43b1bd9e20930bc6a4442.bb5QKRMFmWZkn3VjfHV9hU-250LYkK-pt8eQHLeZAD0
scenes-app-experiments--experiment-results-row-recording-links-unselectable-metric--light:
- hash: v1.k794b7964.86e0d51a7599ef3be53003138d1f96db87c953fb47982fc6397e499b6e5f08aa.SY-Hn7-SqUQXvfW2apbmBcCG2lGhWQQd4YnQRbnhzPY
+ hash: v1.k794b7964.0d5df0b91396009b67956c851cd9a05fd20b367aad4f85ede24906be81a0529b.59YqMM71_JaTWAIBBu8JvrVW_xV_qF_wMVC-vaqAyEY
scenes-app-experiments--experiment-running-time-on-track--dark:
hash: v1.k794b7964.90ba372552ac87dfad6f48e45e24077ca3e33860fa16fecc68bdd272dd21b2f5.d6jLhdZSba5D461NeLRzQ5Wpii-VzIoSZPnzrrwHazE
scenes-app-experiments--experiment-running-time-on-track--light:
@@ -11699,9 +11699,9 @@ snapshots:
scenes-app-experiments--experiment-with-funnel-metric--light:
hash: v1.k794b7964.c2d3ede8f7326246d60c4480b1f9a14bc68bdf4d5c3240b241dd0a1d1c6bcdc5.Pky5x-yPjCHlFvzXTx3sTdFsvDJhncLayozOpJ4D1eU
scenes-app-experiments--experiment-with-health-findings--dark:
- hash: v1.k794b7964.64ce46f85be75aab2a7a9149248add7641b9e7648015f240f45cd500bf50db7f.VK_AsnHM6KI3-olzQOXmB_KdbYXohMj4Ft7GKEdgtpw
+ hash: v1.k794b7964.9be55c56333117d4413a06347d4c2df9d5e9234eeda8f82cea2ca8157f25ef40.-yufZsYFq-ObF16-FgoLIq-MSr4CPYsuhwsMosx63CM
scenes-app-experiments--experiment-with-health-findings--light:
- hash: v1.k794b7964.30bfd573066986ef7fed0859dfbb19b61f83b126232f89cb8c27857fd3a91a8c.F54-orBOQCL3Ia2c-G2F8p6HG6eHjfF8MjYDaXvyq-s
+ hash: v1.k794b7964.79a458688b20300063efaa3faef7dc00304275fefd68bcadd62300acaa89c22d.9Pn-Gk3FSDJ4niRti5zOAuiXuf-f5cZLR-jxyQA8YDw
scenes-app-experiments--experiment-with-long-flag-key--dark:
hash: v1.k794b7964.ce9a9c6de00889bc6e3fd8252d0c04cd08a49ce9ca0ad8586758788d66092a27.8Cj96tNU84pFKtXYz7OsEuWS1Vs-AuBOweBzjxL90nE
scenes-app-experiments--experiment-with-long-flag-key--light:
@@ -14187,21 +14187,21 @@ snapshots:
scenes-app-mcp-analytics--activity--light:
hash: v1.k794b7964.c04cc27b140152a363fb6e789aabcb4b4453d4798ca8fe81c460be84b1284ab5.HzUuZj5kOugUnIrnPIlW9GVDNLORwJWXcs9Le_FM9Ow
scenes-app-mcp-analytics--activity-weekly-report-offer--dark:
- hash: v1.k794b7964.789d157cb1aaa7fe614fbdc0236843b864e7e914516f4315ce12f8339c22e46d.le1K0g8TxCmW9mdUUPibKLInFDQQtk8qiV7g2xVRZ8Y
+ hash: v1.k794b7964.33409bba9973d606edad022352275c6fae1b57e8151318d600ae7dee4c5b0565.Hy07kxdUrHkfHDN2y90EHKgg5ddPZ2CdTpyptV7go2A
scenes-app-mcp-analytics--activity-weekly-report-offer--light:
- hash: v1.k794b7964.84bea3c747f0653a85a61a1ebc609dfcdea73256f22ab444b7c6643598bf1054.7ywKk4orb_d1ZFonKuc9DOC3pgRpLh_d5Gkhf2bnBWw
+ hash: v1.k794b7964.9e24f69a87a1de413332dc3fc361f918d9974de224c1b09943e1ba3b88271f48.AXk8Aqko58gjRUtMrbVRqlivD0f3xBuB8xh5o72oT1Q
scenes-app-mcp-analytics--activity-weekly-report-offer-failed--dark:
- hash: v1.k794b7964.e0733df2d22c4e393d1a5d61f75af02149e42c894f3ae030aaddf70027ed9031.a6eVLvHxsChKQvl_Jxi7gYLmbZTNnwU0vJesLu-Yl1k
+ hash: v1.k794b7964.fbbf4082cef271923820ada5aa885f3da5e2fb388d0cb034b0b92b7bb61093f4.9bFOxfZXN9z25OpQsqrQUojoIVSwnHRju4tre9xKVfc
scenes-app-mcp-analytics--activity-weekly-report-offer-failed--light:
- hash: v1.k794b7964.5633e98797141eb4e69c199f9cfac0b555b8bb7b79355c8050b76480884d6d3d.bXxZFp5KTOU-6nzuo54wDEwCdRmvPw8YoC077t0adZE
+ hash: v1.k794b7964.493ea3b2cb27965dbb750a881110462d888b7ca10574bf1aa6e531def690c02e.DO335T0cED31Y5XKCrEcF6s1xL7TsEarULG1b8ui_hc
scenes-app-mcp-analytics--activity-weekly-report-offer-narrow--dark:
hash: v1.k794b7964.58f914c4e06a5dc7a4ff15d2d5d7275422eda120054ad8acd2022ac5c9e52740.MepuCgXQOk1feYUH4PNgdD5tvqoGu1lqAIDEyPA6PLY
scenes-app-mcp-analytics--activity-weekly-report-offer-narrow--light:
hash: v1.k794b7964.658fa4dc8524b276a16f818adb63791012f6d8868a7bec2e8f8214202b775a9b.axbru-R97XHtl3u-i8RhkXLPQx33wWyk0rADnPhcxu8
scenes-app-mcp-analytics--activity-weekly-report-offer-needs-consent--dark:
- hash: v1.k794b7964.1edcf7ec1509fb522d173c17207bcd0db18f3b1266595b9d5ec046771d276226.I5uYlfiELlLmP2zkUKyV8sAlWNabVHij5YTR7Ct0TqM
+ hash: v1.k794b7964.9524bc749867331ba8050ddc929c17c36e4397305fc182825e2ce3776fa98de0.gjS8_3najJxiZTnc2satBVwKzApbVYCAgiK2ftFoCMo
scenes-app-mcp-analytics--activity-weekly-report-offer-needs-consent--light:
- hash: v1.k794b7964.3b6118de5cdbefab9a5f6f4da4e9b1a08256205e9759a7b2513ce6f910cef6f4.Zy--S0P7PsFtf0HUmt1TxJVjryb5Sai-r_w5RLDhjGU
+ hash: v1.k794b7964.ac23a6c8bb10b946fdd7484c2b37b359270dcb3ce10542b80ad184eaf4f86df5.Lvfy3XpqCRouRKsK17mN2UuAmqGm4ff23KOEq3H4nHU
scenes-app-mcp-analytics--dashboard--medium--dark:
hash: v1.k794b7964.72b34dcc72acd1363067999df342b7c8227615bd56ea444bb94157fccb94525a.p3FQs0zUXHt1njxeUQnqtD0VTUeFyh6LhoVqr6-5V3A
scenes-app-mcp-analytics--dashboard--medium--light:
@@ -14211,17 +14211,17 @@ snapshots:
scenes-app-mcp-analytics--dashboard--wide--light:
hash: v1.k794b7964.7a99a539411c23385d2ab1e0de4de21feb851976dcf301f7a1fb7a90fb3a57fb.lclXNkXG19LrcpaXMPogrc7AwHycJS8IrHwH1F1mvkU
scenes-app-mcp-analytics--dashboard-leaderboard-home--medium--dark:
- hash: v1.k794b7964.cc617d03a0676b9eab117c886f2fc514037e36f5bb563a8143b648029482d5c3.2MB3M9XRydrmy7DvX4Qy4ugJQ_J4XrHNcHH2T6uqhgw
+ hash: v1.k794b7964.64bd2c0de642fce506491eecc4c160f460ccb94a5933296c086e05700afa563d.85_Th3T5vm2HOfL2cPH7pkMR-VeBkRecVlhnW6ZK1S8
scenes-app-mcp-analytics--dashboard-leaderboard-home--medium--light:
- hash: v1.k794b7964.8869199cec304c19185a270be1ce4d5b5581dd8b45830bb0a2636d03f5ffad37.0ycaCmVvU5r9xBX5dM4cc6vKY2U1BgR0VX_6tZUvU_E
+ hash: v1.k794b7964.cab8138b4b02ba6107266cd08c7599ea8b8f06ef97216015158adfef382a8337.oKRXNFGCnzosxu5BjoAR1xVYfhOZet9UbsswryrKkCg
scenes-app-mcp-analytics--dashboard-leaderboard-home--wide--dark:
- hash: v1.k794b7964.ead69153326044d46b000996f3fe025612036c5c929e64635d890d42072ea4e2.8cifiIaJ6C4AQwYOaAP9ZgVkkACFMxH6neIVYKgc4Js
+ hash: v1.k794b7964.5f6c80fd0c30fc265b5b42b533545f3ff3dd25ccc635d790ab9e35ec17ee2077.mrPoMXNbs_ctcaKyOKah-B0qrh7HVrgAptKDNqcin5s
scenes-app-mcp-analytics--dashboard-leaderboard-home--wide--light:
- hash: v1.k794b7964.5c7c57637425377c33efd09d06857752150c6e31eb4dfa0253f17b2cf017ddd9.P8VrrTQkC0kHMLxjkLjTuDHzfwC3CeJsx7gjOOBvq9E
+ hash: v1.k794b7964.c7b2a809ca76bd2dd5c34155a01746fad65f9b4536f67cc87240a568f042676c.e65UOQ5dRv5fQ4JPlextpZ7227-G7HvWKbLQ0h0B-xE
scenes-app-mcp-analytics--dashboard-narrow--dark:
- hash: v1.k794b7964.ecb26dc86a6f09bfbbc13681cbc9fa007c4248e103f4a3b43e778eaf1f3b0de4.vmpwQjCd_B9zIyTYNvlY-aMSkfcbtOPBq-tTiuX-D68
+ hash: v1.k794b7964.46ae2b792892a86ff807665aa8f6c53ba3c94db8f185957b5b55850555d14a12.SH6F8Whdz11CVELKqfAdf7YagZdtPLzYQZCGwZE4ykQ
scenes-app-mcp-analytics--dashboard-narrow--light:
- hash: v1.k794b7964.e24e4e9b42d54ca9148fdd679c54b32e29e9d0c4109559593c70bfd139448066.GbclMfGUhtceL1P2ZSjmwJ4p928-JR_dS2nRWBw8kII
+ hash: v1.k794b7964.d683a0214b82e062143312b94daf19f35e4d4a1c50a52239e087afa981a4cbf4.sVjPKr12_CdjqKRd8w6Z4fJJL4zCej_ita8G3isQQkg
scenes-app-mcp-analytics--dashboard-with-menu-bar--dark:
hash: v1.k794b7964.144a6ed97c2ca61a084a813f45d866c1745fe3769039362a783d95d85af2708c.tEz48U3TwGvcUeb011Z12tD5aDRULZnw2t30BzXRfXI
scenes-app-mcp-analytics--dashboard-with-menu-bar--light:
@@ -14859,9 +14859,9 @@ snapshots:
scenes-app-posthog-ai--thread--light:
hash: v1.k794b7964.2b3e53d46e15e282dccdbc3344af068b802b94150084909f88a9375df3037590.8oP4_JUEugY8LGyu3CeDSM3Rg_lN0Elf-0-gPbkjW3E
scenes-app-posthog-ai--thread-scrolls-to-bottom-on-new-messages--dark:
- hash: v1.k794b7964.da8402be87202863d7e0e2af0a4ae9dcbcbac35ffe7c0b757b38951535b82b24._ElslncXCpARNkPdX-SHcQ-iGQLPPHJAzhnDIcAm3ZA
+ hash: v1.k794b7964.b12db8da6e218d4708fd449f6a113a5de453dc839bbf4e78e1f127b668f4f1f8.Ban8Ddgbf4AWkCzn11HqzM20U8BO-ybv4RMrrHhabco
scenes-app-posthog-ai--thread-scrolls-to-bottom-on-new-messages--light:
- hash: v1.k794b7964.190ad314871531acde732e698d8da8e63e9251c0798a1ccf70f2b45ddadd8018.MmIUN_Gb-WT6cHpmMOCW9VjzM4jWjgTB_fIP1ztNsM0
+ hash: v1.k794b7964.3f33b6fbc9f5decb7d749e0d078e3bf58bd1f4a3ce7878a143fc2319ea63e142.xAPECnGDzc3FNCVddWNDAreW0k-AyD5r1VWW--HGn7g
scenes-app-posthog-ai--thread-with-billing-limit-exceeded--dark:
hash: v1.k794b7964.a0d21c8c69c049c37c367b855ea3dd19101d1194a9acf37dfa02fc3207be2351.L7hSSTjk8fML5gmTu4hX60CZJZ1S6pbMxZ_kefFURNs
scenes-app-posthog-ai--thread-with-billing-limit-exceeded--light:
@@ -15575,7 +15575,7 @@ snapshots:
scenes-app-settings-authentication-domains--redesigned-needs-upgrade--light:
hash: v1.k794b7964.c30fe74ff364064355eba2a1458d90e1f206bba61c100c24ed7f0c6bd1da24a5.sYWeEL_3liphnWLFjVI7H5rEZyXuU8Z_nlxy0FsiytM
scenes-app-settings-environment--settings-environment-access-control--dark:
- hash: v1.k794b7964.871f7ea964a0959bbc8dde537c8bc492525be49de38a24eea41272cd53cfa7f8.VmBRzOky9SgrQdLyBgQBJp7ub48B3d8v-kr7gC8hQE4
+ hash: v1.k794b7964.5f7fd7e35d8201d192111062100eddd413684893dfaffb30dd17ea7c616899b2.T44HrIdYyGpEXriYH3smTgQIUJDSRU-zGZYy5vJeWj0
scenes-app-settings-environment--settings-environment-access-control--light:
hash: v1.k794b7964.77a882b0fc251bd3cf170be462b5ca24b894d6b3476350de30d0db7754ee4d3f.90qlzpcTtsKiLqG7QEOyJnH_GU-Sk-3yefrrLYiAbqg
scenes-app-settings-environment--settings-environment-activity-logs--dark:
@@ -15599,9 +15599,9 @@ snapshots:
scenes-app-settings-environment--settings-environment-ai-subscriptions-codex-reauth-required--light:
hash: v1.k794b7964.931c6017abad7c503f7b89c06013d223ff5684313f7d23c1b91a495ab97a0028.EYFwROwpv-FFpD82a3ZP2nWhmQGMSwB2-4qalbUsTEU
scenes-app-settings-environment--settings-environment-autocapture--dark:
- hash: v1.k794b7964.56096a09bec1006fb0e4b5612885ce68772720d88fe37f80545b8e14132fc25b.7zYnO0IG486ncAsZOKOZV8hBKLMzOaz_KyTjro9ui4U
+ hash: v1.k794b7964.56d79cec11a0d6e04e92282aaade7a00464933ced552700cf5ef8497a05bf752.ra-2X6H76OE3PMleDRgYi823ziaYWvlZ_D2RIh_tn1s
scenes-app-settings-environment--settings-environment-autocapture--light:
- hash: v1.k794b7964.56db0fa80553816d40b77ce765f3ed25e87ff20425be2c2c6c0297488d103c56.asc3Fh9qnSt4RV8_MRVHzC64XJ7aMXkTuXUkXeWx6Tc
+ hash: v1.k794b7964.465259f69a785bd417a92b3886e3bbaca6a5401cc83624299522184dabce1602.Uu5jhncTLcENHVZOyO3q4tpkzYq3QCZSAy5SAufkPGE
scenes-app-settings-environment--settings-environment-business-knowledge--dark:
hash: v1.k794b7964.228d2385f3647a8b0186fb62ccb6f06dddc05136160dbebedca6c0780b49a081.6k8tSnexmnS08sACFI71MiU6WtR4BoJxhGVzdUxO3cw
scenes-app-settings-environment--settings-environment-business-knowledge--light:
@@ -15683,25 +15683,25 @@ snapshots:
scenes-app-settings-environment--settings-environment-product-analytics--light:
hash: v1.k794b7964.6e93a56f0a0044c8890183b394526e343728ef52a19c1978570aa9f21d5baf2e.PeEwAFTw2YIZQ0d81mQaILaS4DqcuYFiLnUpJmZKrkM
scenes-app-settings-environment--settings-environment-replay--dark:
- hash: v1.k794b7964.23072058a8475921de34266eaed3fa6e1fe90fd92268fd29e6579df6c307d58d.30xm0MdMcOZ4dc_u2gZn1RehE5NPBWLX1zBnX3urXT0
+ hash: v1.k794b7964.a46646edf4a396608d13ace60c5905c881b692b5ff0a51001cebff0548c2d02b.TbwtAeCfxzj4DA0bosxJZBUgHkm5i4wfX3KFHtqrI7w
scenes-app-settings-environment--settings-environment-replay--light:
hash: v1.k794b7964.edf975e83407a4ee20a81b8217041ec9689600ce01b2aac50860d37fcc674c1a.zmQy_laVu9NACTqQUC6OI65p_kXgmBOoWZqfHKgUwhs
scenes-app-settings-environment--settings-environment-revenue-analytics--dark:
hash: v1.k794b7964.4ea09b55bbe15fec6cdcb8030bf347e4b816fd3935a27aeeed2348a21d152406.JUGIyde9-AVrSBZ6bEYn0RbTsai9Stwnqu0VjP9wBvM
scenes-app-settings-environment--settings-environment-revenue-analytics--light:
- hash: v1.k794b7964.4485d1a4bec0c38273b87f389f024a95eb6da008b229c483c069e5a69f01086c.e60iO8T_BXdlCmtpJCRC4ezDYp3AUy-DyGUwNr_-yMw
+ hash: v1.k794b7964.28fb75c3fb48cf4f42391b7c9ae7dd7207c84c08ccd65615e0bec59a5a883a97.TPP3s4NOcq3BJQZjD8YJE9Pce4d45j7r6ILQff6iTwI
scenes-app-settings-environment--settings-environment-surveys--dark:
- hash: v1.k794b7964.d67715f4a7ac3a63220b7dca2699b0d15b5724a16207a3c08e0a1065689b0e74.NXo9vVTDQR4cz9kI-M01UbmxhCZxEXPmrnFOp0rOK1c
+ hash: v1.k794b7964.eae455b08bb1d3e5755fb948ea92075324051396620cb99d902ad2d8c66fc22b.zbI0tfhHcDdk9HZM3dY54yHHn6qUFfwPpHcj6mzPuWg
scenes-app-settings-environment--settings-environment-surveys--light:
hash: v1.k794b7964.e9827e5efbfff9b19d1b4f098f696ad6d296f6add9613ce8ffbe009cc6fded44.l7ZGtwkwtPW0kyb9a-szWxrK6JH4AmtiTJ_lYSUeu7s
scenes-app-settings-environment--settings-environment-web-analytics--dark:
- hash: v1.k794b7964.e0931458e04f6cb7d40aecaabddcb30a857eff42fdc4a74273e3795a0f4a02fa.PLdjJffI2Xgp1gYuq6PUcMg4IT6BhMz7Rh5PyrH6PVg
+ hash: v1.k794b7964.4eb3b9dbab28f073eee1539ce28432547e85a41c499ee95c488465a5bf89eb6f.6pWNDFX_tGOvFobThL_9cVyZSLbobpm0c44SnSXc5p4
scenes-app-settings-environment--settings-environment-web-analytics--light:
hash: v1.k794b7964.325010cf6189e34c2180eecbee28ed168fc787a7685572fbf22e0452d9a25e59.CwjnFv1AQ35ES1bCjZD4hTVI1thvG8vkTZcK8OcshK4
scenes-app-settings-environment--settings-mcp-analytics-custom-harnesses--dark:
- hash: v1.k794b7964.df973fb99b893b28effeb6f733727e78b59de05b6127a7581276c173d7e2ef47.V1hQUYekUibTaCAYQFIYyXWD5GnEe52sD5iM27GzCF0
+ hash: v1.k794b7964.8b9284d27c164bda6e3890920f638b4a3fcac7a43bf3229340e854588a431fea.wIRwiaah0nvMmvF4AotThQ1Wb_gT1kYUl6qkng1e6j4
scenes-app-settings-environment--settings-mcp-analytics-custom-harnesses--light:
- hash: v1.k794b7964.3875068aeaaae4362be669bb24ff49ff2711bbc6debd59936efe4775d5139b99.Fo9QIunWQUmiohIa68dwCJbKXmR5vHasn3LmC1q9Qic
+ hash: v1.k794b7964.739286ce54a536935803a95291c59afd23cc6bcfe9b9f6b20e0238fa71f716f6.N_lEUUCeTMgiZ87CqiWEFgIWQc11eGi_pmjXy-jAcBQ
scenes-app-settings-events-retention--organization-on-free-plan--dark:
hash: v1.k794b7964.b075e1de23700cf59e5e17cc0dbe15496d9e7ee89677ca11110b5507b17da120.ud-PQDmvtjOEehGDRhgCKwok3Fivo8yrPTs1kHt81bU
scenes-app-settings-events-retention--organization-on-free-plan--light:
@@ -15847,17 +15847,17 @@ snapshots:
scenes-app-settings-project--settings-project-logs-read-only--light:
hash: v1.k794b7964.e234f3e555bcb083ca96f00005f91ccccf94941d371c71497162169077ec1022.jNkdKOK2KaEq2T2jksEoVtN5Nupa3FuJLTe-npm0RIM
scenes-app-settings-project--settings-project-product-analytics--dark:
- hash: v1.k794b7964.529b8a14def21f75abb918da34abaf0a524a8720b3f9599a3eeb48671d07cff3.-JfMwFboJNDpq4FrmTbNszaP0fCugCUmGBuLNHHYxso
+ hash: v1.k794b7964.8a963da58fa99b6acdf197916fbdf422adb1e9dd68bd81637fbd20baaad9c78f.v6LWZwU6s1_tM75hEG0TmhqD3pDi8VR1xu1lF1ZolEM
scenes-app-settings-project--settings-project-product-analytics--light:
- hash: v1.k794b7964.358161090967d5a58270dd749e6cdee2ad7cdd9466e468f65553da25bcff2cfc.tHrFn5rQ9KQUUGImXMgECrd4gIZ-9kbFxQ0ou8l8CBk
+ hash: v1.k794b7964.685a12656844e55092ae236a803d6e9dcbf9a942f8084f4998981c1a423d1402.PGTyB8W223c6tMa_W5tXIC7ZK8EZo6IxJ65RphcvcIA
scenes-app-settings-project--settings-project-replay--dark:
hash: v1.k794b7964.23072058a8475921de34266eaed3fa6e1fe90fd92268fd29e6579df6c307d58d.gw0d3spnFf9PQ-Xj1B8BCH3_o3i5xsYnvFSkS1pChkU
scenes-app-settings-project--settings-project-replay--light:
hash: v1.k794b7964.7240efb5fccffca8220ccaa97c7fa9ef1906ccaa383c6faa0f78ae749867cff1.ISbk1sPJYUjwH0fhLkkDAtu3JqUwNaogGUXqnm8lvSs
scenes-app-settings-project--settings-project-surveys--dark:
- hash: v1.k794b7964.ca0e0482b9545481080491615a78c9abbe4772832296692aab8c109d2f7c4416.T6MhSTS2muKOj9OCxii68YK1bVkCsHoT8yX8UrHDf5U
+ hash: v1.k794b7964.a78de3ce7c8a25dbd86d50788e6d0d3a21ddc722cf3589d96040d7f0e6197000.62sB63JQRXZ0wQiQcJ0-nPC2E-rtHVYaEXX4_f0KTVE
scenes-app-settings-project--settings-project-surveys--light:
- hash: v1.k794b7964.52c30137e43554a5b10c1b8450e92b1b2b4d52c417aef5ae5b237f8574188ed4.XaAAahFfqjW4beeP5a4ZUS2i0m2YZz9shiRcsI6knOo
+ hash: v1.k794b7964.89d7b93c8b54a5e89e9f0ca65d13e6129dc0e89e6e4e50c4468d0a40f3246832.30k-vIAsZC_tu3PaSvGVSrt29OeGydHTpeTtnupm2U0
scenes-app-settings-settingsectionunavailable--admin-only--dark:
hash: v1.k794b7964.b6580b1a9c7735f0b03e9d5b58954169a1772b47bc2ae449f14771e1c5281a7b.Pp01b8BavwsYTSE4Mo3Q57hwN0X73qsh7JDbp7_DORo
scenes-app-settings-settingsectionunavailable--admin-only--light:
diff --git a/frontend/src/queries/nodes/HogQLX/render.test.tsx b/frontend/src/queries/nodes/HogQLX/render.test.tsx
index c2bc5617f1f2..499a04d8b4ee 100644
--- a/frontend/src/queries/nodes/HogQLX/render.test.tsx
+++ b/frontend/src/queries/nodes/HogQLX/render.test.tsx
@@ -4,6 +4,8 @@ import { render } from '@testing-library/react'
import { parseHogQLX, renderHogQLX } from '~/queries/nodes/HogQLX/render'
+import { mcpCustomHarnessesLogic } from 'products/mcp_analytics/frontend/settings/mcpCustomHarnessesLogic'
+
describe('HogQLX', () => {
describe('parse', () => {
it('should parse tags', () => {
@@ -148,6 +150,8 @@ describe('HogQLX', () => {
expect(container.textContent).toContain('Claude Code')
expect(container.querySelector('svg')).not.toBeNull()
+ // Any query can render this label, so it must not load MCP analytics data.
+ expect(mcpCustomHarnessesLogic.isMounted()).toBe(false)
}
)
diff --git a/frontend/src/scenes/settings/stories/SettingsEnvironment.stories.tsx b/frontend/src/scenes/settings/stories/SettingsEnvironment.stories.tsx
index 8fc5a6129916..5808c63f7f57 100644
--- a/frontend/src/scenes/settings/stories/SettingsEnvironment.stories.tsx
+++ b/frontend/src/scenes/settings/stories/SettingsEnvironment.stories.tsx
@@ -413,6 +413,7 @@ export const SettingsMcpAnalyticsCustomHarnesses: Story = {
id: '0193f2a1-0000-7000-8000-000000000001',
name: 'Acme agent',
match_pattern: 'acme-agent',
+ icon: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAApUlEQVR42tWX3Q2AMAiEW+IaOpDOqwPpIPXVmGJpQX54VXrcV6K5lIwrYw/mtRRJoevImTSAtHBrENAUr2mApnhNC6yXELTdvymwCZy7AAGuOGcIHzsggX6UQkwCmNsRCvEItFz2UohFgOquh0IcAr13S30/BoHRrxylzz8B7u+21e+bANc95Zzpq3HZlAhgoUEjH/jZAU0KTy2g5Lc/o5l5ODWvGwdJQtrvVp3WAAAAAElFTkSuQmCC',
created_at: '2023-05-20T10:00:00Z',
updated_at: '2023-05-20T10:00:00Z',
},
@@ -420,6 +421,7 @@ export const SettingsMcpAnalyticsCustomHarnesses: Story = {
id: '0193f2a1-0000-7000-8000-000000000002',
name: 'Support bot',
match_pattern: 'support-bot',
+ icon: '',
created_at: '2023-05-21T10:00:00Z',
updated_at: '2023-05-21T10:00:00Z',
},
diff --git a/products/mcp_analytics/backend/custom_harness_icons.py b/products/mcp_analytics/backend/custom_harness_icons.py
new file mode 100644
index 000000000000..230cab29eac0
--- /dev/null
+++ b/products/mcp_analytics/backend/custom_harness_icons.py
@@ -0,0 +1,63 @@
+import io
+import re
+import base64
+import binascii
+
+from django.core.exceptions import ValidationError
+
+from PIL import Image, UnidentifiedImageError
+
+MAX_HARNESS_ICON_BYTES = 16 * 1024
+MAX_HARNESS_ICON_SIDE_PX = 256
+# The icon shows as a one-color mask, so without transparent pixels it is a plain square.
+MIN_TRANSPARENT_PIXEL_SHARE = 0.1
+
+# SVG is left out on purpose: it can carry script, and only a raster image can be decoded and checked here.
+# Pillow opens only these formats, so no other decoder ever runs on the uploaded bytes.
+_PIL_FORMATS_BY_SUBTYPE = {"png": ["PNG"], "gif": ["GIF"], "webp": ["WEBP"]}
+_DATA_URI = re.compile(r"data:image/(png|gif|webp);base64,([A-Za-z0-9+/]+={0,2})")
+# Base64 needs 4 characters for every 3 bytes, plus the short prefix.
+_MAX_DATA_URI_LENGTH = MAX_HARNESS_ICON_BYTES * 4 // 3 + 64
+
+
+def validate_harness_icon(value: str) -> None:
+ """Raise unless `value` is empty or a small base64 PNG, GIF or WebP data URI with a transparent background."""
+ if value == "":
+ return
+ if len(value) > _MAX_DATA_URI_LENGTH:
+ raise ValidationError(f"The icon must be {MAX_HARNESS_ICON_BYTES // 1024} KB or smaller.")
+
+ match = _DATA_URI.fullmatch(value)
+ if match is None:
+ raise ValidationError("Paste a PNG, GIF or WebP image as a base64 data URI.")
+ subtype, encoded = match.groups()
+
+ try:
+ raw = base64.b64decode(encoded, validate=True)
+ except binascii.Error:
+ raise ValidationError("The icon is not valid base64.")
+ if len(raw) > MAX_HARNESS_ICON_BYTES:
+ raise ValidationError(f"The icon must be {MAX_HARNESS_ICON_BYTES // 1024} KB or smaller.")
+
+ formats = _PIL_FORMATS_BY_SUBTYPE[subtype]
+ try:
+ with Image.open(io.BytesIO(raw), formats=formats) as image:
+ width, height = image.size
+ if max(width, height) > MAX_HARNESS_ICON_SIDE_PX:
+ raise ValidationError(
+ f"The icon must be {MAX_HARNESS_ICON_SIDE_PX} by {MAX_HARNESS_ICON_SIDE_PX} pixels or smaller."
+ )
+ # Only the first frame is checked and decoded, so a later frame could be any size.
+ if getattr(image, "is_animated", False):
+ raise ValidationError("The icon must be a still image, not an animation.")
+ image.verify()
+ # verify() checks structure only and leaves the image unusable, so decode the pixels from a fresh open.
+ with Image.open(io.BytesIO(raw), formats=formats) as image:
+ image.load()
+ transparent_pixels = image.convert("RGBA").getchannel("A").histogram()[0]
+ except (UnidentifiedImageError, OSError, SyntaxError, ValueError, Image.DecompressionBombError):
+ raise ValidationError(f"The icon is not a valid image/{subtype} image.")
+ if transparent_pixels < width * height * MIN_TRANSPARENT_PIXEL_SHARE:
+ raise ValidationError(
+ "The icon needs a transparent background. Save the logo as a PNG, GIF or WebP with transparency around it."
+ )
diff --git a/products/mcp_analytics/backend/facade/constants.py b/products/mcp_analytics/backend/facade/constants.py
index f4ed24fff54c..077875d47687 100644
--- a/products/mcp_analytics/backend/facade/constants.py
+++ b/products/mcp_analytics/backend/facade/constants.py
@@ -1,6 +1,12 @@
from products.mcp_analytics.backend.constants import MCP_MISSING_CAPABILITY_EVENT
-from products.mcp_analytics.backend.mcp_harness import UNIDENTIFIED_HARNESS_LABEL
+from products.mcp_analytics.backend.mcp_harness import HARNESS_LABELS, MARKED_CLIENT_NAMES, UNIDENTIFIED_HARNESS_LABEL
MAX_CUSTOM_HARNESSES = 20
-__all__ = ["MAX_CUSTOM_HARNESSES", "MCP_MISSING_CAPABILITY_EVENT", "UNIDENTIFIED_HARNESS_LABEL"]
+__all__ = [
+ "HARNESS_LABELS",
+ "MARKED_CLIENT_NAMES",
+ "MAX_CUSTOM_HARNESSES",
+ "MCP_MISSING_CAPABILITY_EVENT",
+ "UNIDENTIFIED_HARNESS_LABEL",
+]
diff --git a/products/mcp_analytics/backend/mcp_harness.py b/products/mcp_analytics/backend/mcp_harness.py
index 84222ba226e7..1835490265ea 100644
--- a/products/mcp_analytics/backend/mcp_harness.py
+++ b/products/mcp_analytics/backend/mcp_harness.py
@@ -250,3 +250,7 @@ HARNESS_LABELS: tuple[str, ...] = (
"PostHog CLI",
"Other",
)
+
+# Client names the classifier keeps as they are, but that the frontend shows with a brand mark
+# (`HARNESS_BY_LABEL` in harnessRegistry.ts). A frontend test pins that map to these two tuples.
+MARKED_CLIENT_NAMES: tuple[str, ...] = ("PostHog AI", "Slack")
diff --git a/products/mcp_analytics/backend/migrations/0013_mcpcustomharness_icon.py b/products/mcp_analytics/backend/migrations/0013_mcpcustomharness_icon.py
new file mode 100644
index 000000000000..6b77a58bd144
--- /dev/null
+++ b/products/mcp_analytics/backend/migrations/0013_mcpcustomharness_icon.py
@@ -0,0 +1,21 @@
+from django.db import migrations, models
+
+import products.mcp_analytics.backend.custom_harness_icons
+
+
+class Migration(migrations.Migration):
+ dependencies = [
+ ("mcp_analytics", "0012_mcpcustomharness"),
+ ]
+
+ operations = [
+ migrations.AddField(
+ model_name="mcpcustomharness",
+ name="icon",
+ field=models.TextField(
+ blank=True,
+ default="",
+ validators=[products.mcp_analytics.backend.custom_harness_icons.validate_harness_icon],
+ ),
+ ),
+ ]
diff --git a/products/mcp_analytics/backend/migrations/max_migration.txt b/products/mcp_analytics/backend/migrations/max_migration.txt
index 2a715cb0ba8a..a90b99987249 100644
--- a/products/mcp_analytics/backend/migrations/max_migration.txt
+++ b/products/mcp_analytics/backend/migrations/max_migration.txt
@@ -1 +1 @@
-0012_mcpcustomharness
+0013_mcpcustomharness_icon
diff --git a/products/mcp_analytics/backend/models.py b/products/mcp_analytics/backend/models.py
index 9b12b8950998..debf19eee5be 100644
--- a/products/mcp_analytics/backend/models.py
+++ b/products/mcp_analytics/backend/models.py
@@ -6,6 +6,8 @@ from django.db import models
from posthog.models.scoping.root_mixin import TeamScopedRootMixin
from posthog.models.utils import UUIDModel
+from products.mcp_analytics.backend.custom_harness_icons import validate_harness_icon
+
class MCPIntentClusterSnapshot(TeamScopedRootMixin):
class Status(models.TextChoices):
@@ -139,6 +141,7 @@ class MCPCustomHarness(UUIDModel, TeamScopedRootMixin):
max_length=100,
validators=[RegexValidator(r"^[a-z0-9._ /-]+$", "Use lowercase letters, numbers, spaces and . _ / - only.")],
)
+ icon = models.TextField(blank=True, default="", validators=[validate_harness_icon])
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)
diff --git a/products/mcp_analytics/backend/presentation/serializers.py b/products/mcp_analytics/backend/presentation/serializers.py
index 6a28017493c1..d7a4d19ce7bd 100644
--- a/products/mcp_analytics/backend/presentation/serializers.py
+++ b/products/mcp_analytics/backend/presentation/serializers.py
@@ -1,6 +1,6 @@
import json
from datetime import datetime
-from typing import Any
+from typing import TYPE_CHECKING, Any
from django.core.exceptions import ValidationError as DjangoValidationError
from django.db import IntegrityError, transaction
@@ -15,9 +15,17 @@ from posthog.schema import (
SessionPropertyFilter,
)
-from products.mcp_analytics.backend.facade.constants import MAX_CUSTOM_HARNESSES, UNIDENTIFIED_HARNESS_LABEL
+from products.mcp_analytics.backend.facade.constants import (
+ HARNESS_LABELS,
+ MARKED_CLIENT_NAMES,
+ MAX_CUSTOM_HARNESSES,
+ UNIDENTIFIED_HARNESS_LABEL,
+)
from products.mcp_analytics.backend.models import MCPAnalyticsSubmission, MCPCustomHarness
+if TYPE_CHECKING:
+ from django.db.models import QuerySet
+
_PROPERTY_FILTERS_ADAPTER: pydantic.TypeAdapter[list[AnyPropertyFilterDiscriminated]] = pydantic.TypeAdapter(
list[AnyPropertyFilterDiscriminated]
)
@@ -870,6 +878,9 @@ class MCPMissingCapabilityCreateSerializer(MCPAnalyticsSubmissionContextSerializ
DUPLICATE_MATCH_PATTERN_ERROR = "A custom harness already uses this pattern."
+_BUILT_IN_HARNESS_LABELS = frozenset(
+ label.lower() for label in (*HARNESS_LABELS, *MARKED_CLIENT_NAMES, UNIDENTIFIED_HARNESS_LABEL)
+)
class MCPCustomHarnessSerializer(serializers.ModelSerializer):
@@ -883,15 +894,34 @@ class MCPCustomHarnessSerializer(serializers.ModelSerializer):
class Meta:
model = MCPCustomHarness
- fields = ["id", "name", "match_pattern", "created_at", "updated_at"]
+ fields = ["id", "name", "match_pattern", "icon", "created_at", "updated_at"]
read_only_fields = ["id", "created_at", "updated_at"]
- extra_kwargs = {"name": {"help_text": "Name to show for calls from this harness."}}
+ extra_kwargs = {
+ "name": {"help_text": "Name to show for calls from this harness."},
+ "icon": {
+ "help_text": (
+ "Optional icon shown next to the harness name. A base64 data URI of a PNG, GIF or WebP image "
+ "with a transparent background, 16 KB or smaller and at most 256 by 256 pixels. The icon shows "
+ "in one color, like the built-in harness logos. An empty string means no icon."
+ )
+ },
+ }
+
+ def _other_team_harnesses(self) -> "QuerySet[MCPCustomHarness]":
+ others = MCPCustomHarness.objects.for_team(self.context["get_team"]().id)
+ return others.exclude(pk=self.instance.pk) if self.instance is not None else others
def validate_name(self, value: str) -> str:
- # The dashboard gives these two labels their own meaning, so a team rule must not produce them.
- if value.strip().lower() in {"other", UNIDENTIFIED_HARNESS_LABEL.lower()}:
- raise serializers.ValidationError(f"{value.strip()} is a built-in label. Choose another name.")
- return value
+ name = value.strip()
+ if self.instance is not None and name == self.instance.name:
+ return name
+ # The dashboard shows its own logo for a built-in label, so a team rule with that name would lose its icon.
+ if name.lower() in _BUILT_IN_HARNESS_LABELS:
+ raise serializers.ValidationError(f"{name} is a built-in label. Choose another name.")
+ # The dashboard finds a harness icon by name, so two rules with one name would share one icon.
+ if self._other_team_harnesses().filter(name__iexact=name).exists():
+ raise serializers.ValidationError("Another custom harness already uses this name.")
+ return name
def validate_match_pattern(self, value: str) -> str:
pattern = value.strip().lower()
@@ -902,10 +932,7 @@ class MCPCustomHarnessSerializer(serializers.ModelSerializer):
return pattern
def validate(self, attrs: dict[str, Any]) -> dict[str, Any]:
- team_id = self.context["get_team"]().id
- others = MCPCustomHarness.objects.for_team(team_id)
- if self.instance is not None:
- others = others.exclude(pk=self.instance.pk)
+ others = self._other_team_harnesses()
if "match_pattern" in attrs and others.filter(match_pattern=attrs["match_pattern"]).exists():
raise serializers.ValidationError({"match_pattern": DUPLICATE_MATCH_PATTERN_ERROR})
if self.instance is None and others.count() >= MAX_CUSTOM_HARNESSES:
diff --git a/products/mcp_analytics/backend/tests/test_custom_harness_icons.py b/products/mcp_analytics/backend/tests/test_custom_harness_icons.py
new file mode 100644
index 000000000000..3ced35ab4469
--- /dev/null
+++ b/products/mcp_analytics/backend/tests/test_custom_harness_icons.py
@@ -0,0 +1,107 @@
+import io
+import zlib
+import base64
+import struct
+
+from django.core.exceptions import ValidationError
+from django.test import SimpleTestCase
+
+from parameterized import parameterized
+from PIL import Image
+
+from products.mcp_analytics.backend.custom_harness_icons import validate_harness_icon
+
+
+def _logo(size: tuple[int, int] = (16, 16), color: tuple[int, int, int] = (200, 40, 40)) -> Image.Image:
+ image = Image.new("RGBA", size, (0, 0, 0, 0))
+ image.paste((*color, 255), (size[0] // 4, size[1] // 4, size[0] * 3 // 4, size[1] * 3 // 4))
+ return image
+
+
+def _encode(mime: str, image: Image.Image, pil_format: str, **save_args: object) -> str:
+ buffer = io.BytesIO()
+ image.save(buffer, format=pil_format, **save_args)
+ return f"data:{mime};base64,{base64.b64encode(buffer.getvalue()).decode()}"
+
+
+def _image_data_uri(mime: str, pil_format: str, size: tuple[int, int] = (16, 16)) -> str:
+ return _encode(mime, _logo(size), pil_format)
+
+
+def _two_frame_data_uri(mime: str, pil_format: str) -> str:
+ return _encode(mime, _logo(), pil_format, save_all=True, append_images=[_logo(color=(40, 40, 200))])
+
+
+def _almost_opaque_png_data_uri() -> str:
+ image = Image.new("RGBA", (16, 16), (200, 40, 40, 255))
+ image.putpixel((0, 0), (0, 0, 0, 0))
+ return _encode("image/png", image, "PNG")
+
+
+def _png_chunk(kind: bytes, data: bytes) -> bytes:
+ return struct.pack(">I", len(data)) + kind + data + struct.pack(">I", zlib.crc32(kind + data))
+
+
+def _handmade_png_data_uri(width: int, height: int, pixel_data: bytes, extra: bytes = b"") -> str:
+ """A PNG with valid chunk checksums whose header and pixels can say anything."""
+ header = struct.pack(">IIBBBBB", width, height, 8, 2, 0, 0, 0)
+ png = (
+ b"\x89PNG\r\n\x1a\n"
+ + _png_chunk(b"IHDR", header)
+ + extra
+ + _png_chunk(b"IDAT", pixel_data)
+ + _png_chunk(b"IEND", b"")
+ )
+ return f"data:image/png;base64,{base64.b64encode(png).decode()}"
+
+
+class TestValidateHarnessIcon(SimpleTestCase):
+ @parameterized.expand(
+ [
+ ("empty_means_no_icon", ""),
+ ("png", _image_data_uri("image/png", "PNG")),
+ ("gif", _image_data_uri("image/gif", "GIF")),
+ ("webp", _image_data_uri("image/webp", "WEBP")),
+ ]
+ )
+ def test_accepts(self, _name: str, value: str) -> None:
+ validate_harness_icon(value)
+
+ @parameterized.expand(
+ [
+ ("jpeg_has_no_transparency", _encode("image/jpeg", Image.new("RGB", (16, 16)), "JPEG")),
+ ("png_without_alpha", _encode("image/png", Image.new("RGB", (16, 16), (200, 40, 40)), "PNG")),
+ ("png_with_an_opaque_background", _encode("image/png", Image.new("RGBA", (16, 16), "white"), "PNG")),
+ ("png_with_almost_no_transparent_pixels", _almost_opaque_png_data_uri()),
+ ("svg_can_carry_script", "data:image/svg+xml;base64," + base64.b64encode(b"<svg></svg>").decode()),
+ ("not_a_data_uri", "https://example.com/icon.png"),
+ ("not_base64", "data:image/png;base64,not base64!"),
+ ("trailing_newline", _image_data_uri("image/png", "PNG") + "\n"),
+ ("not_a_png", "data:image/png;base64," + base64.b64encode(b"hello").decode()),
+ ("type_does_not_match_content", _image_data_uri("image/png", "GIF")),
+ ("too_wide", _image_data_uri("image/png", "PNG", size=(300, 10))),
+ ("decompression_bomb", _handmade_png_data_uri(20_000, 20_000, zlib.compress(b""))),
+ ("pixels_do_not_decode", _handmade_png_data_uri(16, 16, b"not zlib data")),
+ ("animated_gif", _two_frame_data_uri("image/gif", "GIF")),
+ ("animated_webp", _two_frame_data_uri("image/webp", "WEBP")),
+ ("bmp_declared_as_png", _image_data_uri("image/png", "BMP")),
+ (
+ "gif_frame_outside_the_screen",
+ "data:image/gif;base64,"
+ "R0lGODdhEAAQAFcAAAECAwAAAAAsAAAAACwAAAAAEAAQxUAIHQCUCBxIsKDBgwgTKlzIsKHDixAjSpxIsaLFrAEBADs=",
+ ),
+ (
+ "text_chunk_too_large_to_expand",
+ _handmade_png_data_uri(
+ 16,
+ 16,
+ zlib.compress(b"\x00" * 16 * 49),
+ extra=_png_chunk(b"zTXt", b"k\x00\x00" + zlib.compress(b"a" * 2_000_000)),
+ ),
+ ),
+ ("too_many_bytes", "data:image/png;base64," + base64.b64encode(b"\x00" * 20_000).decode()),
+ ]
+ )
+ def test_rejects(self, _name: str, value: str) -> None:
+ with self.assertRaises(ValidationError):
+ validate_harness_icon(value)
diff --git a/products/mcp_analytics/backend/tests/test_presentation.py b/products/mcp_analytics/backend/tests/test_presentation.py
index 83f2bf9ad7ba..956690b08f26 100644
--- a/products/mcp_analytics/backend/tests/test_presentation.py
+++ b/products/mcp_analytics/backend/tests/test_presentation.py
@@ -662,6 +662,9 @@ class TestMCPCustomHarnessEndpoint(_MCPAnalyticsTeamScopedTestMixin, APIBaseTest
("empty_pattern", {"name": "Ok", "match_pattern": " "}),
("reserved_other", {"name": "other", "match_pattern": "ok"}),
("reserved_unidentified", {"name": "Unidentified client", "match_pattern": "ok"}),
+ ("built_in_harness_label", {"name": " cursor ", "match_pattern": "ok"}),
+ ("name_the_frontend_gives_a_mark", {"name": "Slack", "match_pattern": "ok"}),
+ ("icon_not_an_image", {"name": "Ok", "match_pattern": "ok", "icon": "data:text/plain;base64,aGk="}),
]
)
def test_create_rejects_unsafe_values(self, _name: str, payload: dict[str, str]) -> None:
@@ -680,6 +683,45 @@ class TestMCPCustomHarnessEndpoint(_MCPAnalyticsTeamScopedTestMixin, APIBaseTest
over_limit = self.client.post(self._url(), {"name": "Extra", "match_pattern": "extra"}, format="json")
assert over_limit.status_code == status.HTTP_400_BAD_REQUEST
+ @parameterized.expand(
+ [
+ ("same_case", "Acme", "Acme"),
+ ("other_case_and_spaces", "Acme", " ACME "),
+ ("first_name_sent_with_spaces", "Acme ", "acme"),
+ ]
+ )
+ def test_create_rejects_a_name_another_rule_uses(self, _name: str, first_name: str, duplicate_name: str) -> None:
+ self.client.post(self._url(), {"name": first_name, "match_pattern": "acme"}, format="json")
+
+ response = self.client.post(self._url(), {"name": duplicate_name, "match_pattern": "acme-cli"}, format="json")
+
+ assert response.status_code == status.HTTP_400_BAD_REQUEST
+ assert response.json()["attr"] == "name"
+
+ @parameterized.expand([("built_in_name", "Cursor"), ("name_another_rule_uses", "Acme")])
+ def test_update_accepts_an_unchanged_name_saved_before_names_were_checked(self, _name: str, name: str) -> None:
+ older, _ = MCPCustomHarness.objects.bulk_create(
+ [
+ MCPCustomHarness(team=self.team, name=name, match_pattern="one"),
+ MCPCustomHarness(team=self.team, name="Acme", match_pattern="two"),
+ ]
+ )
+
+ response = self.client.patch(self._url(f"{older.id}/"), {"name": name, "icon": ""}, format="json")
+
+ assert response.status_code == status.HTTP_200_OK
+
+ def test_update_keeps_its_own_name_but_cannot_take_another_rules_name(self) -> None:
+ first = self.client.post(self._url(), {"name": "Acme", "match_pattern": "acme"}, format="json").json()
+ self.client.post(self._url(), {"name": "Beta", "match_pattern": "beta"}, format="json")
+
+ same_name = self.client.patch(self._url(f"{first['id']}/"), {"name": "acme"}, format="json")
+ taken_name = self.client.patch(self._url(f"{first['id']}/"), {"name": "Beta"}, format="json")
+
+ assert same_name.status_code == status.HTTP_200_OK
+ assert taken_name.status_code == status.HTTP_400_BAD_REQUEST
+ assert taken_name.json()["attr"] == "name"
+
def test_a_redis_outage_falls_back_to_postgres_without_reporting_an_exception(self) -> None:
MCPCustomHarness.objects.create(team=self.team, name="One", match_pattern="one")
outage = Exception("redis is down")
diff --git a/products/mcp_analytics/frontend/MCPAnalyticsDashboard.stories.tsx b/products/mcp_analytics/frontend/MCPAnalyticsDashboard.stories.tsx
index 69bca4f9b319..00d45ca53a12 100644
--- a/products/mcp_analytics/frontend/MCPAnalyticsDashboard.stories.tsx
+++ b/products/mcp_analytics/frontend/MCPAnalyticsDashboard.stories.tsx
@@ -80,12 +80,27 @@ const SESSION_RESULTS = [
['0193f2a1-aaaa-bbbb-cccc-000000000006', 22, 3, 13.6, 410, 6, '2026-06-06T16:20:00Z'],
]
+// An invented icon for the custom harness below, as a team would paste it in settings.
+const ACME_AGENT_ICON =
+ 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAoklEQVR42u2WyxGAIAwF4ZXhwcIs0MI82IbemUHyh8yYMwnshl8pfyjjPvZHk4/ZALCg11jIa6ClllrIaaBHK7GQz8CIkmshlwEqHceC2sB2XjXEALe31PGwoNdYgOeLR8mDVe+lFuD93o/yYbnzJRbgSU+pA+tzz7UAb/pRPXjcehwLiKD/qguvO586vkbR9xa31n8ggr6dZx0DUfSz5uvGCwGCWU5qX8y4AAAAAElFTkSuQmCC'
+
+const CUSTOM_HARNESSES = [
+ {
+ id: '0193f2a1-0000-7000-8000-000000000001',
+ name: 'Acme agent',
+ match_pattern: 'acme-agent',
+ icon: ACME_AGENT_ICON,
+ created_at: '2026-06-01T10:00:00Z',
+ updated_at: '2026-06-01T10:00:00Z',
+ },
+]
+
// MCPHarnessBreakdownQuery returns already-labelled rows (the runner resolves the
// harness server-side), so these are customer labels, not raw client strings.
const HARNESS_RESULTS = [
{ harness: 'Claude Code', total_calls: 6200, errors: 240, error_rate_pct: 3.9, sessions: 820 },
{ harness: 'Cursor', total_calls: 2100, errors: 96, error_rate_pct: 4.6, sessions: 410 },
- // A team-defined custom harness name. It has no brand mark, so it shows the generic one.
+ // A team-defined custom harness name. It shows the icon the team pasted in settings.
{ harness: 'Acme agent', total_calls: 1500, errors: 30, error_rate_pct: 2.0, sessions: 260 },
{ harness: 'OpenAI Codex', total_calls: 980, errors: 71, error_rate_pct: 7.2, sessions: 180 },
{ harness: 'Claude.ai', total_calls: 760, errors: 22, error_rate_pct: 2.9, sessions: 240 },
@@ -767,6 +782,7 @@ const meta: Meta = {
})(Story, context),
mswDecorator({
get: {
+ '/api/projects/:team_id/mcp_analytics/custom_harnesses/': CUSTOM_HARNESSES,
'/api/projects/:team_id/mcp_analytics/intent_clusters/': CLUSTER_SNAPSHOT,
'/api/projects/:team_id/mcp_analytics/sessions/activity_overview/': ACTIVITY_OVERVIEW,
'/api/projects/:team_id/mcp_analytics/sessions/': SESSION_LIST,
diff --git a/products/mcp_analytics/frontend/MCPAnalyticsToolDetail.tsx b/products/mcp_analytics/frontend/MCPAnalyticsToolDetail.tsx
index 0fe08f891ea9..6b5260659e2d 100644
--- a/products/mcp_analytics/frontend/MCPAnalyticsToolDetail.tsx
+++ b/products/mcp_analytics/frontend/MCPAnalyticsToolDetail.tsx
@@ -43,12 +43,10 @@ import { SceneExport } from '~/scenes/sceneTypes'
import { PersonDisplay } from 'products/persons/frontend/components/PersonDisplay'
import { ToolDetailIntentsSection } from './clustering/ToolDetailIntentsSection'
-import { BrandMark } from './components/BrandMark'
import { McpDateFilter } from './components/McpDateFilter'
import { McpSharedFilters } from './components/McpSharedFilters'
import { formatMs, formatMsAsSeconds, formatNumber } from './dashboard/formatters'
-import { HarnessPill } from './dashboard/harness'
-import { harnessMark } from './dashboard/harnessRegistry'
+import { HarnessLogo, HarnessPill } from './dashboard/harness'
import { MetricTile } from './dashboard/MetricTile'
import {
type DailyChartData,
@@ -103,7 +101,7 @@ function HarnessLogos({ labels }: { labels: string[] }): JSX.Element {
return (
<div className="flex items-center gap-1">
{labels.map((category) => (
- <BrandMark key={category} name={harnessMark(category)} label={category} />
+ <HarnessLogo key={category} category={category} label={category} />
))}
</div>
)
diff --git a/products/mcp_analytics/frontend/components/BrandMarkLabel.tsx b/products/mcp_analytics/frontend/components/BrandMarkLabel.tsx
index 755c23f59e99..eb52e67b240d 100644
--- a/products/mcp_analytics/frontend/components/BrandMarkLabel.tsx
+++ b/products/mcp_analytics/frontend/components/BrandMarkLabel.tsx
@@ -1,9 +1,17 @@
import { BrandMark, toBrandMarkName } from './BrandMark'
-export function BrandMarkLabel({ label, mark }: { label: string; mark: string }): JSX.Element {
+export function BrandMarkLabel({
+ label,
+ mark,
+ icon,
+}: {
+ label: string
+ mark: string
+ icon?: JSX.Element
+}): JSX.Element {
return (
<span className="inline-flex items-center gap-1.5" data-attr="hogqlx-brand-mark-label">
- <BrandMark name={toBrandMarkName(mark)} />
+ {icon ?? <BrandMark name={toBrandMarkName(mark)} />}
<span>{label}</span>
</span>
)
diff --git a/products/mcp_analytics/frontend/components/CustomHarnessIcon.tsx b/products/mcp_analytics/frontend/components/CustomHarnessIcon.tsx
new file mode 100644
index 000000000000..66a52fbc69cb
--- /dev/null
+++ b/products/mcp_analytics/frontend/components/CustomHarnessIcon.tsx
@@ -0,0 +1,23 @@
+import { useValues } from 'kea'
+
+import { mcpCustomHarnessesLogic } from '../settings/mcpCustomHarnessesLogic'
+import { BrandMark } from './BrandMark'
+import { HarnessIconMask } from './HarnessIconMask'
+
+/** The icon a team set for one of its custom harnesses, or the generic harness mark when it set none. */
+export function CustomHarnessIcon({
+ harness,
+ label,
+ className = 'size-4',
+}: {
+ harness: string
+ label?: string
+ className?: string
+}): JSX.Element {
+ const { customHarnessIcons } = useValues(mcpCustomHarnessesLogic)
+ const icon = customHarnessIcons.get(harness)
+ if (!icon) {
+ return <BrandMark name="Other harnesses" label={label} className={className} />
+ }
+ return <HarnessIconMask src={icon} label={label} className={className} />
+}
diff --git a/products/mcp_analytics/frontend/components/HarnessIconMask.tsx b/products/mcp_analytics/frontend/components/HarnessIconMask.tsx
new file mode 100644
index 000000000000..3d47a6e95e59
--- /dev/null
+++ b/products/mcp_analytics/frontend/components/HarnessIconMask.tsx
@@ -0,0 +1,30 @@
+import { type CSSProperties } from 'react'
+
+import { cn } from 'lib/utils/css-classes'
+
+// `src` must be a validated data URI: other text inside url() could add a mask layer that loads a remote image.
+export function HarnessIconMask({
+ src,
+ label,
+ className = 'size-4',
+}: {
+ src: string
+ label?: string
+ className?: string
+}): JSX.Element {
+ const a11y = label ? ({ role: 'img', 'aria-label': label } as const) : ({ 'aria-hidden': true } as const)
+ // Tailwind classes are static, so the per-harness image reaches the mask through a CSS variable.
+ const style = { '--harness-icon': `url("${src}")` } as CSSProperties
+ return (
+ <span
+ {...a11y}
+ title={label}
+ className={cn(
+ 'inline-block shrink-0 bg-current mask-(--harness-icon) mask-contain mask-no-repeat mask-center',
+ className
+ )}
+ // eslint-disable-next-line react/forbid-dom-props
+ style={style}
+ />
+ )
+}
diff --git a/products/mcp_analytics/frontend/dashboard/HarnessLabel.tsx b/products/mcp_analytics/frontend/dashboard/HarnessLabel.tsx
index f8de5a505af2..c5b3d90ba0aa 100644
--- a/products/mcp_analytics/frontend/dashboard/HarnessLabel.tsx
+++ b/products/mcp_analytics/frontend/dashboard/HarnessLabel.tsx
@@ -1,6 +1,14 @@
import { BrandMarkLabel } from '../components/BrandMarkLabel'
+import { CustomHarnessIcon } from '../components/CustomHarnessIcon'
import { harnessMark } from './harnessRegistry'
export function HarnessLabel({ category }: { category: string }): JSX.Element {
- return <BrandMarkLabel label={category} mark={harnessMark(category)} />
+ const mark = harnessMark(category)
+ return (
+ <BrandMarkLabel
+ label={category}
+ mark={mark}
+ icon={mark === 'Other harnesses' ? <CustomHarnessIcon harness={category} /> : undefined}
+ />
+ )
}
diff --git a/products/mcp_analytics/frontend/dashboard/harness.test.tsx b/products/mcp_analytics/frontend/dashboard/harness.test.tsx
new file mode 100644
index 000000000000..b746c03f373a
--- /dev/null
+++ b/products/mcp_analytics/frontend/dashboard/harness.test.tsx
@@ -0,0 +1,62 @@
+import '@testing-library/jest-dom'
+
+import { cleanup, render, waitFor } from '@testing-library/react'
+import { Provider } from 'kea'
+
+import { useMocks } from '~/mocks/jest'
+import { initKeaTests } from '~/test/init'
+
+import { mcpCustomHarnessesLogic } from '../settings/mcpCustomHarnessesLogic'
+import { HarnessLogo } from './harness'
+import { HarnessLabel } from './HarnessLabel'
+
+const ICON = 'data:image/png;base64,iVBORw0KGgo='
+
+describe('harness icons', () => {
+ beforeEach(() => {
+ useMocks({
+ get: {
+ '/api/projects/:team_id/mcp_analytics/custom_harnesses/': () => [
+ 200,
+ [
+ {
+ id: '0193f2a1-0000-7000-8000-000000000001',
+ name: 'Acme agent',
+ match_pattern: 'acme-agent',
+ icon: ICON,
+ created_at: '2026-01-01T00:00:00Z',
+ updated_at: '2026-01-01T00:00:00Z',
+ },
+ ],
+ ],
+ },
+ })
+ initKeaTests()
+ })
+
+ afterEach(() => {
+ cleanup()
+ })
+
+ it.each([
+ ['a custom harness with an icon shows that icon', 'Acme agent', ICON],
+ ['a custom harness without an icon keeps the generic mark', 'Support bot', null],
+ ['a built-in harness keeps its brand mark', 'Claude Code', null],
+ ['a custom harness named like an object property keeps the generic mark', 'constructor', null],
+ ])('%s', async (_, harness, expectedSrc) => {
+ const logic = mcpCustomHarnessesLogic()
+ logic.mount()
+ await waitFor(() => expect(logic.values.customHarnesses).toHaveLength(1))
+
+ const { container } = render(
+ <Provider>
+ <HarnessLogo category={harness} label={harness} />
+ <HarnessLabel category={harness} />
+ </Provider>
+ )
+ const masks = Array.from(container.querySelectorAll<HTMLElement>('[style]')).map((el) =>
+ el.style.getPropertyValue('--harness-icon')
+ )
+ expect(masks).toEqual(expectedSrc ? [`url("${expectedSrc}")`, `url("${expectedSrc}")`] : [])
+ })
+})
diff --git a/products/mcp_analytics/frontend/dashboard/harness.tsx b/products/mcp_analytics/frontend/dashboard/harness.tsx
index 47fece1f0f11..8d287e325f20 100644
--- a/products/mcp_analytics/frontend/dashboard/harness.tsx
+++ b/products/mcp_analytics/frontend/dashboard/harness.tsx
@@ -1,14 +1,22 @@
import { BrandMark } from '../components/BrandMark'
+import { CustomHarnessIcon } from '../components/CustomHarnessIcon'
import { harnessMark } from './harnessRegistry'
export function HarnessLogo({
category,
+ label,
className = 'h-4 w-4',
}: {
category: string
+ label?: string
className?: string
}): JSX.Element {
- return <BrandMark name={harnessMark(category)} className={className} />
+ const mark = harnessMark(category)
+ return mark === 'Other harnesses' ? (
+ <CustomHarnessIcon harness={category} label={label} className={className} />
+ ) : (
+ <BrandMark name={mark} label={label} className={className} />
+ )
}
export function HarnessPill({ category, title }: { category: string; title?: string }): JSX.Element {
diff --git a/products/mcp_analytics/frontend/firstLook/MCPAnalyticsFirstLook.tsx b/products/mcp_analytics/frontend/firstLook/MCPAnalyticsFirstLook.tsx
index f4eb62330a6e..52fa0363b820 100644
--- a/products/mcp_analytics/frontend/firstLook/MCPAnalyticsFirstLook.tsx
+++ b/products/mcp_analytics/frontend/firstLook/MCPAnalyticsFirstLook.tsx
@@ -9,8 +9,7 @@ import { Link } from 'lib/lemon-ui/Link/Link'
import posthog from 'lib/posthog-typed'
import { cn } from 'lib/utils/css-classes'
-import { BrandMark } from '../components/BrandMark'
-import { harnessMark } from '../dashboard/harnessRegistry'
+import { HarnessLogo } from '../dashboard/harness'
import type { FirstLookChip } from './firstLookCopy'
import { mcpFirstLookLogic } from './mcpFirstLookLogic'
@@ -29,11 +28,7 @@ function Chip({ chip }: { chip: FirstLookChip }): JSX.Element {
)}
>
<span className="flex items-center text-xs leading-none">
- {chip.harness ? (
- <BrandMark name={harnessMark(chip.harness)} className="size-3.5" />
- ) : (
- CHIP_ICON[chip.key]
- )}
+ {chip.harness ? <HarnessLogo category={chip.harness} className="size-3.5" /> : CHIP_ICON[chip.key]}
</span>
<span className="text-muted">{chip.label}</span>
<span className="font-medium text-primary">{chip.value}</span>
diff --git a/products/mcp_analytics/frontend/generated/api.schemas.ts b/products/mcp_analytics/frontend/generated/api.schemas.ts
index 96611cb24547..55c5531821d6 100644
--- a/products/mcp_analytics/frontend/generated/api.schemas.ts
+++ b/products/mcp_analytics/frontend/generated/api.schemas.ts
@@ -20,6 +20,8 @@ export interface MCPCustomHarnessApi {
* @maxLength 100
*/
match_pattern: string
+ /** Optional icon shown next to the harness name. A base64 data URI of a PNG, GIF or WebP image with a transparent background, 16 KB or smaller and at most 256 by 256 pixels. The icon shows in one color, like the built-in harness logos. An empty string means no icon. */
+ icon?: string
readonly created_at: string
readonly updated_at: string
}
@@ -37,6 +39,8 @@ export interface PatchedMCPCustomHarnessApi {
* @maxLength 100
*/
match_pattern?: string
+ /** Optional icon shown next to the harness name. A base64 data URI of a PNG, GIF or WebP image with a transparent background, 16 KB or smaller and at most 256 by 256 pixels. The icon shows in one color, like the built-in harness logos. An empty string means no icon. */
+ icon?: string
readonly created_at?: string
readonly updated_at?: string
}
diff --git a/products/mcp_analytics/frontend/generated/api.zod.ts b/products/mcp_analytics/frontend/generated/api.zod.ts
index ee6d4785a213..5e3978bee838 100644
--- a/products/mcp_analytics/frontend/generated/api.zod.ts
+++ b/products/mcp_analytics/frontend/generated/api.zod.ts
@@ -29,6 +29,12 @@ export const McpAnalyticsCustomHarnessesCreateBody = /* @__PURE__ */ zod.object(
.describe(
'Text to look for in the client name or User-Agent product that the harness reports. Matching ignores case and finds the text anywhere in the name, so `acme-agent` matches `Acme-Agent\/1.2`.'
),
+ icon: zod
+ .string()
+ .optional()
+ .describe(
+ 'Optional icon shown next to the harness name. A base64 data URI of a PNG, GIF or WebP image with a transparent background, 16 KB or smaller and at most 256 by 256 pixels. The icon shows in one color, like the built-in harness logos. An empty string means no icon.'
+ ),
})
/**
@@ -51,6 +57,12 @@ export const McpAnalyticsCustomHarnessesUpdateBody = /* @__PURE__ */ zod.object(
.describe(
'Text to look for in the client name or User-Agent product that the harness reports. Matching ignores case and finds the text anywhere in the name, so `acme-agent` matches `Acme-Agent\/1.2`.'
),
+ icon: zod
+ .string()
+ .optional()
+ .describe(
+ 'Optional icon shown next to the harness name. A base64 data URI of a PNG, GIF or WebP image with a transparent background, 16 KB or smaller and at most 256 by 256 pixels. The icon shows in one color, like the built-in harness logos. An empty string means no icon.'
+ ),
})
/**
@@ -75,6 +87,12 @@ export const McpAnalyticsCustomHarnessesPartialUpdateBody = /* @__PURE__ */ zod.
.describe(
'Text to look for in the client name or User-Agent product that the harness reports. Matching ignores case and finds the text anywhere in the name, so `acme-agent` matches `Acme-Agent\/1.2`.'
),
+ icon: zod
+ .string()
+ .optional()
+ .describe(
+ 'Optional icon shown next to the harness name. A base64 data URI of a PNG, GIF or WebP image with a transparent background, 16 KB or smaller and at most 256 by 256 pixels. The icon shows in one color, like the built-in harness logos. An empty string means no icon.'
+ ),
})
/**
diff --git a/products/mcp_analytics/frontend/mcpDashboardOverviewLogic.test.ts b/products/mcp_analytics/frontend/mcpDashboardOverviewLogic.test.ts
index bb404431a0ef..0bcd628b015e 100644
--- a/products/mcp_analytics/frontend/mcpDashboardOverviewLogic.test.ts
+++ b/products/mcp_analytics/frontend/mcpDashboardOverviewLogic.test.ts
@@ -89,6 +89,15 @@ describe('mcpDashboardOverviewLogic', () => {
expect(Object.prototype.hasOwnProperty.call(HARNESS_BY_LABEL, label)).toBe(true)
})
+ it('HARNESS_BY_LABEL has no key the backend does not reserve', () => {
+ // Mirrors MARKED_CLIENT_NAMES in mcp_harness.py. The backend rejects custom harness names
+ // in both lists, because a custom harness with one of these names would lose its icon.
+ const MARKED_CLIENT_NAMES = ['PostHog AI', 'Slack']
+ expect(Object.keys(HARNESS_BY_LABEL).sort()).toEqual(
+ [...EXPECTED_HARNESS_LABELS, ...MARKED_CLIENT_NAMES].sort()
+ )
+ })
+
it.each([
'Claude Code',
'OpenAI',
diff --git a/products/mcp_analytics/frontend/settings/McpCustomHarnessForm.tsx b/products/mcp_analytics/frontend/settings/McpCustomHarnessForm.tsx
index b2beaf3520c3..53e6f881a783 100644
--- a/products/mcp_analytics/frontend/settings/McpCustomHarnessForm.tsx
+++ b/products/mcp_analytics/frontend/settings/McpCustomHarnessForm.tsx
@@ -5,10 +5,24 @@ import { LemonButton, LemonInput } from '@posthog/lemon-ui'
import { LemonField } from 'lib/lemon-ui/LemonField'
+import { HarnessIconMask } from '../components/HarnessIconMask'
import { mcpCustomHarnessesLogic } from './mcpCustomHarnessesLogic'
+// Fixed colors rather than theme tokens, so the preview shows both themes whichever one is active.
+const PREVIEW_BACKGROUNDS = [
+ { name: 'light', className: 'bg-white text-black' },
+ { name: 'dark', className: 'bg-black text-white' },
+] as const
+
export function McpCustomHarnessForm(): JSX.Element {
- const { isCustomHarnessFormSubmitting, saveInProgressReason } = useValues(mcpCustomHarnessesLogic)
+ const {
+ isCustomHarnessFormSubmitting,
+ saveInProgressReason,
+ customHarnessForm,
+ customHarnessFormValidationErrors,
+ } = useValues(mcpCustomHarnessesLogic)
+ const iconPreview =
+ customHarnessForm.icon && !customHarnessFormValidationErrors.icon ? customHarnessForm.icon.trim() : null
const { cancelEditingHarness } = useActions(mcpCustomHarnessesLogic)
return (
@@ -31,6 +45,25 @@ export function McpCustomHarnessForm(): JSX.Element {
<LemonInput placeholder="acme-agent" maxLength={100} />
</LemonField>
</div>
+ <div className="flex items-start gap-2">
+ <LemonField
+ name="icon"
+ label="Icon (optional)"
+ help="Paste a PNG, GIF or WebP image with a transparent background as a data URI. It can be 16 KB and 256 by 256 pixels at most. It shows in one color, like the other harness logos."
+ className="flex-1 min-w-60"
+ >
+ <LemonInput placeholder="data:image/png;base64,..." />
+ </LemonField>
+ {iconPreview && (
+ <div className="flex gap-1 mt-7 shrink-0">
+ {PREVIEW_BACKGROUNDS.map(({ name, className }) => (
+ <div key={name} className={`flex rounded border p-2 ${className}`}>
+ <HarnessIconMask src={iconPreview} label={`Icon preview on a ${name} background`} />
+ </div>
+ ))}
+ </div>
+ )}
+ </div>
<div className="flex justify-end gap-2">
<LemonButton type="secondary" onClick={cancelEditingHarness} disabledReason={saveInProgressReason}>
Cancel
diff --git a/products/mcp_analytics/frontend/settings/McpCustomHarnessesSettings.test.tsx b/products/mcp_analytics/frontend/settings/McpCustomHarnessesSettings.test.tsx
index 34213bfe5463..2321b27d5415 100644
--- a/products/mcp_analytics/frontend/settings/McpCustomHarnessesSettings.test.tsx
+++ b/products/mcp_analytics/frontend/settings/McpCustomHarnessesSettings.test.tsx
@@ -71,6 +71,24 @@ describe('McpCustomHarnessesSettings', () => {
await waitFor(() => expect(screen.queryByText('Beta bot')).not.toBeInTheDocument())
})
+ it.each([
+ ['a valid data URI shows a preview', 'data:image/png;base64,iVBORw0KGgo=', true],
+ ['a web address shows no preview, so the browser never fetches it', 'https://example.com/icon.png', false],
+ ])('%s', async (_, icon, showsPreview) => {
+ render(
+ <Provider>
+ <McpCustomHarnessesSettings />
+ </Provider>
+ )
+ await userEvent.click(await screen.findByText('Add custom harness'))
+ await userEvent.click(screen.getByPlaceholderText('data:image/png;base64,...'))
+ await userEvent.paste(icon)
+
+ for (const background of ['light', 'dark']) {
+ expect(screen.queryByLabelText(`Icon preview on a ${background} background`) !== null).toBe(showsPreview)
+ }
+ })
+
it('blocks opening another form while a save is pending', async () => {
stored = [
{ id: 'a', name: 'Alpha', match_pattern: 'alpha', created_at: '', updated_at: '' },
diff --git a/products/mcp_analytics/frontend/settings/McpCustomHarnessesSettings.tsx b/products/mcp_analytics/frontend/settings/McpCustomHarnessesSettings.tsx
index 61685d20eb03..83bef671bbc3 100644
--- a/products/mcp_analytics/frontend/settings/McpCustomHarnessesSettings.tsx
+++ b/products/mcp_analytics/frontend/settings/McpCustomHarnessesSettings.tsx
@@ -3,6 +3,7 @@ import { useActions, useValues } from 'kea'
import { IconPencil, IconPlus, IconTrash } from '@posthog/icons'
import { LemonButton, LemonDialog, LemonSkeleton } from '@posthog/lemon-ui'
+import { CustomHarnessIcon } from '../components/CustomHarnessIcon'
import { mcpCustomHarnessesLogic } from './mcpCustomHarnessesLogic'
import { McpCustomHarnessForm } from './McpCustomHarnessForm'
@@ -43,6 +44,7 @@ export function McpCustomHarnessesSettings(): JSX.Element {
key={harness.id}
className="border rounded flex items-center gap-2 p-2 pl-4 bg-surface-primary"
>
+ <CustomHarnessIcon harness={harness.name} />
<span className="flex-1 min-w-0 truncate font-semibold" title={harness.name}>
{harness.name}
</span>
diff --git a/products/mcp_analytics/frontend/settings/mcpCustomHarnessesLogic.test.ts b/products/mcp_analytics/frontend/settings/mcpCustomHarnessesLogic.test.ts
index 8096b9cc791f..15d1e3b35ae9 100644
--- a/products/mcp_analytics/frontend/settings/mcpCustomHarnessesLogic.test.ts
+++ b/products/mcp_analytics/frontend/settings/mcpCustomHarnessesLogic.test.ts
@@ -10,10 +10,13 @@ import { mcpCustomHarnessesLogic } from './mcpCustomHarnessesLogic'
const HARNESSES_URL = '/api/projects/:team_id/mcp_analytics/custom_harnesses/'
-const harness = (id: string, name: string, match_pattern: string): MCPCustomHarnessApi => ({
+const ICON = 'data:image/png;base64,iVBORw0KGgo='
+
+const harness = (id: string, name: string, match_pattern: string, icon = ''): MCPCustomHarnessApi => ({
id,
name,
match_pattern,
+ icon,
created_at: '2026-01-01T00:00:00Z',
updated_at: '2026-01-01T00:00:00Z',
})
@@ -40,12 +43,12 @@ describe('mcpCustomHarnessesLogic', () => {
get: { [HARNESSES_URL]: () => [200, stored] },
post: {
[HARNESSES_URL]: async ({ request }) => {
- const body = (await request.json()) as { name: string; match_pattern: string }
+ const body = (await request.json()) as { name: string; match_pattern: string; icon: string }
posted.push(body)
if (rejectCreate) {
return [400, { detail: 'A custom harness already uses this pattern.' }]
}
- const created = harness(`id-${posted.length}`, body.name, body.match_pattern)
+ const created = harness(`id-${posted.length}`, body.name, body.match_pattern, body.icon)
stored = [...stored, created]
return [201, created]
},
@@ -87,6 +90,26 @@ describe('mcpCustomHarnessesLogic', () => {
[{ name: '', match_pattern: 'acme' }, { name: 'Enter a name' }],
[{ name: ' ', match_pattern: 'acme' }, { name: 'Enter a name' }],
[{ name: 'Acme', match_pattern: '' }, { match_pattern: 'Enter the text to match' }],
+ [
+ { name: 'Acme', match_pattern: 'acme', icon: 'https://example.com/icon.png' },
+ { icon: 'Paste a PNG, GIF or WebP image as a data URI.' },
+ ],
+ [
+ { name: 'Acme', match_pattern: 'acme', icon: 'data:image/jpeg;base64,/9j/4AAQ' },
+ { icon: 'Paste a PNG, GIF or WebP image as a data URI.' },
+ ],
+ [
+ {
+ name: 'Acme',
+ match_pattern: 'acme',
+ icon: 'data:image/png;base64,iVBORw0KGgo="), url("https://example.com/track.png',
+ },
+ { icon: 'Paste a PNG, GIF or WebP image as a data URI.' },
+ ],
+ [
+ { name: 'Acme', match_pattern: 'acme', icon: `data:image/png;base64,${'A'.repeat(30_000)}` },
+ { icon: 'The icon must be 16 KB or smaller.' },
+ ],
])('does not send %j and shows %j', async (values, errors) => {
const logic = await mounted()
logic.actions.startAddingHarness()
@@ -97,6 +120,20 @@ describe('mcpCustomHarnessesLogic', () => {
expect(posted).toEqual([])
})
+ it.each([
+ ['accepts an icon of exactly 16 KB', `${'A'.repeat(21_846)}==`, undefined],
+ ['rejects an icon one byte over 16 KB', `${'A'.repeat(21_847)}=`, 'The icon must be 16 KB or smaller.'],
+ ])('%s', async (_, base64, error) => {
+ const logic = await mounted()
+ logic.actions.startAddingHarness()
+ logic.actions.setCustomHarnessFormValues({
+ name: 'Acme',
+ match_pattern: 'acme',
+ icon: `data:image/png;base64,${base64}`,
+ })
+ expect(logic.values.customHarnessFormValidationErrors.icon).toEqual(error)
+ })
+
it('saves a trimmed name, closes the form and shows the new harness', async () => {
const logic = await mounted()
logic.actions.startAddingHarness()
@@ -104,7 +141,7 @@ describe('mcpCustomHarnessesLogic', () => {
logic.actions.submitCustomHarnessForm()
await expectLogic(logic).toDispatchActions(['submitCustomHarnessFormSuccess', 'loadCustomHarnessesSuccess'])
- expect(posted).toEqual([{ name: 'Beta bot', match_pattern: 'beta-bot' }])
+ expect(posted).toEqual([{ name: 'Beta bot', match_pattern: 'beta-bot', icon: '' }])
expect(logic.values.editingHarnessId).toBeNull()
expect(logic.values.customHarnesses?.map((h) => h.name)).toEqual(['Acme agent', 'Beta bot'])
})
@@ -113,14 +150,16 @@ describe('mcpCustomHarnessesLogic', () => {
const logic = await mounted()
logic.actions.startEditingHarness(stored[0])
expect(logic.values.editingHarnessId).toBe('a')
- expect(logic.values.customHarnessForm).toEqual({ name: 'Acme agent', match_pattern: 'acme-agent' })
+ expect(logic.values.customHarnessForm).toEqual({ name: 'Acme agent', match_pattern: 'acme-agent', icon: '' })
- logic.actions.setCustomHarnessFormValues({ name: 'Acme assistant' })
+ logic.actions.setCustomHarnessFormValues({ name: 'Acme assistant', icon: ICON })
logic.actions.submitCustomHarnessForm()
await expectLogic(logic).toDispatchActions(['submitCustomHarnessFormSuccess', 'loadCustomHarnessesSuccess'])
expect(posted).toEqual([])
- expect(patched).toEqual([{ id: 'a', body: { name: 'Acme assistant', match_pattern: 'acme-agent' } }])
+ expect(patched).toEqual([
+ { id: 'a', body: { name: 'Acme assistant', match_pattern: 'acme-agent', icon: ICON } },
+ ])
expect(logic.values.editingHarnessId).toBeNull()
expect(logic.values.customHarnesses?.map((h) => h.name)).toEqual(['Acme assistant'])
})
@@ -132,7 +171,14 @@ describe('mcpCustomHarnessesLogic', () => {
logic.actions.startAddingHarness()
expect(logic.values.editingHarnessId).toBe('new')
- expect(logic.values.customHarnessForm).toEqual({ name: '', match_pattern: '' })
+ expect(logic.values.customHarnessForm).toEqual({ name: '', match_pattern: '', icon: '' })
+ })
+
+ it('maps each harness name to its icon, leaving out harnesses without one', async () => {
+ stored = [harness('a', 'Acme agent', 'acme-agent', ICON), harness('b', 'Support bot', 'support-bot')]
+ const logic = await mounted()
+
+ expect(logic.values.customHarnessIcons).toEqual(new Map([['Acme agent', ICON]]))
})
it('keeps what the person typed and shows the server reason when a save fails', async () => {
@@ -144,7 +190,7 @@ describe('mcpCustomHarnessesLogic', () => {
await expectLogic(logic).toDispatchActions(['submitCustomHarnessFormFailure'])
expect(logic.values.editingHarnessId).toBe('new')
- expect(logic.values.customHarnessForm).toEqual({ name: 'Acme copy', match_pattern: 'acme-agent' })
+ expect(logic.values.customHarnessForm).toEqual({ name: 'Acme copy', match_pattern: 'acme-agent', icon: '' })
expect(lemonToast.error).toHaveBeenCalledWith('A custom harness already uses this pattern.')
})
diff --git a/products/mcp_analytics/frontend/settings/mcpCustomHarnessesLogic.ts b/products/mcp_analytics/frontend/settings/mcpCustomHarnessesLogic.ts
index 99c4eb2c7d2a..9c207d35f583 100644
--- a/products/mcp_analytics/frontend/settings/mcpCustomHarnessesLogic.ts
+++ b/products/mcp_analytics/frontend/settings/mcpCustomHarnessesLogic.ts
@@ -21,9 +21,28 @@ const projectId = (): string => String(ApiConfig.getCurrentProjectId())
export interface CustomHarnessFormValues {
name: string
match_pattern: string
+ icon: string
}
-const EMPTY_FORM: CustomHarnessFormValues = { name: '', match_pattern: '' }
+const EMPTY_FORM: CustomHarnessFormValues = { name: '', match_pattern: '', icon: '' }
+
+// Mirrors the server check in custom_harness_icons.py, so most mistakes show before a save.
+// Matching the whole value keeps the preview mask to one data URI.
+const MAX_ICON_BYTES = 16 * 1024
+const ICON_DATA_URI = /^data:image\/(png|gif|webp);base64,[A-Za-z0-9+/]+={0,2}$/
+
+function iconError(icon: string): string | undefined {
+ if (!icon) {
+ return undefined
+ }
+ if (!ICON_DATA_URI.test(icon)) {
+ return 'Paste a PNG, GIF or WebP image as a data URI.'
+ }
+ const base64 = icon.slice(icon.indexOf(',') + 1)
+ const padding = base64.length - base64.replace(/=+$/, '').length
+ const decodedBytes = (base64.length * 3) / 4 - padding
+ return decodedBytes > MAX_ICON_BYTES ? 'The icon must be 16 KB or smaller.' : undefined
+}
/** The id of the harness being edited, `'new'` while adding one, or null when no form is open. */
export type EditingHarnessId = string | 'new' | null
@@ -39,6 +58,7 @@ export interface mcpCustomHarnessesLogicValues {
customHarnessFormTouched: boolean
customHarnessFormTouches: Record<string, boolean>
customHarnessFormValidationErrors: DeepPartialMap<CustomHarnessFormValues, ValidationErrorType>
+ customHarnessIcons: Map<string, string>
customHarnesses: MCPCustomHarnessApi[] | null
customHarnessesLoading: boolean
deletingHarnessId: string | null
@@ -121,6 +141,7 @@ export interface mcpCustomHarnessesLogicActions {
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface mcpCustomHarnessesLogicMeta {
__keaTypeGenInternalSelectorTypes: {
+ customHarnessIcons: (customHarnesses: MCPCustomHarnessApi[] | null) => Map<string, string>
saveInProgressReason: (isCustomHarnessFormSubmitting: boolean) => string | null
}
}
@@ -167,15 +188,23 @@ export const mcpCustomHarnessesLogic = kea<mcpCustomHarnessesLogicType>([
},
],
}),
+ selectors({
+ customHarnessIcons: [
+ (s) => [s.customHarnesses],
+ (customHarnesses: MCPCustomHarnessApi[] | null): Map<string, string> =>
+ new Map((customHarnesses ?? []).filter((h) => h.icon).map((h) => [h.name, h.icon as string])),
+ ],
+ }),
forms(({ actions, values }) => ({
customHarnessForm: {
defaults: EMPTY_FORM,
- errors: ({ name, match_pattern }) => ({
+ errors: ({ name, match_pattern, icon }) => ({
name: name.trim() ? undefined : 'Enter a name',
match_pattern: match_pattern.trim() ? undefined : 'Enter the text to match',
+ icon: iconError(icon.trim()),
}),
- submit: async ({ name, match_pattern }) => {
- const harness = { name: name.trim(), match_pattern }
+ submit: async ({ name, match_pattern, icon }) => {
+ const harness = { name: name.trim(), match_pattern, icon: icon.trim() }
const editingId = values.editingHarnessId
try {
if (editingId && editingId !== 'new') {
@@ -206,7 +235,11 @@ export const mcpCustomHarnessesLogic = kea<mcpCustomHarnessesLogicType>([
actions.resetCustomHarnessForm(EMPTY_FORM)
},
startEditingHarness: ({ harness }) => {
- actions.resetCustomHarnessForm({ name: harness.name, match_pattern: harness.match_pattern })
+ actions.resetCustomHarnessForm({
+ name: harness.name,
+ match_pattern: harness.match_pattern,
+ icon: harness.icon ?? '',
+ })
},
cancelEditingHarness: () => {
actions.resetCustomHarnessForm(EMPTY_FORM)
diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.ts
index 87fea7e563ba..51ad061854b9 100644
--- a/services/mcp/src/api/generated.ts
+++ b/services/mcp/src/api/generated.ts
@@ -63889,6 +63889,8 @@ export namespace Schemas {
* @maxLength 100
*/
match_pattern: string;
+ /** Optional icon shown next to the harness name. A base64 data URI of a PNG, GIF or WebP image with a transparent background, 16 KB or smaller and at most 256 by 256 pixels. The icon shows in one color, like the built-in harness logos. An empty string means no icon. */
+ icon?: string;
readonly created_at: string;
readonly updated_at: string;
}
@@ -84570,6 +84572,8 @@ export namespace Schemas {
* @maxLength 100
*/
match_pattern?: string;
+ /** Optional icon shown next to the harness name. A base64 data URI of a PNG, GIF or WebP image with a transparent background, 16 KB or smaller and at most 256 by 256 pixels. The icon shows in one color, like the built-in harness logos. An empty string means no icon. */
+ icon?: string;
readonly created_at?: string;
readonly updated_at?: string;
}