getMcpButtonData.ts35 lines · main
1import type { McpClient, McpClientConfig } from '../types'
2import { getMcpClientIconSrc } from './getMcpIconSrc'
3
4interface GetMcpButtonDataOptions {
5 theme?: 'light' | 'dark'
6 client: McpClient
7 clientConfig: McpClientConfig
8 isPlatform?: boolean
9}
10
11export function getMcpButtonData({
12 theme,
13 client,
14 clientConfig,
15 isPlatform,
16}: GetMcpButtonDataOptions) {
17 if (client.generateDeepLink) {
18 const deepLink = client.generateDeepLink(clientConfig, { isPlatform })
19 if (!deepLink) return null
20
21 // If the theme is dark, the button background will be light and vice-versa
22 const imageSrc = getMcpClientIconSrc({
23 icon: client.icon!,
24 useDarkVariant: theme === 'light',
25 hasDistinctDarkIcon: client.hasDistinctDarkIcon,
26 })
27
28 return {
29 deepLink,
30 imageSrc,
31 label: client.label,
32 }
33 }
34 return null
35}