Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Comprehensive guide for building production-ready MCP servers with tools, resources, prompts, and React widgets using mcp-use.
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
references/foundations/deployment.md
1# Deployment23Guide for deploying MCP servers to production.45## ⚠️ FIRST: Ensure the User is Logged In67**Before any deployment command, always verify authentication:**89```bash10mcp-use whoami11```1213If this fails or the user has never logged in, run `mcp-use login` first — it opens a browser for OAuth.1415**Non-interactive / agent contexts:** if you were handed a one-time device code16(e.g. from the web onboarding flow), authenticate without a browser:1718```bash19mcp-use login --device-code <CODE>20```2122The code is short-lived and already approved, so the CLI redeems it immediately.2324---2526## Quick Deploy (Manufact Cloud)2728There are two ways to deploy, depending on where the code should live.2930### Option A — Managed repo (no GitHub required)3132Best for getting live fast, or when the user hasn't connected GitHub. The CLI33uploads your local source; the repo is created in the platform-managed org and34deployed through the normal pipeline:3536```bash37mcp-use deploy --no-github38```3940No git remote, no GitHub App install. The user can later move it to their own41GitHub from the server's dashboard ("Connect your GitHub").4243### Option B — Your own GitHub4445Deploys from a repository in the user's GitHub account (enables push-to-deploy):4647```bash48mcp-use deploy49```5051Or via the npm script (pre-configured in all templates):5253```bash54npm run deploy55```5657Either way, your server is live at `https://{slug}.run.mcp-use.com/mcp`.5859---6061## Prerequisites6263**No-GitHub deploy (`--no-github`)** only needs you to be **logged in** (`mcp-use whoami`).64No git, no GitHub App — the CLI uploads your local source directly.6566**GitHub deploy** (`mcp-use deploy` without `--no-github`) additionally needs:67681. **Git repository** — your project must be a git repo692. **GitHub remote** — the `origin` remote must point to GitHub (SSH or HTTPS)703. **Changes pushed** — deployment pulls from GitHub, not your local files. Commit and push first.714. **GitHub App installed** — the mcp-use GitHub App must have access to the repo. The CLI prompts you to install it if missing, or install it at `github.com/apps/mcp-use/installations/new`.7273---7475## Deploy Options7677```bash78mcp-use deploy [options]79```8081| Flag | Description | Default |82| --------------------- | ------------------------------------------------------------ | ------------------------------------- |83| `--no-github` | Upload local source without connecting GitHub | `false` |84| `--org <slug>` | Deploy to a specific organization (by slug or id) | configured org |85| `--name <name>` | Custom deployment name | `package.json` name or directory name |86| `--port <port>` | Server port | `3000` |87| `--runtime <runtime>` | `"node"` or `"python"` | Auto-detected from project files |88| `--env <KEY=VALUE>` | Set environment variable value (repeatable) | — |89| `--env-file <path>` | Load env vars from a file | — |90| `--branch <name>` | Deploy branch; also scopes `--env`/`--env-file` to its preview | current git branch |91| `--open` | Open deployment in browser after success | `false` |92| `--new` | Force a fresh deployment (ignore existing link) | `false` |93| `-y, --yes` | Skip confirmation prompts (non-interactive / CI / agents) | `false` |9495> Redeploys of a platform-managed project are auto-detected from the linked server, so96> `--no-github` is only needed on the first deploy.9798### Setting Environment Variables99100```bash101# Inline102mcp-use deploy --env API_KEY=sk-xxx --env DATABASE_URL=postgres://...103104# From file105mcp-use deploy --env-file .env.production106```107108**NEVER commit secrets to git.** Use `--env` or `--env-file` for API keys, database URLs, and other sensitive values.109110After the server exists, manage env vars (and other config) without redeploying:111112```bash113# Env vars (production scope, or scope to a branch's preview with --branch)114mcp-use servers env list --server <id>115mcp-use servers env add API_KEY=sk-xxx --server <id> --env production,preview116mcp-use servers env update API_KEY --server <id> --value sk-yyy # by KEY or UUID117mcp-use servers env rm API_KEY --server <id>118119# Server config in place (no delete/recreate): production branch, name, commands120mcp-use servers update <id> --branch main --build-command "npm run build"121# Clear a build/start override: pass an empty string (--build-command "")122```123124---125126## Common Mistakes127128- ❌ Running `mcp-use deploy` without verifying auth first129- ✅ Always run `mcp-use whoami` before deploying — run `mcp-use login` if needed130- ❌ Running `mcp-use deploy` with uncommitted/unpushed changes131- ✅ The cloud builds from GitHub — always `git push` first132- ❌ Hardcoding secrets in code or committing `.env`133- ✅ Use `--env` / `--env-file` flags, or `mcp-use servers env add KEY=VALUE --server <id>`134- ❌ Forgetting to install the mcp-use GitHub App on the repo135- ✅ The CLI will prompt you, but you can also install it at `github.com/apps/mcp-use` — or skip GitHub entirely with `mcp-use deploy --no-github`136- ❌ Running `mcp-use start` without `mcp-use build` first137- ✅ Always build before starting in production138