Skip to main content
Glama
responseFormatter.ts862 B
export interface FormattedResponse { content: { type: "text"; text: string }[]; isError?: boolean; } export class ResponseFormatter { static success(message: string, data?: unknown): FormattedResponse { const responseData = { success: true, message, ...(data && typeof data === "object" && data !== null ? { data } : {}), }; return { content: [ { type: "text", text: JSON.stringify(responseData, null, 2), }, ], }; } static error(message: string, details?: string): FormattedResponse { const errorData = { success: false, error: message, ...(details && { details }), }; return { isError: true, content: [ { type: "text", text: JSON.stringify(errorData, null, 2), }, ], }; } }

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/andradehenrique/dokploy-mcp'

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