@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.
73 lines (72 loc) • 2.38 kB
JavaScript
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 || [];
}
}