Skip to main content
Glama
ampcome-mcps

Time MCP Server

by ampcome-mcps

get_timestamp

Convert human-readable date and time strings into Unix timestamps for programming and data processing applications.

Instructions

Get the timestamp for the time.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
timeNoThe time to get the timestamp. Format: YYYY-MM-DD HH:mm:ss

Implementation Reference

  • The core handler function that computes the Unix timestamp (milliseconds) for the given time string (parsed as UTC) or the current time.
    function getTimestamp(time?: string) { return time ? dayjs.utc(time).valueOf() : dayjs().valueOf(); }
  • Defines the Tool object for 'get_timestamp' including name, description, and input schema allowing optional 'time' parameter.
    export const GET_TIMESTAMP: Tool = { name: 'get_timestamp', description: 'Get the timestamp for the time.', inputSchema: { type: 'object', properties: { time: { type: 'string', description: 'The time to get the timestamp. Format: YYYY-MM-DD HH:mm:ss', }, }, }, };
  • src/index.ts:30-34 (registration)
    Registers the GET_TIMESTAMP tool in the list of available tools returned by ListToolsRequest.
    server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools: [CURRENT_TIME, RELATIVE_TIME, DAYS_IN_MONTH, GET_TIMESTAMP, CONVERT_TIME, GET_WEEK_YEAR], }; });
  • Dispatches the get_timestamp tool call: validates arguments, invokes getTimestamp handler, and formats the response content.
    case 'get_timestamp': { if (!checkTimestampArgs(args)) { throw new Error(`Invalid arguments for tool: [${name}]`); } const time = args.time; const result = getTimestamp(time); return { success: true, content: [ { type: 'text', text: time ? `The timestamp of ${time} (parsed as UTC) is ${result} ms.` : `The current timestamp is ${result} ms.`, }, ], }; }
  • Helper function to validate input arguments for the get_timestamp tool.
    function checkTimestampArgs(args: unknown): args is { time?: string } { return ( typeof args === 'object' && args !== null && 'time' in args && (typeof args.time === 'string' || args.time === undefined) ); }

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