---
title: "Deploy Mastra Server With Studio"
description: "Mastra server with Studio UI - build, test, and manage AI agents"
category: "AI/ML"
url: https://railway.com/deploy/mastra-server-with-studio
---

# Deploy Mastra Server With Studio

Mastra server with Studio UI - build, test, and manage AI agents

**[Deploy Mastra Server With Studio on Railway](https://railway.com/template/mastra-server-with-studio)**

- **Creator:** Sjoerd Tiemensma
- **Category:** AI/ML
- **Total deploys:** 8

## Template content

### Mastra Studio https://unpkg.com/mastra/dist/studio/mastra.svg

- **Source:** https://github.com/Sjotie/mastra-studio-railway
- **Health check:** /health
- **Public domain:** Yes

## Documentation

# Deploy and Host Mastra Server With Studio on Railway

[Mastra](https://mastra.ai) is the open-source TypeScript framework for building AI agents and workflows. This template deploys a complete Mastra server with [Mastra Studio](https://mastra.ai/docs/studio/overview) — the interactive UI for building, testing, and managing your agents — served from the same service. It ships with a starter agent (with conversation memory) you can chat with immediately.

## About Hosting Mastra Server With Studio

Hosting Mastra in production involves more than `mastra dev`: the server must be built with the `--studio` flag (Studio is not bundled by default), serve the Studio SPA via `MASTRA_STUDIO_PATH`, auto-detect its public URL so the UI doesn't call `localhost`, bind `0.0.0.0` inside the container, and persist agent memory across deploys. This template handles all of that: a multi-stage Docker build runs `mastra build --studio`, the runtime serves API + Studio on one port, LibSQL storage lives on a Railway volume, and access is protected out of the box with a generated key (Mastra Simple Auth) so your agents aren't publicly exposed. Bring an LLM provider API key, deploy, and log in.

## Common Use Cases

- Build, test, and iterate on AI agents in a hosted Studio UI shared with your team
- Run a production Mastra API (agents, workflows, tools) and manage it visually from the same deployment
- Prototype agent products without wiring up your own frontend
- A persistent playground for agent memory, scorers, and datasets that survives redeploys

## Dependencies for Mastra Server With Studio Hosting

- An LLM provider API key (OpenAI by default; any [model router](https://mastra.ai/models) provider works via the `MODEL` variable)
- A Railway volume (included) for LibSQL storage

### Deployment Dependencies

- [Mastra documentation](https://mastra.ai/docs)
- [Mastra Studio overview](https://mastra.ai/docs/studio/overview)
- [Studio deployment guide](https://mastra.ai/docs/studio/deployment)
- [Studio auth](https://mastra.ai/docs/studio/auth)
- [Template source on GitHub](https://github.com/Sjotie/mastra-studio-railway)

### Implementation Details

The service logs you in with the generated `STUDIO_AUTH_KEY` (check the service variables): open the deployed URL, paste the key on the login screen. All API routes also accept it as a Bearer token:

```bash
curl -H "Authorization: Bearer $STUDIO_AUTH_KEY" https://your-service.up.railway.app/api/agents
```

Customize the starter agent in `src/mastra/agents/assistant.ts`, change the model with the `MODEL` variable (`provider/model` format), and add your own agents, tools, and workflows — every push redeploys.

### Why Deploy Mastra Server With Studio on Railway?

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 Mastra Server With Studio 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.


## Similar templates

- [Chat Chat](https://railway.com/deploy/-WWW5r) — Chat Chat, your own unified chat and search to AI platform.
- [stella](https://railway.com/deploy/stella) — Self-host stella with web, API, Postgres, Redis, and object storage.
- [Hermes Agent | OpenClaw Alternative with Dashboard](https://railway.com/deploy/hermes-agent-or-openclaw-alternative-wit) — Self-Hosted Hermes AI Agent for Telegram, Discord & Slack

Open this page in a browser: https://railway.com/deploy/mastra-server-with-studio
