Skip to main content
Glama
ampcome-mcps

Time MCP Server

by ampcome-mcps

get_week_year

Determine the week and ISO week of the year for a specific date using the Time MCP Server. Input the date in 'YYYY-MM-DD' format to retrieve accurate time-based calculations.

Instructions

Get the week and isoWeek of the year.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
dateNoThe date to get the week and isoWeek of the year. e.g. 2025-03-23

Implementation Reference

  • The core handler function that computes the week and ISO week of the year for a given date or the current date using dayjs library.
    function getWeekOfYear(date?: string) { const week = date ? dayjs(date).week() : dayjs().week(); const isoWeek = date ? dayjs(date).isoWeek() : dayjs().isoWeek(); return { week, isoWeek, }; }
  • Defines the Tool object with name, description, and input schema for the 'get_week_year' tool.
    export const GET_WEEK_YEAR: Tool = { name: 'get_week_year', description: 'Get the week and isoWeek of the year.', inputSchema: { type: 'object', properties: { date: { type: 'string', description: 'The date to get the week and isoWeek of the year. e.g. 2025-03-23', }, }, }, };
  • src/index.ts:30-34 (registration)
    Registers the GET_WEEK_YEAR tool in the list of available tools for the MCP server.
    server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools: [CURRENT_TIME, RELATIVE_TIME, DAYS_IN_MONTH, GET_TIMESTAMP, CONVERT_TIME, GET_WEEK_YEAR], }; });
  • Dispatch handler in the CallToolRequestSchema that validates args, calls getWeekOfYear, and formats the response.
    case 'get_week_year': { if (!checkWeekOfYearArgs(args)) { throw new Error(`Invalid arguments for tool: [${name}]`); } const { date } = args; const { week, isoWeek } = getWeekOfYear(date); return { success: true, content: [ { type: 'text', text: `The week of the year is ${week}, and the isoWeek of the year is ${isoWeek}.`, }, ], }; }
  • Helper function to validate input arguments for the get_week_year tool.
    function checkWeekOfYearArgs(args: unknown): args is { date: string } { return ( typeof args === 'object' && args !== null && ('date' in args ? typeof args.date === 'string' : true) ); }

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

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