Skip to main content
Glama

MCP Server for Crawl4AI

by omgwtfwow
base-handler.ts1.49 kB
import { Crawl4AIService } from '../crawl4ai-service.js'; import { AxiosInstance } from 'axios'; // Error handling types export interface ErrorWithResponse { response?: { data?: | { detail?: string; } | string | unknown; }; message?: string; } export interface SessionInfo { id: string; created_at: Date; last_used: Date; initial_url?: string; metadata?: Record<string, unknown>; } export abstract class BaseHandler { protected service: Crawl4AIService; protected axiosClient: AxiosInstance; protected sessions: Map<string, SessionInfo>; constructor(service: Crawl4AIService, axiosClient: AxiosInstance, sessions: Map<string, SessionInfo>) { this.service = service; this.axiosClient = axiosClient; this.sessions = sessions; } protected formatError(error: unknown, operation: string): Error { const errorWithResponse = error as ErrorWithResponse; let errorMessage = ''; const data = errorWithResponse.response?.data; if (typeof data === 'object' && data && 'detail' in data) { errorMessage = (data as { detail: string }).detail; } else if (data) { // If data is an object, stringify it errorMessage = typeof data === 'object' ? JSON.stringify(data) : String(data); } else if (error instanceof Error) { errorMessage = error.message; } else { errorMessage = String(error); } return new Error(`Failed to ${operation}: ${errorMessage}`); } }

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/omgwtfwow/mcp-crawl4ai-ts'

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