Skip to main content
Glama
errors.ts1.25 kB
// Initial empty file for custom error handling import { McpError, ErrorCode } from "@modelcontextprotocol/sdk/types.js"; // TODO: Implement detailed GraphQL error parsing and mapping to McpError /** * Placeholder function for handling GraphQL errors. * This should be expanded to parse the error structure and map to specific McpError codes. * * @param errors The errors array from a GraphQL response. * @param defaultMessage A default message if no specific mapping is found. * @returns An McpError instance. */ export function mapGraphQLErrorToMcpError( errors: any[], defaultMessage: string = "GraphQL operation failed" ): McpError { // Basic implementation: just take the first message const message = errors[0]?.message || defaultMessage; console.error("GraphQL Errors Encountered:", errors); // TODO: Revisit ErrorCode mapping once SDK types are clarified. // Using InternalError as a generic placeholder for now. return new McpError( ErrorCode.InternalError, // Placeholder message, { details: { graphqlErrors: errors } } // Include original errors ); } // Example usage (will be used in tool handlers later): // if (response.errors) { // throw mapGraphQLErrorsToMcpError(response.errors); // }

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/jorgeraad/mcp4gql'

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