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.

255 lines (250 loc) 6.4 kB
export class LogsRepository { client; constructor(client) { this.client = client; } async getBuildLogs(deploymentId, filter, limit, startDate, endDate) { const query = ` query buildLogs( $deploymentId: String! $filter: String $limit: Int $startDate: DateTime $endDate: DateTime ) { buildLogs( deploymentId: $deploymentId filter: $filter limit: $limit startDate: $startDate endDate: $endDate ) { timestamp message severity attributes tags } } `; const variables = { deploymentId, filter, limit, startDate, endDate }; const data = await this.client.request(query, variables); return data.buildLogs || []; } async getDeploymentLogs(deploymentId, filter, limit, startDate, endDate) { const query = ` query deploymentLogs( $deploymentId: String! $filter: String $limit: Int $startDate: DateTime $endDate: DateTime ) { deploymentLogs( deploymentId: $deploymentId filter: $filter limit: $limit startDate: $startDate endDate: $endDate ) { timestamp message severity attributes tags } } `; const variables = { deploymentId, filter, limit, startDate, endDate }; const data = await this.client.request(query, variables); return data.deploymentLogs || []; } async getEnvironmentLogs(environmentId, filter, limit, startDate, endDate, anchorDate) { const query = ` query environmentLogs( $environmentId: String! $filter: String $afterDate: String $afterLimit: Int $anchorDate: String $beforeDate: String $beforeLimit: Int ) { environmentLogs( environmentId: $environmentId filter: $filter afterDate: $afterDate afterLimit: $afterLimit anchorDate: $anchorDate beforeDate: $beforeDate beforeLimit: $beforeLimit ) { timestamp message severity attributes tags } } `; // Map our parameters to the GraphQL API's expected format const variables = { environmentId, filter, afterDate: startDate, afterLimit: limit, anchorDate, beforeDate: endDate, beforeLimit: limit }; const data = await this.client.request(query, variables); return data.environmentLogs || []; } async getHttpLogs(deploymentId, filter, limit, startDate, endDate) { const query = ` query httpLogs( $deploymentId: String! $filter: String $limit: Int $startDate: String $endDate: String ) { httpLogs( deploymentId: $deploymentId filter: $filter limit: $limit startDate: $startDate endDate: $endDate ) { timestamp requestId deploymentId deploymentInstanceId method path host clientUa srcIp httpStatus responseDetails totalDuration downstreamProto upstreamProto upstreamAddress upstreamRqDuration edgeRegion rxBytes txBytes } } `; const variables = { deploymentId, filter, limit, startDate, endDate }; const data = await this.client.request(query, variables); return data.httpLogs || []; } async getMetrics(startDate, measurements, groupBy, options = {}) { const query = ` query metrics( $startDate: DateTime! $measurements: [MetricMeasurement]! $groupBy: [MetricTag]! $endDate: DateTime $projectId: String $environmentId: String $serviceId: String $deploymentId: String $pluginId: String $volumeId: String $sampleRateSeconds: Int $averagingWindowSeconds: Int $includeDeleted: Boolean ) { metrics( startDate: $startDate measurements: $measurements groupBy: $groupBy endDate: $endDate projectId: $projectId environmentId: $environmentId serviceId: $serviceId deploymentId: $deploymentId pluginId: $pluginId volumeId: $volumeId sampleRateSeconds: $sampleRateSeconds averagingWindowSeconds: $averagingWindowSeconds includeDeleted: $includeDeleted ) { measurement tags values { timestamp value } } } `; const variables = { startDate, measurements, groupBy, ...options }; const data = await this.client.request(query, variables); return data.metrics || []; } async getPluginLogs(pluginId, environmentId, filter, limit, startDate, endDate) { const query = ` query pluginLogs( $pluginId: String! $environmentId: String! $filter: String $limit: Int $startDate: DateTime $endDate: DateTime ) { pluginLogs( pluginId: $pluginId environmentId: $environmentId filter: $filter limit: $limit startDate: $startDate endDate: $endDate ) { timestamp message severity attributes tags } } `; const variables = { pluginId, environmentId, filter, limit, startDate, endDate }; const data = await this.client.request(query, variables); return data.pluginLogs || []; } }