Skip to main content
Glama

Timezone MCP Server

by sam-artuso
timezone.controller.tsβ€’2.88 kB
import { Controller, Get, Param, BadRequestException } from '@nestjs/common' import { ApiTags, ApiOperation, ApiResponse, ApiParam } from '@nestjs/swagger' import { TimezoneService } from './timezone.service' import { RegionsResponseDto } from './dto/regions-response.dto' import { CitiesResponseDto } from './dto/cities-response.dto' import { TimezoneResponseDto } from './dto/timezone-response.dto' @ApiTags('timezones') @Controller('timezones') export class TimezoneController { constructor(private readonly timezoneService: TimezoneService) {} @Get('regions') @ApiOperation({ summary: 'Get all timezone regions', description: 'Returns a list of all available timezone regions (e.g., America, Europe, Asia)', }) @ApiResponse({ status: 200, description: 'List of regions retrieved successfully', type: RegionsResponseDto, }) getRegions(): RegionsResponseDto { const regions = this.timezoneService.getRegions() return { regions, count: regions.length, } } @Get('regions/:region/cities') @ApiOperation({ summary: 'Get cities in a region', description: 'Returns all cities/locations available in a specific timezone region', }) @ApiParam({ name: 'region', description: 'Timezone region name (e.g., America, Europe, Asia)', example: 'America', }) @ApiResponse({ status: 200, description: 'List of cities retrieved successfully', type: CitiesResponseDto, }) @ApiResponse({ status: 400, description: 'Invalid region name provided', }) getCitiesInRegion(@Param('region') region: string): CitiesResponseDto { try { const cities = this.timezoneService.getCitiesInRegion(region) return { region, cities, count: cities.length, } } catch (error) { throw new BadRequestException(error.message) } } @Get(':region/:city') @ApiOperation({ summary: 'Get current time in timezone', description: 'Returns the current date and time in a specific timezone with ISO 8601 formatted timestamps', }) @ApiParam({ name: 'region', description: 'Timezone region (e.g., America, Europe, Asia)', example: 'America', }) @ApiParam({ name: 'city', description: 'City or location name (e.g., New_York, London, Tokyo)', example: 'New_York', }) @ApiResponse({ status: 200, description: 'Timezone information retrieved successfully', type: TimezoneResponseDto, }) @ApiResponse({ status: 400, description: 'Invalid timezone provided', }) getTimeInTimezone( @Param('region') region: string, @Param('city') city: string, ): TimezoneResponseDto { const timezone = `${region}/${city}` try { return this.timezoneService.getTimeInTimezone(timezone) } catch (error) { throw new BadRequestException(error.message) } } }

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/sam-artuso/demo-mcp'

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