Skip to main content
Glama
ainarsklavins

Date MCP Server

Get Day of Week

get-day-of-week

Determine the day of the week for any date or today's date. Specify a locale to get localized day names in formats like YYYY-MM-DD.

Instructions

Returns the day of the week for a given date or today.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
dateNoDate in YYYY-MM-DD format (defaults to today)
localeNoLocale for day name (e.g., "en-US", "de-DE")

Implementation Reference

  • The handler function implementing the 'get-day-of-week' tool. It parses an optional date (YYYY-MM-DD) or uses today, validates it, determines the day of the week using toLocaleDateString and getDay(), handles errors for invalid date or locale, and returns structured JSON content.
    async ({ date, locale = 'en-US' }) => {
      const targetDate = date ? new Date(date + 'T00:00:00') : new Date();
    
      if (isNaN(targetDate.getTime())) {
        return {
          content: [{ type: 'text', text: 'Error: Invalid date format. Use YYYY-MM-DD.' }],
          isError: true
        };
      }
    
      try {
        return {
          content: [{
            type: 'text',
            text: JSON.stringify({
              dayName: targetDate.toLocaleDateString(locale, { weekday: 'long' }),
              dayNumber: targetDate.getDay(),
              date: targetDate.toISOString().split('T')[0]
            }, null, 2)
          }]
        };
      } catch {
        return {
          content: [{ type: 'text', text: `Error: Invalid locale "${locale}".` }],
          isError: true
        };
      }
    }
  • Input schema for the 'get-day-of-week' tool using Zod, defining optional 'date' (YYYY-MM-DD) and 'locale' parameters with descriptions.
    {
      title: 'Get Day of Week',
      description: 'Returns the day of the week for a given date or today.',
      inputSchema: {
        date: z.string().optional().describe('Date in YYYY-MM-DD format (defaults to today)'),
        locale: z.string().optional().describe('Locale for day name (e.g., "en-US", "de-DE")')
      }
    },
  • src/index.ts:47-85 (registration)
    The server.registerTool call registering the 'get-day-of-week' tool with its name, schema, and handler function.
    server.registerTool(
      'get-day-of-week',
      {
        title: 'Get Day of Week',
        description: 'Returns the day of the week for a given date or today.',
        inputSchema: {
          date: z.string().optional().describe('Date in YYYY-MM-DD format (defaults to today)'),
          locale: z.string().optional().describe('Locale for day name (e.g., "en-US", "de-DE")')
        }
      },
      async ({ date, locale = 'en-US' }) => {
        const targetDate = date ? new Date(date + 'T00:00:00') : new Date();
    
        if (isNaN(targetDate.getTime())) {
          return {
            content: [{ type: 'text', text: 'Error: Invalid date format. Use YYYY-MM-DD.' }],
            isError: true
          };
        }
    
        try {
          return {
            content: [{
              type: 'text',
              text: JSON.stringify({
                dayName: targetDate.toLocaleDateString(locale, { weekday: 'long' }),
                dayNumber: targetDate.getDay(),
                date: targetDate.toISOString().split('T')[0]
              }, null, 2)
            }]
          };
        } catch {
          return {
            content: [{ type: 'text', text: `Error: Invalid locale "${locale}".` }],
            isError: true
          };
        }
      }
    );

Tool Definition Quality

Score is being calculated. Check back soon.

Install Server

Other Tools

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/ainarsklavins/date-mcp'

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