Skip to main content
Glama
mcp-response.ts1.32 kB
/** * Centralized MCP response utilities for consistent tool responses */ export interface McpTextContent { type: "text"; text: string; } export interface McpToolResponse { content: McpTextContent[]; isError?: boolean; } /** * Create a successful MCP tool response */ export function mcpSuccess(text: string): McpToolResponse { return { content: [{ type: "text", text }], }; } /** * Create an error MCP tool response */ export function mcpError(message: string): McpToolResponse { return { content: [{ type: "text", text: message }], isError: true, }; } /** * Create a rate limit exceeded response */ export function mcpRateLimitError( reason: string, retryAfter?: number, alternativeContact = "me@duyet.net", ): McpToolResponse { const retryMessage = retryAfter ? `\n\nYou can try again in ${Math.ceil(retryAfter / 60)} minutes.` : ""; return mcpError( `Rate Limit Exceeded\n\n${reason}${retryMessage}\n\nAlternative: Email me directly at ${alternativeContact}`, ); } /** * Create a database error response (sanitized) */ export function mcpDatabaseError( fallbackMessage = "Your request could not be processed. Please try again or contact me@duyet.net.", ): McpToolResponse { return { content: [{ type: "text", text: fallbackMessage }], }; }

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/duyet/duyet-mcp-server'

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