Deploy Claude Code MCP

Run Claude Code with MCP servers on an always-on Ubuntu box

Deploy Claude Code MCP

Deploy and Host self hosted Claude Code MCP (Adding MCP Servers to Claude Code) on Railway

This template runs Claude Code on an always-on Ubuntu 26.04 box, reachable by browser or SSH. Built for developers who want MCP tools in their terminal agent.

About Hosting Claude Code MCP open-source software on Railway (self hosted Claude Code MCP server setup and scopes template)

This template gives you an Ubuntu 26.04 LTS box with Claude Code 2.1.314 installed, reachable from a browser terminal and over SSH on one tmux session.

Railway runs the container, terminates TLS on the web terminal, proxies SSH, and handles restarts. You still own the box.

Why Deploy Claude Code MCP, the Claude Desktop alternative on Railway (Railway Free Trial)

Claude Desktop is the easy way to get MCP tools in front of Claude, but its servers live on your laptop and stop when the lid closes.

Railway is a singular platform to deploy your infrastructure stack. Railway will host your infrastructure so you don't have to deal with configuration, while allowing you to vertically and horizontally scale it.

By deploying Claude Code MCP on Railway, you are one step closer to supporting a complete full-stack application with minimal burden. Host your servers, databases, AI agents, and more on Railway.

Railway vs Other Hosting Providers and VPS for Claude Code MCP self hosting

Railway ships the Ubuntu + Claude Code box with a persistent /home volume, so MCP config survives redeploys. A VPS means building that yourself.

ProviderWhat You Get with RailwayWhat You Get with the Other Provider
DigitalOceanOne-click template with a persistent /home volume and browser plus SSH access.A Droplet you harden, firewall, and install Claude Code on yourself.
AWSThe volume and networking are pre-wired for claude mcp add config.Full EC2, EBS, and IAM control, with persistence and access set up by you.
Hetzner~/.claude.json and .mcp.json persist by default, no manual mounts.Cheap bare servers, but backups and the MCP setup are yours to run.

Pick a VPS if you need full root control and will run the box yourself.

Common Use Cases for hosted Claude Code MCP

  • Connecting a remote HTTP MCP server: Run claude mcp add --transport http notion https://mcp.notion.com/mcp once from the web terminal, then start claude and use /mcp to sign in. The server is available to every session on the box.
  • Sharing project MCP servers with a team: Add the server with --scope project so it lands in .mcp.json, then commit that file. Teammates approve the server once before it runs.
  • Keeping personal servers in user scope: Servers added with --scope user load in every project on the box. Your personal tools stay out of shared repos.
  • Debugging a stuck server: Run claude mcp list to check health, then /mcp to see status, re-authenticate, or toggle the server off without deleting its config.
  • Persisting MCP config across redeploys: Since /home is the persistent volume, keep ~/.claude.json and any .mcp.json under /home. Config stored elsewhere is lost when the container is rebuilt.

Dependencies for Claude Code MCP Docker hosted on Railway

This template runs as one Railway service named Ubuntu, built from ghcr.io/onepush-dev/ubuntu-claude-code:26.04-claude2.1.314. The only volume mounts at /home, where your MCP config lives.

Deployment Dependencies for Managed Claude Code MCP Service (Claude Code + ttyd + OpenSSH + tmux)

The stack bundles Claude Code 2.1.314, installed globally as the claude command, plus Node.js 22, npm, Python 3, git, and ripgrep. ttyd protects the browser terminal with basic auth using TERMINAL_USER and TERMINAL_PASSWORD.

Implementation Details for Claude Code MCP (Using Ubuntu + Claude Code official docker image)

Everything under /home persists, including the ~/.claude login and any .mcp.json you commit, so servers added with claude mcp add survive redeploys.

How does Claude Code MCP compare against other ways to add MCP servers to Claude Code and Claude Desktop, Cursor, Cline

Claude Code MCP vs Claude Desktop (Claude Desktop Alternative)

  • MCP setup: Claude Code adds servers with claude mcp add, by URL for HTTP or by command for stdio.
  • Config location: Scopes decide where config lives: local, project (a committed .mcp.json), or user.
  • Where Claude Desktop wins: It is a GUI chat app for people who never open a shell.

Claude Code MCP vs Cursor (Cursor Alternative)

  • Interface: Claude Code runs in a terminal you reach from a browser or SSH, while Cursor is a desktop editor.
  • Server management: Check health with claude mcp list and authenticate remote servers with /mcp.
  • Where Cursor wins: Inline diffs and tab completion are built in, and Claude Code on this box has neither.

