tcp_proxy_create
Create a TCP proxy to expose database access or configure external connections for services on Railway.app, enabling secure TCP service exposure.
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 |
|---|---|---|---|
| environmentId | Yes | ID of the environment (usually obtained from service_info) | |
| serviceId | Yes | ID of the service | |
| applicationPort | Yes | Port of application/service to proxy, usually based off of the service's Dockerfile or designated running port. |
Implementation Reference
- src/tools/tcpProxy.tool.ts:57-63 (handler)The main handler function for the tcp_proxy_create tool. It receives input parameters and delegates to tcpProxyService.createTcpProxy.async ({ environmentId, serviceId, applicationPort }) => { return tcpProxyService.createTcpProxy({ environmentId, serviceId, applicationPort }); }
- src/tools/tcpProxy.tool.ts:52-56 (schema)Zod input schema for the tcp_proxy_create tool defining environmentId, serviceId, and applicationPort.{ 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/tcpProxy.tool.ts:31-64 (registration)Tool registration using createTool, which includes the name 'tcp_proxy_create', formatted description, input schema, and handler function.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 }); } ),
- Helper service method that handles the business logic, calls the repository, and formats the CallToolResult response.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)}`); } }
- Repository helper that executes the GraphQL mutation to create the TCP proxy on the Railway API.async tcpProxyCreate(input: TcpProxyCreateInput): Promise<TcpProxy> { const query = ` mutation tcpProxyCreate($input: TCPProxyCreateInput!) { tcpProxyCreate(input: $input) { id applicationPort createdAt deletedAt domain environmentId proxyPort serviceId updatedAt } } `; const variables = { input }; const response = await this.client.request<{ tcpProxyCreate: TcpProxy }>(query, variables); return response.tcpProxyCreate; }