Skip to main content
Glama
pshempel

MCP Time Server Node

by pshempel

get_server_info

Retrieve version and build details to verify server status and compatibility for time manipulation operations.

Instructions

Get server version and build information

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The main handler function implementing the get_server_info tool. It collects server version from package.json, git revision/branch/dirty status, Node version, and timezone.
    export function getServerInfo(_params?: unknown): ServerInfo { debug.server('getServerInfo called'); // Try to read build-time version info first const versionJson = readVersionJson(); // Always use package.json for version (source of truth) const version = getPackageVersion(); // Use build-time info if available, otherwise detect at runtime const revision = versionJson?.revision ?? getGitRevision(); const branch = versionJson?.branch ?? getGitBranch(); // Build the response const info: ServerInfo = { version, revision, branch, node_version: process.version, timezone: Intl.DateTimeFormat().resolvedOptions().timeZone, }; // Add optional fields if available if (versionJson?.buildDate) { info.build_date = versionJson.buildDate; } if (versionJson?.buildNumber) { info.build_number = versionJson.buildNumber; } // Include dirty status if available const dirty = versionJson?.dirty ?? getGitDirtyStatus(); if (dirty !== undefined) { info.dirty = dirty; } debug.server('getServerInfo returning: v%s, rev: %s, branch: %s', version, revision, branch); return info; }
  • TypeScript interface defining the structure of the ServerInfo object returned by the getServerInfo tool.
    interface ServerInfo { version: string; revision: string; branch: string; dirty?: boolean; build_date?: string; build_number?: string; node_version: string; timezone: string; }
  • src/index.ts:33-40 (registration)
    Tool registration in TOOL_DEFINITIONS array, specifying name, description, and empty input schema for the tools/list endpoint.
    { name: 'get_server_info', description: 'Get server version and build information', inputSchema: { type: 'object' as const, properties: {}, }, },
  • src/index.ts:257-257 (registration)
    Mapping of tool name 'get_server_info' to the getServerInfo handler function in TOOL_FUNCTIONS for tools/call execution.
    get_server_info: (params: unknown) => getServerInfo(params),
  • Helper function to extract version from package.json, used by getServerInfo.
    function getPackageVersion(): string { try { const packagePath = path.join(__dirname, '../../package.json'); // eslint-disable-next-line security/detect-non-literal-fs-filename const packageContent = fs.readFileSync(packagePath, 'utf8'); const packageData = JSON.parse(packageContent) as { version?: string }; return packageData.version ?? '1.0.0'; } catch { return '1.0.0'; } }

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/pshempel/mcp-time-server-node'

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