Skip to main content
Glama
base-provider.ts2.29 kB
/** * Base Provider Interface * * Abstract base class for VCS providers (GitHub, Gitea). * Defines the common interface that all providers must implement. */ import { ProviderResult, ProviderOperation } from './types.js'; export abstract class BaseProvider { protected name: string; protected config: any; constructor(name: string, config: any) { this.name = name; this.config = config; } /** * Get the provider name */ getName(): string { return this.name; } /** * Check if the provider is properly configured */ abstract isConfigured(): boolean; /** * Validate provider credentials */ abstract validateCredentials(): Promise<boolean>; /** * Execute a provider operation */ abstract executeOperation(operation: string, params: any): Promise<ProviderResult>; /** * Get supported operations for this provider */ abstract getSupportedOperations(): string[]; /** * Check if an operation is supported */ isOperationSupported(operation: string): boolean { return this.getSupportedOperations().includes(operation); } /** * Get provider configuration status */ getConfigurationStatus(): { configured: boolean; missingFields: string[]; provider: string; } { return { configured: this.isConfigured(), missingFields: this.getMissingConfigFields(), provider: this.name }; } /** * Get missing configuration fields */ protected abstract getMissingConfigFields(): string[]; /** * Format error response */ protected formatError(code: string, message: string, details?: any): ProviderResult { return { success: false, error: { code, message, details }, provider: this.name }; } /** * Format success response */ protected formatSuccess(data?: any): ProviderResult { return { success: true, data, provider: this.name }; } } /** * Multi-provider interface for handling multiple providers simultaneously */ export interface MultiProvider { providers: BaseProvider[]; executeOperation(operation: string, params: any): Promise<ProviderResult[]>; getConfiguredProviders(): BaseProvider[]; isAnyProviderConfigured(): boolean; }

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/Andre-Buzeli/git-mcp'

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