Skip to main content
Glama
pshempel

MCP Time Server Node

by pshempel
RecurrenceFactory.ts1.78 kB
import { ValidationError } from '../../adapters/mcp-sdk'; import type { RecurrenceParams, RecurrencePattern } from '../../types/recurrence'; import { debug } from '../../utils/debug'; import { DailyRecurrence } from './DailyRecurrence'; import { MonthlyRecurrence } from './MonthlyRecurrence'; import { RecurrenceValidator } from './RecurrenceValidator'; import { WeeklyRecurrence } from './WeeklyRecurrence'; import { YearlyRecurrence } from './YearlyRecurrence'; export class RecurrenceFactory { private validator: RecurrenceValidator; private patterns: Map<string, RecurrencePattern>; constructor() { this.validator = new RecurrenceValidator(); this.patterns = new Map<string, RecurrencePattern>(); this.patterns.set('daily', new DailyRecurrence()); this.patterns.set('weekly', new WeeklyRecurrence()); this.patterns.set('monthly', new MonthlyRecurrence()); this.patterns.set('yearly', new YearlyRecurrence()); } /** * Creates and returns the appropriate recurrence pattern instance */ create(params: RecurrenceParams): RecurrencePattern { // Validate parameters first this.validator.validate(params); // Get the appropriate pattern const pattern = this.patterns.get(params.pattern); if (!pattern) { // This should never happen if validation works correctly debug.error('Unknown pattern (should never happen): %s', params.pattern); throw new ValidationError(`Unknown pattern: ${params.pattern}`, { pattern: params.pattern }); } return pattern; } /** * Validates parameters and calculates the next occurrence in one step */ calculate(from: Date, params: RecurrenceParams): Date { const pattern = this.create(params); return pattern.calculate(from, params); } }

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/pshempel/mcp-time-server-node'

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