Skip to main content
Glama
toolUtils.ts1.39 kB
/** * Utility functions for tool handlers */ /** * Tool utilities class that provides utility functions */ export class ToolUtils { /** * Creates a standardized tool response with text content * @param content Any data that will be stringified as JSON * @returns A properly formatted tool response object */ static createJSONToolResponse(content: any): { content: Array<{ type: "text"; text: string; }>; } { return { content: [ { type: "text", text: JSON.stringify(content, null, 2) } ] }; } /** * Creates a standardized tool response with image content * @param base64Data Base64 encoded image data * @param mimeType The MIME type of the image (e.g., "image/png", "image/webp") * @returns A properly formatted tool response object */ static createImageToolResponse(base64Data: string, mimeType: string): { content: Array<{ type: "image"; data: string; mimeType: string; }>; } { return { content: [ { type: "image", data: base64Data, mimeType: mimeType } ] }; } } // Export convenience functions for backward compatibility export const createJSONToolResponse = ToolUtils.createJSONToolResponse; export const createImageToolResponse = ToolUtils.createImageToolResponse;

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/zillow/auto-mobile'

If you have feedback or need assistance with the MCP directory API, please join our Discord server