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.

227 lines (226 loc) 7.19 kB
export class MonitoringRepository { client; constructor(client) { this.client = client; } async queryMetrics(input) { const query = ` query queryMetrics($projectId: String!, $serviceId: String, $metricName: String, $startTime: String!, $endTime: String!, $step: String, $labels: JSON) { project(id: $projectId) { metrics(serviceId: $serviceId, name: $metricName, startTime: $startTime, endTime: $endTime, step: $step, labels: $labels) { edges { node { id projectId serviceId name type description unit labels value timestamp createdAt } } } } } `; const response = await this.client.request(query, input); return response.project.metrics.edges.map(edge => edge.node); } async createCustomMetric(projectId, serviceId, name, type, value, labels, unit) { const query = ` mutation createCustomMetric($projectId: String!, $serviceId: String!, $name: String!, $type: MetricType!, $value: Float!, $labels: JSON, $unit: String) { metricCreate(projectId: $projectId, serviceId: $serviceId, name: $name, type: $type, value: $value, labels: $labels, unit: $unit) { id projectId serviceId name type value labels unit timestamp createdAt } } `; const response = await this.client.request(query, { projectId, serviceId, name, type, value, labels, unit }); return response.metricCreate; } async getAPMData(projectId, serviceId, startTime, endTime) { const query = ` query getAPMData($projectId: String!, $serviceId: String, $startTime: String, $endTime: String) { project(id: $projectId) { apmData(serviceId: $serviceId, startTime: $startTime, endTime: $endTime) { edges { node { id projectId serviceId timestamp responseTime throughput errorRate cpuUsage memoryUsage customMetrics } } } } } `; const response = await this.client.request(query, { projectId, serviceId, startTime, endTime }); return response.project.apmData.edges.map(edge => edge.node); } async listAlerts(projectId, serviceId) { const query = ` query listAlerts($projectId: String!, $serviceId: String) { project(id: $projectId) { alerts(serviceId: $serviceId) { edges { node { id projectId serviceId name description condition threshold severity isActive notifications { type destination } createdAt updatedAt } } } } } `; const response = await this.client.request(query, { projectId, serviceId }); return response.project.alerts.edges.map(edge => edge.node); } async createAlert(projectId, name, description, condition, threshold, severity, notifications, serviceId) { const query = ` mutation createAlert($projectId: String!, $serviceId: String, $name: String!, $description: String!, $condition: String!, $threshold: Float!, $severity: AlertSeverity!, $notifications: [NotificationInput!]!) { alertCreate(projectId: $projectId, serviceId: $serviceId, name: $name, description: $description, condition: $condition, threshold: $threshold, severity: $severity, notifications: $notifications) { id projectId serviceId name description condition threshold severity isActive notifications { type destination } createdAt } } `; const response = await this.client.request(query, { projectId, serviceId, name, description, condition, threshold, severity, notifications }); return response.alertCreate; } async updateAlert(alertId, isActive, threshold, notifications) { const query = ` mutation updateAlert($alertId: String!, $isActive: Boolean, $threshold: Float, $notifications: [NotificationInput!]) { alertUpdate(id: $alertId, isActive: $isActive, threshold: $threshold, notifications: $notifications) { id name isActive threshold notifications { type destination } updatedAt } } `; const response = await this.client.request(query, { alertId, isActive, threshold, notifications }); return response.alertUpdate; } async deleteAlert(alertId) { const query = ` mutation deleteAlert($alertId: String!) { alertDelete(id: $alertId) } `; const response = await this.client.request(query, { alertId }); return response.alertDelete; } async getTraces(projectId, serviceId, startTime, endTime, operationName) { const query = ` query getTraces($projectId: String!, $serviceId: String, $startTime: String, $endTime: String, $operationName: String) { project(id: $projectId) { traces(serviceId: $serviceId, startTime: $startTime, endTime: $endTime, operationName: $operationName) { edges { node { id traceId parentId operationName serviceName startTime endTime duration tags logs { timestamp message level } status } } } } } `; const response = await this.client.request(query, { projectId, serviceId, startTime, endTime, operationName }); return response.project.traces.edges.map(edge => edge.node); } async getTraceById(traceId) { const query = ` query getTraceById($traceId: String!) { trace(id: $traceId) { spans { id traceId parentId operationName serviceName startTime endTime duration tags logs { timestamp message level } status } } } `; const response = await this.client.request(query, { traceId }); return response.trace.spans; } }