@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.
76 lines (75 loc) • 2.74 kB
JavaScript
import { BaseService } from './base.service.js';
import { createSuccessResponse, createErrorResponse, formatError } from '../utils/responses.js';
export class TcpProxyService extends BaseService {
constructor() {
super();
}
/**
* Create a new TCP proxy for a service in a specific environment
* @param input TCP proxy creation parameters
*/
async createTcpProxy(input) {
try {
const tcpProxy = await this.client.tcpProxies.tcpProxyCreate(input);
return createSuccessResponse({
text: `TCP Proxy created successfully:
- Application Port: ${tcpProxy.applicationPort}
- Proxy Port: ${tcpProxy.proxyPort}
- Domain: ${tcpProxy.domain}
- ID: ${tcpProxy.id}`,
data: tcpProxy
});
}
catch (error) {
return createErrorResponse(`Error creating TCP proxy: ${formatError(error)}`);
}
}
/**
* Delete a TCP proxy by ID
* @param id TCP proxy ID to delete
*/
async deleteTcpProxy(id) {
try {
const result = await this.client.tcpProxies.tcpProxyDelete(id);
if (result) {
return createSuccessResponse({
text: `TCP Proxy with ID ${id} deleted successfully`,
data: { success: true }
});
}
else {
return createErrorResponse(`Failed to delete TCP Proxy with ID ${id}`);
}
}
catch (error) {
return createErrorResponse(`Error deleting TCP proxy: ${formatError(error)}`);
}
}
/**
* List all TCP proxies for a service in a specific environment
* @param environmentId Railway environment ID
* @param serviceId Railway service ID
*/
async listTcpProxies(environmentId, serviceId) {
try {
const proxies = await this.client.tcpProxies.listTcpProxies(environmentId, serviceId);
if (proxies.length === 0) {
return createSuccessResponse({
text: 'No TCP proxies found for this service.',
data: []
});
}
const proxyDetails = proxies.map(proxy => `- Application Port: ${proxy.applicationPort} → Proxy Port: ${proxy.proxyPort}
Domain: ${proxy.domain}
ID: ${proxy.id}`).join('\n\n');
return createSuccessResponse({
text: `TCP Proxies for this service:\n\n${proxyDetails}`,
data: proxies
});
}
catch (error) {
return createErrorResponse(`Error listing TCP proxies: ${formatError(error)}`);
}
}
}
export const tcpProxyService = new TcpProxyService();