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.

213 lines (212 loc) 4.61 kB
export class UsageRepository { client; constructor(client) { this.client = client; } async getTeamUsage(teamId, startDate, endDate) { const query = ` query getTeamUsage($teamId: String!, $startDate: String, $endDate: String) { teamUsage(teamId: $teamId, startDate: $startDate, endDate: $endDate) { id teamId period { start end } metrics { cpu { used limit unit cost } memory { used limit unit cost } network { used limit unit cost } disk { used limit unit cost } builds { used limit unit cost } executions { used limit unit cost } } costs { total breakdown { compute memory network storage builds addOns } currency } } } `; const response = await this.client.request(query, { teamId, startDate, endDate }); return response.teamUsage; } async getProjectUsage(projectId, startDate, endDate) { const query = ` query getProjectUsage($projectId: String!, $startDate: String, $endDate: String) { projectUsage(projectId: $projectId, startDate: $startDate, endDate: $endDate) { id teamId projectId period { start end } metrics { cpu { used limit unit cost } memory { used limit unit cost } network { used limit unit cost } disk { used limit unit cost } builds { used limit unit cost } executions { used limit unit cost } } costs { total breakdown { compute memory network storage builds addOns } currency } } } `; const response = await this.client.request(query, { projectId, startDate, endDate }); return response.projectUsage; } async getBillingInfo(teamId) { const query = ` query getBillingInfo($teamId: String!) { teamBilling(teamId: $teamId) { teamId plan { name type limits { projects services cpu memory storage networkGB buildMinutes executions } price currency billingCycle } currentUsage { amount currency period { start end } } paymentMethod { type last4 expiryMonth expiryYear } nextBillingDate } } `; const response = await this.client.request(query, { teamId }); return response.teamBilling; } async getUsageAlerts(teamId) { const query = ` query getUsageAlerts($teamId: String!) { usageAlerts(teamId: $teamId) { edges { node { id teamId type threshold currentValue isActive notificationEmail createdAt } } } } `; const response = await this.client.request(query, { teamId }); return response.usageAlerts.edges.map(edge => edge.node); } }