Skip to main content
Glama

days_in_month

Calculate the number of days in a specific or current month. Provide a date in YYYY-MM-DD format to determine the days in that month. Part of the time-mcp server, enhancing applications with accurate time-related functionalities.

Instructions

Get the number of days in a month. If no date is provided, get the number of days in the current month.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
dateNoThe date to get the days in month. Format: YYYY-MM-DD

Implementation Reference

  • Main handler logic for the 'days_in_month' tool call within the MCP server request handler. Validates arguments, computes the result using getDaysInMonth, and returns a formatted response.
    case 'days_in_month': {
      if (!checkDaysInMonthArgs(args)) {
        throw new Error(`Invalid arguments for tool: [${name}]`);
      }
    
      const date = args.date;
      const result = getDaysInMonth(date);
      return {
        success: true,
        content: [
          {
            type: 'text',
            text: `The number of days in month is ${result}.`,
          },
        ],
      };
    }
  • Tool schema definition for 'days_in_month', including name, description, and input schema.
    export const DAYS_IN_MONTH: Tool = {
      name: 'days_in_month',
      description: 'Get the number of days in a month. If no date is provided, get the number of days in the current month.',
      inputSchema: {
        type: 'object',
        properties: {
          date: {
            type: 'string',
            description: 'The date to get the days in month. Format: YYYY-MM-DD',
          },
        },
      },
    };
  • Core helper function that calculates the number of days in a given month (or current month) using dayjs library.
    function getDaysInMonth(date?: string) {
      return date ? dayjs(date).daysInMonth() : dayjs().daysInMonth();
    }
  • src/index.ts:30-34 (registration)
    Registration of the 'days_in_month' tool (via DAYS_IN_MONTH) in the server's list tools handler.
    server.setRequestHandler(ListToolsRequestSchema, async () => {
      return {
        tools: [CURRENT_TIME, RELATIVE_TIME, DAYS_IN_MONTH, GET_TIMESTAMP, CONVERT_TIME, GET_WEEK_YEAR],
      };
    });
  • Input validation helper function for 'days_in_month' tool arguments.
    function checkDaysInMonthArgs(args: unknown): args is { date: string } {
      return (
        typeof args === 'object' &&
        args !== null &&
        'date' in args &&
        typeof args.date === 'string'
      );
    }
Behavior3/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It describes the default behavior (current month if no date) and the basic operation, but doesn't mention error handling, format validation for the date parameter, or what happens with invalid dates. It adds some context beyond the schema but lacks comprehensive behavioral traits.

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 appropriately sized with two clear, front-loaded sentences that directly state the tool's function and default behavior. There is zero waste or redundancy, and every sentence earns its place by providing essential information efficiently.

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

Completeness4/5

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

Given the tool's low complexity (single optional parameter, simple calculation), no annotations, and no output schema, the description is reasonably complete. It covers the purpose, usage, and default behavior adequately, though it could benefit from mentioning error cases or output format to fully compensate for the lack of structured fields.

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 the single parameter 'date' with its format. The description adds marginal value by mentioning the default behavior (current month if no date provided), which implies the parameter is optional, but doesn't provide additional semantic details beyond what the schema specifies.

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

Purpose5/5

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

The description clearly states the tool's purpose with specific verbs ('Get the number of days in a month') and distinguishes it from siblings by focusing on month-day calculation rather than time conversion, timestamp retrieval, or relative time operations. It explicitly defines the resource (days in a month) and scope (current month if no date provided).

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

Usage Guidelines4/5

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

The description provides clear context for when to use this tool (to get days in a month, with current month as default) but doesn't explicitly mention when not to use it or name alternatives among siblings like 'convert_time' or 'get_timestamp'. It implies usage for date-based month calculations but lacks explicit exclusions or comparisons.

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

Related 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/yokingma/time-mcp'

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