
TL;DR
Your coding agent can write the code. With Railway's official MCP server it can ship it too: create the project, deploy the service, assign a domain, tweak variables, and read logs, all as tool calls. The complete one-hour build.
Your coding agent writes the pull request. You review it, merge it, and then the familiar second half of the job starts: open the hosting dashboard, create the project, push the code, wait for the build, assign a domain, find the logs when it crashes. That second half is exactly the kind of repetitive tool work an agent should be doing for you, and in 2026 it can: Railway ships an official Model Context Protocol (MCP) server that turns its whole platform into a toolset your agent can call.
This guide wires that server into OpenCode, the open source agent CLI, so one prompt covers the entire journey: create the project, deploy the service, assign a domain, verify it responds, tweak a variable, redeploy, and read the logs when something breaks. No dashboard clicks, no context switching, no "ship it" messages to your future self. Seven steps, under an hour, every step ending in something you can run. If you are new to MCP itself, the beginner guide covers the protocol; here we stay on the build.
| Resource | Description |
|---|---|
| Railway MCP Server | The server, both transport modes, and the full tool list |
| Railway for Agents | CLI, MCP, and agent skills setup for AI coding agents |
| railway mcp command reference | railway mcp install and the exact config it writes per editor |
| Railway CLI | Install, login, and every CLI command |
| OpenCode MCP docs | Adding local and remote MCP servers to OpenCode |
| Railway Pricing | Plans, included usage, and per-resource rates |
Prerequisites: a Railway account (the free trial comes with a one-time $5 grant, which covers this whole build), a code directory for a small test app, and a model provider key for OpenCode.
Install OpenCode with the official one-liner from the docs:
curl -fsSL https://opencode.ai/install | bash
Install the Railway CLI from the official docs. The no-frills path:
bash <(curl -fsSL railway.com/install.sh)
There is also curl -fsSL agents.railway.com | sh, which installs the CLI and immediately runs railway setup agent for detected editors, and npm i -g @railway/cli if you prefer npm (requires Node 16 or newer). Verify both sides:
opencode --version
railway --version
What you have now: two CLIs on your machine, nothing connected yet.
OpenCode needs a provider. Run opencode auth login and pick one; this week's DeepSeek V4 Flash guide covers why a budget model is plenty for tool orchestration like this. Prove the harness runs one task and exits:
opencode run --model opencode/deepseek-v4-flash "print the current directory tree, two levels deep"
Railway needs your account. The login command opens a browser; use --browserless on a headless box:
railway login
Confirm the session:
railway whoami
What you have now: two authenticated CLIs. The next step is where they meet.
Railway's agent setup writes the MCP configuration for you. The docs document three ways to connect - Local MCP, Remote MCP through a CLI proxy, and Remote MCP with direct OAuth - and railway mcp install targets specific editors with --agent. For OpenCode:
railway mcp install --agent opencode
This merges an entry into OpenCode's config without touching any other MCP servers you have configured. What it writes, per the documented config table:
{
"$schema": "https://opencode.ai/config.json",
"mcp": {
"railway": {
"type": "local",
"command": ["railway", "mcp"],
"enabled": true
}
}
}
You could write that file by hand, but the installer is better: it keeps the exact command shape current across CLI releases. Verify the server registered:
opencode mcp list
You should see railway listed with a local transport. Now run a probe that forces tool use:
opencode run --model opencode/deepseek-v4-flash "list my Railway workspaces, projects, and services. use railway"
A real answer instead of an apology means the loop is live. Local MCP runs railway mcp as a child process using your existing railway login session, so there is no token file to leak and nothing to refresh.
What you have now: your coding agent can see Railway. It can read; the next step lets it ship.
From the archive
Aug 11, 2026 • 7 min read
Aug 11, 2026 • 7 min read
Aug 11, 2026 • 6 min read
Aug 11, 2026 • 6 min read
Local MCP exposes the CLI workflow as tools: projects (list_workspaces, list_projects, create_project), services (create_service, connect_service_source, scale_service), deployments (deploy, list_deployments), domains (generate_domain, domain_status), variables (list_variables, set_variables), and observability (get_logs, service_metrics). The full list is in the MCP server docs.
Fire the canonical prompt from those same docs:
Create a Next.js app in this directory and deploy it to Railway.
Also assign it a domain.
Watch the sequence: the agent scaffolds the app, calls create_project, connects the directory as a service, triggers deploy, waits on deployment status, and runs generate_domain. When it reports a URL, hit it:
curl -I https://<your-service>.up.railway.app
Expect a 200 (or the 3xx from your app's own redirect - the point is a live response, not a dashboard state). You just went from a blank directory to a deployed, domain'd service with one sentence and zero dashboard tabs.
What you have now: a deployed service your agent built and shipped in one session.
Deployment is the first step, not the last. Keep the whole operating loop inside the agent:
Add an environment variable GREETING=hello to my api service and deploy the change.
Then show me the last 20 lines of its logs.
That is set_variables, a fresh deploy, and get_logs back to back. This is the loop you will use every day: change something, ship it, look at the logs, iterate. When you want to check what is costing you money, the agent can do that too:
Show me my current Railway usage and what it is costing. use railway
Small services like this one stay comfortably inside the Hobby plan's $5 of included usage ($20/vCPU/month and $10/GB/month, billed per minute, per the pricing docs) - but the habit of checking costs from the same chat that deploys is the one that keeps the overnight-bill failure mode from ever being yours.
What you have now: a deploy and iterate loop that never leaves the agent.
Local MCP covers day-to-day operations, but two capabilities are remote-only: redeploy / accept-deploy, and railway-agent, Railway's hosted agent tool for multi-step work like log analysis and crash diagnosis. Install remote mode the same way:
railway mcp install --agent opencode --remote
This swaps the entry to command: ["railway", "mcp", "proxy"] - the proxy reuses your railway login credentials and forwards to mcp.railway.com over HTTPS. There is also --remote --oauth, which writes {"type": "remote", "url": "https://mcp.railway.com"} and hands OAuth to OpenCode itself; with that mode, run opencode mcp auth railway once and OpenCode stores the token in its own auth store.
Now break the app on purpose, so the debugger has something to find. Set a variable that points your service at a nonexistent value and deploy. Then ask:
Use the railway agent to figure out why my api service is crashing on deploy.
The railway-agent tool investigates on Railway's side - logs, config, recent deploys - and comes back with a diagnosis and a proposed fix. If you would rather work without the MCP hop, the same brain is available as a CLI command, documented at railway agent: railway agent -p "help me debug why my api service is failing". When the fix lands, accept-deploy is how a staged change ships.
What you have now: a debugging path for when your agent's own code is not the thing that is broken.
Giving a coding agent deploy access is a real capability, and the security model matters more than the convenience. The Railway docs are explicit, and the rails worth keeping:
remove_service, delete_domain, redeploy, accept-deploy, and railway-agent are marked with protocol-level hints, and Local MCP returns a preview that requires your confirm: true. Read the preview; an agent that deletes a service costs you a rebuild.railway usage is your monthly scoreboard.What you have now: a deploy-capable agent with explicit confirmations, scoped credentials, and a cost check in the loop.
A coding session that starts with "build me this" and ends with a live URL, with every intermediate step - project, deploy, domain, variables, logs, diagnosis - a tool call instead of a dashboard. The same connection works in Claude Code, Cursor, Codex, and the rest if you want it elsewhere, and Railway's agent skills (railway skills install) add procedural knowledge on top of the tools. The pattern that stays with you: hosting platforms are becoming agent toolsets, and the agent that writes the code should be the one that ships it.
Yes. Railway documents OpenCode as a supported agent: railway mcp install --agent opencode writes the exact config entry (local stdio, CLI proxy, or remote OAuth), and OpenCode's own MCP support handles local and remote servers with opencode mcp list to verify.
Local MCP for day-to-day work on a machine where you are already logged in with railway login - it runs the CLI as a child process with no token files. Remote MCP when you want the railway-agent debugging tool, redeploy / accept-deploy, or a hosted connection that survives your laptop.
Deploy to non-critical environments, keep destructive tools behind their confirmations, scope OAuth to specific workspaces, and use short-lived revocable tokens. Railway's remote MCP deliberately does not accept project tokens, so every action trails back to a user identity.
The build stays inside the free trial's one-time $5 grant and, after that, the Hobby plan's $5 monthly fee with $5 of included usage. A single small service typically stays inside the included amount; per-resource rates are $20/vCPU/month and $10/GB/month billed per minute. Ask your agent for railway usage instead of guessing.
No. Local MCP and the CLI proxy reuse your railway login session, and remote OAuth authenticates in OpenCode via opencode mcp auth railway. For remote MCP specifically, Railway does not accept project tokens.
| Source | URL |
|---|---|
| Railway MCP Server | https://docs.railway.com/ai/mcp-server |
| Railway for Agents | https://docs.railway.com/agents |
| railway mcp command reference | https://docs.railway.com/cli/mcp |
| railway agent command reference | https://docs.railway.com/cli/agent |
| Railway CLI | https://docs.railway.com/cli |
| Railway Pricing | https://docs.railway.com/reference/pricing |
| OpenCode MCP docs | https://opencode.ai/docs/mcp-servers/ |
| OpenCode Docs | https://opencode.ai/docs/ |
Some links to tools above are referral links - see our affiliate disclosure.
Last updated: August 11, 2026
Read next
MCP just became stateless, which means your own MCP server is now just an HTTP endpoint that deploys like any web service. Build one with an agent, deploy it on Railway, and point opencode or Claude Code at the public URL. The full build, start to finish.
10 min readOpenCode is the fastest-growing open-source AI coding agent - 160K GitHub stars, 7.5M monthly users, 75+ model providers. Here is how to set it up, configure models, and use it effectively in your workflow.
11 min readThe most common trigger for an AI coding agent is not a clock, it is an event. A GitHub webhook, a Railway service, and OpenCode headless add up to a repo where a labeled issue gets a real pull request without anyone at the keyboard. The full build, start to finish.
10 min readTechnical content at the intersection of AI and development. Building with AI agents, Claude Code, and modern dev tools - then showing you exactly how it works.
Registry and hosting platform for MCP servers. 6,000+ servers indexed. One-command install and configuration via CLI. Su...
View ToolAI-native code editor forked from VS Code. Composer mode rewrites multiple files at once. Tab autocomplete predicts your...
View ToolOpen-source terminal agent runtime with approval modes, rollback snapshots, MCP servers, LSP diagnostics, and a headless...
View ToolStackBlitz's in-browser AI app builder. Full-stack apps from a prompt - runs Node.js, installs packages, and deploys....
View ToolOne command deploys any MCP server to a public URL. No infra wiring.
View AppTurn a one-liner into a working Claude Code skill. From idea to installed in a minute.
View AppRun any MCP server without running infra. Private endpoints, no DevOps.
View AppStep-by-step guide to building an MCP server in TypeScript - from project setup to tool definitions, resource handling, testing, and deployment.
AI AgentsWhat MCP servers are, how they work, and how to build your own in 5 minutes.
AI AgentsConfigure Claude Code for maximum productivity -- CLAUDE.md, sub-agents, MCP servers, and autonomous workflows.
AI Agents
To try everything Brilliant has to offer—free—for a full 30 days, visit https://brilliant.org/DevelopersDigest/ . You’ll also get 20% off an annual premium subscription. Build and Deploy...

Build MCP Servers with Databutton It's been a huge few months for MCP! In this video, I'll show you how to build and deploy MCP servers using Databutton— all with just natural language....

In this video, discover how to build your customized voice AI agents using TEN Agent, an open-source conversational AI platform. Learn to integrate top speech-to-text models, large language...

MCP just became stateless, which means your own MCP server is now just an HTTP endpoint that deploys like any web servic...

OpenCode is the fastest-growing open-source AI coding agent - 160K GitHub stars, 7.5M monthly users, 75+ model providers...

The most common trigger for an AI coding agent is not a clock, it is an event. A GitHub webhook, a Railway service, and...

An agent CLI plus a cron schedule turns recurring dev chores into background work: dependency bumps, doc freshness check...

MCP is the USB-C of AI agents. What the Model Context Protocol is, why Anthropic built it, and how to install your first...

The agent finishes, the summary scrolls past, and you will read it later. Build the fix: a coding agent that ends every...

New tutorials, open-source projects, and deep dives on coding agents - delivered weekly.