Skip to main content
Glama
ampcome-mcps

Time MCP Server

by ampcome-mcps

days_in_month

Calculate the number of days in any month. Specify a date or use current month to get accurate day counts for planning and scheduling.

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

  • Handler for the 'days_in_month' tool within the CallToolRequestSchema request handler. Validates arguments, computes days using getDaysInMonth, and formats the 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', }, }, }, };
  • src/index.ts:30-34 (registration)
    Registers the DAYS_IN_MONTH tool (among others) in the ListToolsRequestSchema handler for tool discovery.
    server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools: [CURRENT_TIME, RELATIVE_TIME, DAYS_IN_MONTH, GET_TIMESTAMP, CONVERT_TIME, GET_WEEK_YEAR], }; });
  • Helper function that calculates the number of days in a specified month (or current month) using dayjs.
    function getDaysInMonth(date?: string) { return date ? dayjs(date).daysInMonth() : dayjs().daysInMonth(); }
  • Helper function to validate input arguments for the days_in_month tool.
    function checkDaysInMonthArgs(args: unknown): args is { date: string } { return ( typeof args === 'object' && args !== null && 'date' in args && typeof args.date === 'string' ); }

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/ampcome-mcps/time-mcp'

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