Skip to main content
Glama
version.ts2.33 kB
import * as semver from "semver"; import { runRailwayCommand } from "./core"; let cachedVersion: string | null = null; let versionCacheTime: number | null = null; const VERSION_CACHE_DURATION = 5 * 60 * 1000; /** * Get the Railway CLI version * @returns Version string (e.g., "4.9.0") or null if unable to determine */ export const getRailwayVersion = async (): Promise<string | null> => { // Use a cache to avoid constantly running railway --version. if ( cachedVersion && versionCacheTime && Date.now() - versionCacheTime < VERSION_CACHE_DURATION ) { return cachedVersion; } try { const { stdout } = await runRailwayCommand("railway --version"); // Use semver.coerce to extract a valid semver from various formats // This handles "railway 4.9.0", "railway version 4.9.0", "4.9.0", etc. const version = semver.coerce(stdout); if (version) { cachedVersion = version.version; versionCacheTime = Date.now(); return cachedVersion; } } catch (_error) { // Unable to determine version } return null; }; /** Clear the cached version */ export const clearVersionCache = (): void => { cachedVersion = null; versionCacheTime = null; }; /**Force a fresh version check */ export const refreshRailwayVersion = async (): Promise<string | null> => { clearVersionCache(); return getRailwayVersion(); }; /** * Compare version strings using semver * @returns 1 if version1 > version2, -1 if version1 < version2, 0 if equal */ export const compareVersions = (version1: string, version2: string): number => { return semver.compare(version1, version2); }; export type CliFeatureSupport = { logs: { args: { lines: boolean; filter: boolean; }; }; deployment: { list: boolean; }; }; /** Get Railway CLI feature support based on version */ export const getCliFeatureSupport = async (): Promise<CliFeatureSupport> => { const version = await getRailwayVersion(); const supportsLogFeatures = version ? semver.gte(version, "4.9.0") : false; const supportsDeploymentList = version ? semver.gte(version, "4.10.0") : false; return { logs: { args: { lines: supportsLogFeatures, filter: supportsLogFeatures, }, }, deployment: { list: supportsDeploymentList, }, }; };

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/railwayapp/railway-mcp-server'

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