mcp-framework
Version:
Framework for building Model Context Protocol (MCP) servers in Typescript
60 lines (59 loc) • 1.68 kB
TypeScript
import { z } from "zod";
/**
* Configuration options for image transport
*/
export interface ImageTransportOptions {
maxSize: number;
allowedMimeTypes: string[];
compressionQuality?: number;
}
/**
* Schema for image content validation
*/
export declare const ImageContentSchema: z.ZodObject<{
type: z.ZodLiteral<"image">;
data: z.ZodString;
mimeType: z.ZodString;
}, "strip", z.ZodTypeAny, {
type: "image";
data: string;
mimeType: string;
}, {
type: "image";
data: string;
mimeType: string;
}>;
export type ImageContent = z.infer<typeof ImageContentSchema>;
/**
* Default configuration for image transport
*/
export declare const DEFAULT_IMAGE_OPTIONS: ImageTransportOptions;
/**
* Validates image content against transport options
*/
export declare function validateImageTransport(content: ImageContent, options?: ImageTransportOptions): void;
/**
* Prepares image content for transport
* This function can be extended to handle compression, format conversion, etc.
*/
export declare function prepareImageForTransport(content: ImageContent, options?: ImageTransportOptions): ImageContent;
/**
* Gets the size of a base64 image in bytes
*/
export declare function getBase64ImageSize(base64String: string): number;
/**
* Utility type for messages containing image content
*/
export type MessageWithImage = {
result?: {
content?: Array<ImageContent | {
type: string;
[key: string]: unknown;
}>;
};
[key: string]: unknown;
};
/**
* Checks if a message contains image content
*/
export declare function hasImageContent(message: unknown): message is MessageWithImage;