UNPKG

@mseep/railway-mcp

Version:

Model Context Protocol server for Railway.app - Enables AI agents to manage Railway infrastructure through natural language

73 lines (72 loc) 2.38 kB
export class VariableRepository { client; constructor(client) { this.client = client; } async getVariables(projectId, environmentId, serviceId) { const data = await this.client.request(` query variables($projectId: String!, $environmentId: String!, $serviceId: String) { variables(projectId: $projectId, environmentId: $environmentId, serviceId: $serviceId) } `, { projectId, environmentId, serviceId }); return data.variables || {}; } async upsertVariable(input) { const { projectId, environmentId, serviceId, name, value } = input; await this.client.request(` mutation variableUpsert( $projectId: String!, $environmentId: String!, $serviceId: String, $name: String!, $value: String! ) { variableUpsert( input: { projectId: $projectId, environmentId: $environmentId, serviceId: $serviceId, name: $name, value: $value } ) } `, { projectId, environmentId, serviceId, name, value }); } async upsertVariables(inputs) { // Process variables in batches to avoid overwhelming the API const batchSize = 10; for (let i = 0; i < inputs.length; i += batchSize) { const batch = inputs.slice(i, i + batchSize); await Promise.all(batch.map(input => this.upsertVariable(input))); } } async deleteVariable(input) { const { projectId, environmentId, serviceId, name } = input; await this.client.request(` mutation variableDelete( $projectId: String!, $environmentId: String!, $serviceId: String, $name: String! ) { variableDelete( input: { projectId: $projectId, environmentId: $environmentId, serviceId: $serviceId, name: $name } ) } `, { projectId, environmentId, serviceId, name }); } async listVariables(serviceId, environmentId) { const data = await this.client.request(` query variables($serviceId: String!, $environmentId: String!) { variables(serviceId: $serviceId, environmentId: $environmentId) } `, { serviceId, environmentId }); return data.variables || []; } }