Skip to main content
Glama

link-service

Link a service to your Railway project or list available services to connect. Specify a workspace path to manage service integrations efficiently.

Instructions

Link a service to the current Railway project. If no service is specified, it will list available services

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
serviceNameNoThe service name to link
workspacePathYesThe path to the workspace to link the service to

Implementation Reference

  • The async handler function that executes the 'link-service' tool: links a specified Railway service to the workspace or lists available services if no serviceName is provided, with comprehensive error handling.
    handler: async ({ workspacePath, serviceName }: LinkServiceOptions) => { try { if (serviceName) { // Link the specified service const result = await linkRailwayService({ workspacePath, serviceName, }); return createToolResponse( `✅ Successfully linked service '${serviceName}':\n\n${result}`, ); } else { // List available services const servicesResult = await getRailwayServices({ workspacePath }); if (!servicesResult.success) { return createToolResponse( "❌ Failed to get Railway services\n\n" + `**Error:** ${servicesResult.error}\n\n` + "**Next Steps:**\n" + "• Ensure you have a Railway project linked\n" + "• Check that you have permissions to view services\n" + "• Run `railway link` to ensure proper project connection", ); } if (!servicesResult.services || servicesResult.services.length === 0) { return createToolResponse( "ℹ️ No services found in this project. Create a service first.", ); } const result = `Available services:\n${servicesResult.services.map((s) => `- ${s}`).join("\n")}\n\nRun with a service name to link it.`; return createToolResponse(result); } } catch (error: unknown) { const errorMessage = error instanceof Error ? error.message : "Unknown error occurred"; return createToolResponse( "❌ Failed to link Railway service\n\n" + `**Error:** ${errorMessage}\n\n` + "**Next Steps:**\n" + "• Ensure you have a Railway project linked\n" + "• Check that the service name is correct\n" + "• Verify you have permissions to link services\n" + "• Run `railway link` to ensure proper project connection", ); } },
  • Zod input schema defining required 'workspacePath' and optional 'serviceName' parameters for the tool.
    inputSchema: { workspacePath: z .string() .describe("The path to the workspace to link the service to"), serviceName: z.string().optional().describe("The service name to link"), },
  • src/index.ts:21-31 (registration)
    Dynamically registers the 'link-service' tool (along with all other tools exported from './tools') on the MCP server using server.registerTool with name, metadata, and handler.
    Object.values(tools).forEach((tool) => { server.registerTool( tool.name, { title: tool.title, description: tool.description, inputSchema: tool.inputSchema, }, tool.handler, ); });

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/railwayapp/railway-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server