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
          };
        }
      }
    );
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden for behavioral disclosure. It states the basic function but doesn't mention important behavioral aspects: whether it's read-only (implied but not stated), what happens with invalid dates/locales, format of returned day names, or localization behavior. The description is minimal and lacks operational context.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is perfectly concise - a single sentence that states exactly what the tool does with zero wasted words. It's front-loaded with the core functionality and includes the essential scope information ('for a given date or today'). Every word earns its place.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a simple read-only tool with 100% schema coverage but no output schema, the description is minimally adequate. It states the core function but lacks information about return format (string? object?), error behavior, or localization details. With no annotations and no output schema, users must infer these aspects from the tool name and parameters alone.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already fully documents both parameters (date format, locale examples). The description adds no additional parameter semantics beyond what's in the schema - it doesn't explain when to use locale parameter, what happens if omitted, or provide examples of day name outputs. Baseline 3 is appropriate when schema does all the work.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's function ('Returns the day of the week') and specifies the resource ('for a given date or today'). It distinguishes from siblings like 'format-date' by focusing specifically on day-of-week extraction rather than general date formatting. However, it doesn't explicitly contrast with 'get-current-datetime' which might also provide day information.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives like 'format-date' (which could also return day of week) or 'get-current-datetime' (which provides comprehensive datetime info). There's no mention of use cases, prerequisites, or trade-offs between this tool and its siblings.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

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