@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.
145 lines (144 loc) • 4.14 kB
JavaScript
export class DeploymentRepository {
client;
constructor(client) {
this.client = client;
}
async listDeployments({ projectId, serviceId, environmentId, limit }) {
const data = await this.client.request(`
query deployments($projectId: String!, $serviceId: String!, $environmentId: String, $limit: Int) {
deployments(
input: {
projectId: $projectId,
serviceId: $serviceId,
${environmentId ? `environmentId: $environmentId` : ''}
},
first: $limit
) {
edges {
node {
id
status
createdAt
staticUrl
url
serviceId
environmentId
projectId
meta
deploymentStopped
}
}
}
}
`, {
projectId,
serviceId,
environmentId,
limit,
});
return data.deployments.edges.map(edge => ({
...edge.node,
projectId: edge.node.projectId || edge.node.serviceId,
meta: edge.node.meta || {},
deploymentStopped: edge.node.deploymentStopped || false
}));
}
async getDeployment(id) {
const data = await this.client.request(`
query deployment($id: String!) {
deployment(id: $id) {
id
status
createdAt
serviceId
environmentId
url
staticUrl
canRedeploy
canRollback
projectId
meta
deploymentStopped
}
}
`, { id });
return data.deployment || null;
}
async triggerDeployment(input) {
const { commitSha, environmentId, serviceId } = input;
const data = await this.client.request(`
mutation serviceInstanceDeployV2($commitSha: String, $environmentId: String!, $serviceId: String!) {
serviceInstanceDeployV2(
commitSha: $commitSha
environmentId: $environmentId
serviceId: $serviceId
)
}
`, { commitSha, environmentId, serviceId });
return data.serviceInstanceDeployV2;
}
async getBuildLogs(deploymentId, limit = 100) {
const data = await this.client.request(`
query buildLogs($deploymentId: String!, $limit: Int) {
buildLogs(deploymentId: $deploymentId, limit: $limit) {
timestamp
message
severity
attributes {
key
value
}
}
}
`, { deploymentId, limit });
return data.buildLogs || [];
}
async getDeploymentLogs(deploymentId, limit = 100) {
const data = await this.client.request(`
query deploymentLogs($deploymentId: String!, $limit: Int) {
deploymentLogs(deploymentId: $deploymentId, limit: $limit) {
timestamp
message
severity
attributes {
key
value
}
}
}
`, { deploymentId, limit });
return data.deploymentLogs || [];
}
async restartDeployment(id) {
await this.client.request(`
mutation deploymentRestart($id: String!) {
deploymentRestart(id: $id)
}
`, { id });
}
async rollbackDeployment(id) {
await this.client.request(`
mutation deploymentRollback($id: String!) {
deploymentRollback(id: $id)
}
`, { id });
}
async cancelDeployment(id) {
await this.client.request(`
mutation deploymentCancel($id: String!) {
deploymentCancel(id: $id)
}
`, { id });
}
async healthCheckDeployment(deploymentId) {
await new Promise(resolve => setTimeout(resolve, 5000)); // TODO: Replace later with a wait for the deployment to be healthy with websocket subscriptions
const data = await this.client.request(`
query deployment($id: String!) {
deployment(id: $id) {
status
}
}
`, { id: deploymentId });
return data.deployment.status;
}
}