Skip to main content
Glama

Formula1 MCP Server

MIT License
11
  • Apple
  • Linux
error-handler.ts1.1 kB
import { McpError, ErrorCode, Request } from "@modelcontextprotocol/sdk"; export const errorHandlerMiddleware = async ( request: Request, next: () => Promise<any> ) => { try { return await next(); } catch (error) { console.error( `Error handling request: ${ error instanceof Error ? error.message : String(error) }` ); // If it's already an MCP error, just rethrow it if (error instanceof McpError) { throw error; } // Map common error types to appropriate MCP error codes if (error instanceof TypeError) { throw new McpError( ErrorCode.InvalidParams, `Invalid parameters: ${error.message}` ); } if (error instanceof SyntaxError) { throw new McpError( ErrorCode.ParseError, `Failed to parse request: ${error.message}` ); } // For unknown errors, return a generic internal error throw new McpError( ErrorCode.InternalError, `An unexpected error occurred: ${ error instanceof Error ? error.message : String(error) }` ); } };

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/Panth1823/formula1-mcp'

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