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.

42 lines (41 loc) 1.51 kB
export class BaseApiClient { apiUrl = 'https://backboard.railway.app/graphql/v2'; wsUrl = 'wss://backboard.railway.app/graphql/v2'; token = null; constructor() { console.error('BaseApiClient initialized'); } getToken() { return this.token; } async request(query, variables) { if (!this.token) { console.error('No token available for request. Environment token exists:', !!process.env.RAILWAY_API_TOKEN); throw new Error('API token not set. Please either:\n1. Add RAILWAY_API_TOKEN to your environment variables, or\n2. Use the configure tool to set the token manually.'); } const debug = process.env.DEBUG; const isDebug = debug === 'railway:*' || debug?.includes('railway:api'); if (isDebug) { console.error('GraphQL Request initiated'); } const response = await fetch(this.apiUrl, { method: 'POST', headers: { 'Content-Type': 'application/json', 'Authorization': `Bearer ${this.token}`, }, body: JSON.stringify({ query, variables, }), }); const result = await response.json(); if (isDebug) { console.error('GraphQL Response received'); } if (result.errors && result.errors.length > 0) { throw new Error(result.errors[0].message); } return result.data; } }