link-environment
Link a specific workspace to a Railway environment or list available environments for selection using the Railway MCP Server tool.
Instructions
Link to a specific Railway environment. If no environment is specified, it will list available environments for selection.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| environmentName | Yes | The environment name to link to | |
| workspacePath | Yes | The path to the workspace to link the environment to |
Implementation Reference
- src/tools/link-environment.ts:17-39 (handler)The handler function that executes the core logic of the 'link-environment' tool by calling the CLI linker and handling responses/errors.handler: async ({ workspacePath, environmentName, }: LinkEnvironmentOptions) => { try { const result = await linkRailwayEnvironment({ workspacePath, environmentName, }); return createToolResponse(result); } catch (error: unknown) { const errorMessage = error instanceof Error ? error.message : "Unknown error occurred"; return createToolResponse( "❌ Failed to link environment\n\n" + `**Error:** ${errorMessage}\n\n` + "**Next Steps:**\n" + "• Ensure you have a Railway project linked\n" + "• Check that the environment name is correct\n" + "• Run `railway environment` to see available environments", ); } },
- src/tools/link-environment.ts:11-16 (schema)Zod input schema defining parameters for the tool: workspacePath (string) and environmentName (string).inputSchema: { workspacePath: z .string() .describe("The path to the workspace to link the environment to"), environmentName: z.string().describe("The environment name to link to"), },
- src/index.ts:21-31 (registration)Registers all tools (including 'link-environment') exported from './tools' with the MCP server.Object.values(tools).forEach((tool) => { server.registerTool( tool.name, { title: tool.title, description: tool.description, inputSchema: tool.inputSchema, }, tool.handler, ); });
- src/tools/index.ts:8-8 (registration)Exports the linkEnvironmentTool for inclusion in the aggregated tools module used by the MCP server.export { linkEnvironmentTool } from "./link-environment";