Claude Code MCP vs Cline (Cline Alternative)

  • Host: Cline is a VS Code extension tied to your local machine, while this box runs on an always-on server.
  • Server config: Cline stores servers in extension settings, while Claude Code uses scopes set on the command line.
  • Where Cline wins: It sits inside VS Code next to your files and needs no hosting.

Claude Code MCP vs Claude Code on the web (Hosted Alternative)

  • Ownership: The web version runs in Anthropic's hosted environment, while this is your own box with servers and files under /home.
  • Custom servers: You can install any stdio server command here and keep it in user or project scope.
  • Where the web version wins: Nothing to deploy or maintain, and it works from any browser.

How to use Claude Code MCP (the OSS Adding MCP Servers to Claude Code)?

  1. Open the web terminal at your Railway domain or SSH in with ssh -p PORT ubuntu@HOST. Both land in the shared tmux session.

  2. Add a remote HTTP server with claude mcp add --transport http NAME URL, or a stdio server with claude mcp add NAME -- COMMAND ARGS. Keep the -- in place.

  3. Pick a scope with --scope: local (default, this project only), project (writes a shared .mcp.json for your team to commit), or user (every project on the box).

  4. Run claude mcp list to confirm each server is healthy.

  5. Start claude and run /mcp to authenticate a remote server or toggle servers. Approve any project-scoped server marked Pending approval before its tools load.

claude mcp add --transport http notion https://mcp.notion.com/mcp
claude mcp add --scope project filesystem -- npx -y @modelcontextprotocol/server-filesystem /home/ubuntu/repos
claude mcp list
claude

How to self host Claude Code MCP on other VPS Services (Ubuntu + Claude Code self hosting guide)

Run the same Ubuntu and Claude Code stack on your own VPS, so claude mcp add servers and their config survive reboots under your home directory.

Clone the Repository

git clone https://github.com/onepush-dev/ubuntu-claude-code.git
cd ubuntu-claude-code

Install Dependencies

On Ubuntu 26.04, install the tools and pin Claude Code:

sudo apt-get update
sudo apt-get install -y nodejs npm ripgrep python3 python3-venv git
sudo npm install -g @anthropic-ai/claude-code@2.1.314

Configure Environment Variables

Add your key and disable self-updates in a file only your user can read:

echo 'export DISABLE_AUTOUPDATER=1' >> ~/.bashrc
echo 'export ANTHROPIC_API_KEY=your-api-key' >> ~/.bashrc
chmod 600 ~/.bashrc

Start the Claude Code MCP Application

Start a tmux session, add a remote HTTP server, and check its health:

tmux new -s main
claude mcp add --transport http notion https://mcp.notion.com/mcp
claude mcp list

Run /mcp inside Claude Code to authenticate. Railway handles TLS, the public domain, and the persistent volume for you.

Official Pricing of Claude Code MCP (Ubuntu + Claude Code pricing)

Claude Code MCP is free and open source under the MIT license, so the template itself costs nothing.

Claude Code MCP cloud vs self hosted comparison (Pricing, features, costs, and more)

Self hosting Claude Code MCP keeps your MCP servers, scopes, and auth on a persistent volume you own. Here is how the two paths compare.

Monthly cost of self hosting Claude Code MCP on Railway

Railway bills for the compute and storage your service uses, so the monthly figure depends on uptime and how much you keep under /home.

System Requirements for Hosting Claude Code MCP on a VPS

On a plain VPS you take on the OS, firewall, and TLS work that Railway handles for you. Treat the terminal password like a root password, because anyone with it can run code on the box.

Frequently Asked Questions (FAQs)

Do I need to re-add servers after a redeploy?

No, as long as the config lives under /home. Anything installed with apt outside /home, such as a server's system packages, is lost and needs reinstalling.

Where is the config stored?

Local-scope servers are recorded in ~/.claude.json under the project path, user-scope servers in the same file at the top level, and project-scope servers in .mcp.json at the repo root.

What is the difference between local, project and user scope?

Local is the default and applies only to the current project for your user. User applies to every project on this box.

Why does a project server show Pending approval?

Claude Code requires you to approve servers defined in a shared .mcp.json before they run.

How do I authenticate a remote MCP server?

Start claude, run /mcp, and select the server to complete its OAuth sign-in flow. Once authenticated, the token is stored with your Claude Code config under /home.

How do I remove a server?

Run claude mcp remove with the server name, adding the matching --scope flag if the server is not in local scope. Confirm with claude mcp list afterward.


Template Content

More templates in this category

View Template
Chat Chat
Chat Chat, your own unified chat and search to AI platform.

okisdev
117
View Template
NEW
Weaviate
Vector database with hybrid search and an API key-protected API

zer0person
1
View Template
Möbius v0.1 Personal AI OS
Self-hosted AI agent that builds and runs apps for you, with memory.

bento
1