@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.
164 lines (163 loc) • 4.68 kB
JavaScript
export class ResourceRepository {
client;
constructor(client) {
this.client = client;
}
async getTeamQuotas(teamId) {
const query = `
query getTeamQuotas($teamId: String!) {
teamResourceQuotas(teamId: $teamId) {
edges {
node {
teamId
resourceType
allocated
used
unit
isShared
priority
expiresAt
}
}
}
}
`;
const response = await this.client.request(query, { teamId });
return response.teamResourceQuotas.edges.map(edge => edge.node);
}
async getProjectAllocations(projectId) {
const query = `
query getProjectAllocations($projectId: String!) {
projectResourceAllocations(projectId: $projectId) {
edges {
node {
id
projectId
serviceId
resourceType
amount
unit
isReserved
priority
createdAt
updatedAt
}
}
}
}
`;
const response = await this.client.request(query, { projectId });
return response.projectResourceAllocations.edges.map(edge => edge.node);
}
async updateAllocation(allocationId, amount, priority) {
const query = `
mutation updateResourceAllocation($allocationId: String!, $amount: Float!, $priority: ResourcePriority) {
resourceAllocationUpdate(id: $allocationId, amount: $amount, priority: $priority) {
id
projectId
serviceId
resourceType
amount
unit
isReserved
priority
updatedAt
}
}
`;
const response = await this.client.request(query, {
allocationId,
amount,
priority
});
return response.resourceAllocationUpdate;
}
async getResourceLimits(teamId) {
const query = `
query getResourceLimits($teamId: String!) {
teamResourceLimits(teamId: $teamId) {
edges {
node {
id
teamId
resourceType
hardLimit
softLimit
unit
alertThreshold
isEnforced
createdAt
}
}
}
}
`;
const response = await this.client.request(query, { teamId });
return response.teamResourceLimits.edges.map(edge => edge.node);
}
async updateResourceLimit(limitId, hardLimit, softLimit, alertThreshold) {
const query = `
mutation updateResourceLimit($limitId: String!, $hardLimit: Float, $softLimit: Float, $alertThreshold: Float) {
resourceLimitUpdate(id: $limitId, hardLimit: $hardLimit, softLimit: $softLimit, alertThreshold: $alertThreshold) {
id
teamId
resourceType
hardLimit
softLimit
unit
alertThreshold
isEnforced
}
}
`;
const response = await this.client.request(query, {
limitId,
hardLimit,
softLimit,
alertThreshold
});
return response.resourceLimitUpdate;
}
async getOptimizationRecommendations(projectId) {
const query = `
query getResourceOptimization($projectId: String!) {
projectResourceOptimization(projectId: $projectId) {
projectId
recommendations {
type
resourceType
currentValue
recommendedValue
estimatedSavings
confidence
description
}
totalEstimatedSavings
analysisDate
}
}
`;
const response = await this.client.request(query, { projectId });
return response.projectResourceOptimization;
}
async getUsageHistory(resourceId, startDate, endDate) {
const query = `
query getResourceUsageHistory($resourceId: String!, $startDate: String!, $endDate: String!) {
resourceUsageHistory(resourceId: $resourceId, startDate: $startDate, endDate: $endDate) {
edges {
node {
id
resourceId
timestamp
value
unit
metadata
}
}
}
}
`;
const response = await this.client.request(query, { resourceId, startDate, endDate });
return response.resourceUsageHistory.edges.map(edge => edge.node);
}
}