1
>
/*---------------------------------------------------------------------------------------------
mcpIcons.ts
2
>
* Copyright (c) Microsoft Corporation. All rights reserved.
3
>
* Licensed under the MIT License. See License.txt in the project root for license information.
4
>
*--------------------------------------------------------------------------------------------*/
5
>
6
>
import { getMediaMime } from '../../../../base/common/mime.js';
7
>
import { URI } from '../../../../base/common/uri.js';
8
>
import { ILogger } from '../../../../platform/log/common/log.js';
9
>
import { Dto } from '../../../services/extensions/common/proxyIdentifier.js';
10
>
import { IMcpIcons, McpServerLaunch, McpServerTransportType } from './mcpTypes.js';
11
>
import { MCP } from './modelContextProtocol.js';
12
>
13
>
const mcpAllowableContentTypes: readonly string[] = [
14
>
'image/webp',
15
>
'image/png',
16
>
'image/jpeg',
17
>
'image/jpg',
18
>
'image/gif'
19
>
];
20
>
21
>
const enum IconTheme {
22
>
Light,
23
>
Dark,
24
>
Any,
25
>
}
26
>
27
>
interface IIcon {
28
>
/** URI the image can be loaded from */
29
>
src: URI;
30
>
/** Theme for this icon. */
31
>
theme: IconTheme;
32
>
/** Sizes of the icon in ascending order. */
33
>
sizes: { width: number; height: number }[];
34
>
}
35
>
36
>
export type ParsedMcpIcons = IIcon[];
37
>
export type StoredMcpIcons = Dto<IIcon>[];
38
>
39
>
40
function validateIcon(icon: MCP.Icon, launch: McpServerLaunch, logger: ILogger): URI | undefined {
41
const mimeType = icon.mimeType?.toLowerCase() || getMediaMime(icon.src);