UNPKG

@crazyrabbitltc/railway-mcp

Version:

Railway MCP Server - 146+ tools with 100% Railway API coverage, comprehensive MCP testing framework, and real infrastructure management through AI assistants. Enhanced version with enterprise features, based on original work by Jason Tan.

127 lines (126 loc) 4.8 kB
import { BaseApiClient } from './base-client.js'; import { CustomDomainRepository } from './repository/customDomain.repo.js'; import { DeploymentRepository } from './repository/deployment.repo.js'; import { DomainRepository } from './repository/domain.repo.js'; import { EnvironmentRepository } from './repository/environment.repo.js'; import { GitHubRepository } from './repository/github.repo.js'; import { LogsRepository } from './repository/logs.repo.js'; import { PluginRepository } from './repository/plugin.repo.js'; import { ProjectRepository } from './repository/project.repo.js'; import { ResourceRepository } from './repository/resource.repo.js'; import { ServiceRepository } from './repository/service.repo.js'; import { TcpProxyRepository } from './repository/tcpProxy.repo.js'; import { TeamRepository } from './repository/team.repo.js'; import { TemplateRepository } from './repository/template.repo.js'; import { UsageRepository } from './repository/usage.repo.js'; import { VariableRepository } from './repository/variable.repo.js'; import { VolumeRepository } from './repository/volume.repo.js'; import { WebhookRepository } from './repository/webhook.repo.js'; import { BackupRepository } from './repository/backup.repo.js'; import { SecurityRepository } from './repository/security.repo.js'; import { MonitoringRepository } from './repository/monitoring.repo.js'; import { NetworkingRepository } from './repository/networking.repo.js'; import { DeploymentAdvancedRepository } from './repository/deployment-advanced.repo.js'; export class RailwayApiClient extends BaseApiClient { customDomains; deployments; domains; environments; github; logs; plugins; projects; resource; services; tcpProxies; teams; templates; usage; variables; volumes; webhooks; backup; security; monitoring; networking; deploymentAdvanced; initialized = false; constructor() { super(); this.customDomains = new CustomDomainRepository(this); this.deployments = new DeploymentRepository(this); this.domains = new DomainRepository(this); this.environments = new EnvironmentRepository(this); this.github = new GitHubRepository(this); this.logs = new LogsRepository(this); this.plugins = new PluginRepository(this); this.projects = new ProjectRepository(this); this.resource = new ResourceRepository(this); this.services = new ServiceRepository(this); this.tcpProxies = new TcpProxyRepository(this); this.teams = new TeamRepository(this); this.templates = new TemplateRepository(this); this.usage = new UsageRepository(this); this.variables = new VariableRepository(this); this.volumes = new VolumeRepository(this); this.webhooks = new WebhookRepository(this); this.backup = new BackupRepository(this); this.security = new SecurityRepository(this); this.monitoring = new MonitoringRepository(this); this.networking = new NetworkingRepository(this); this.deploymentAdvanced = new DeploymentAdvancedRepository(this); } async initialize() { if (this.initialized) { return; } // Initialize with environment token if available const envToken = process.env.RAILWAY_API_TOKEN; if (envToken) { console.error('Initializing with environment token: ***[REDACTED]***'); try { this.token = envToken; await this.validateToken(); console.error('Successfully initialized with environment token'); } catch (error) { console.error('Failed to initialize with environment token:', error instanceof Error ? error.message : 'Unknown error'); this.token = null; } } else { console.error('No environment token found'); } this.initialized = true; } async request(query, variables) { return super.request(query, variables); } async setToken(token) { this.token = token; if (token) { await this.validateToken(); } } getToken() { return super.getToken(); } async validateToken() { try { const response = await this.request(` query { me { name email } } `); // Just check if the query succeeded } catch (error) { throw new Error('Invalid API token. Please check your token and try again.'); } } } // Initialize and export the singleton instance export const railwayClient = new RailwayApiClient();