tcp_proxy_create
Create a TCP proxy to enable external access to services, configure database connections, or expose TCP endpoints on the railway-mcp server. Requires environment ID, service ID, and application port.
Instructions
[API] Create a new TCP proxy for a service
⚡️ Best for: ✓ Setting up database access ✓ Configuring external connections ✓ Exposing TCP services
⚠️ Not for: × HTTP/HTTPS endpoints (use domain_create) × Internal service communication
→ Prerequisites: service_list
→ Alternatives: domain_create
→ Next steps: tcp_proxy_list
→ Related: service_info, service_update
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| applicationPort | Yes | Port of application/service to proxy, usually based off of the service's Dockerfile or designated running port. | |
| environmentId | Yes | ID of the environment (usually obtained from service_info) | |
| serviceId | Yes | ID of the service |
Implementation Reference
- src/tools/tcpProxy.tool.ts:31-64 (handler)The core handler implementation for the 'tcp_proxy_create' tool. It defines the tool using createTool, including description, Zod input schema, and the async executor that calls tcpProxyService.createTcpProxy with the provided parameters.createTool( "tcp_proxy_create", formatToolDescription({ type: 'API', description: "Create a new TCP proxy for a service", bestFor: [ "Setting up database access", "Configuring external connections", "Exposing TCP services" ], notFor: [ "HTTP/HTTPS endpoints (use domain_create)", "Internal service communication" ], relations: { prerequisites: ["service_list"], nextSteps: ["tcp_proxy_list"], alternatives: ["domain_create"], related: ["service_info", "service_update"] } }), { environmentId: z.string().describe("ID of the environment (usually obtained from service_info)"), serviceId: z.string().describe("ID of the service"), applicationPort: z.number().describe("Port of application/service to proxy, usually based off of the service's Dockerfile or designated running port.") }, async ({ environmentId, serviceId, applicationPort }) => { return tcpProxyService.createTcpProxy({ environmentId, serviceId, applicationPort }); } ),
- src/tools/tcpProxy.tool.ts:52-56 (schema)Zod schema defining the input parameters for the tcp_proxy_create tool: environmentId (string), serviceId (string), applicationPort (number).{ environmentId: z.string().describe("ID of the environment (usually obtained from service_info)"), serviceId: z.string().describe("ID of the service"), applicationPort: z.number().describe("Port of application/service to proxy, usually based off of the service's Dockerfile or designated running port.") },
- src/tools/index.ts:16-37 (registration)Registration of all tools, including tcpProxyTools (which contains tcp_proxy_create), by spreading into allTools array and registering each with server.tool().export function registerAllTools(server: McpServer) { // Collect all tools const allTools = [ ...databaseTools, ...deploymentTools, ...domainTools, ...projectTools, ...serviceTools, ...tcpProxyTools, ...variableTools, ...configTools, ...volumeTools, ...templateTools, ] as Tool[]; // Register each tool with the server allTools.forEach((tool) => { server.tool( ...tool ); }); }
- Helper service method invoked by the tool handler to perform the actual TCP proxy creation via the API client, handling success/error responses.async createTcpProxy(input: TcpProxyCreateInput): Promise<CallToolResult> { 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)}`); } }
- src/types.ts:337-344 (schema)TypeScript interface defining the input shape for TCP proxy creation, matching the tool's schema and used by service/repo.export interface TcpProxyCreateInput { /** ID of the environment */ environmentId: string; /** ID of the service */ serviceId: string; /** Container port that will be proxied */ applicationPort: number; }