---
title: "Building Uscreen’s remote, multi-tenant MCP server inside a Rails app"
description: "Evil Martians moved Uscreen's local, NPM-installed MCP server into Uscreen's Rails monolith, so creators connect an AI client by pasting a URL, signing in via OAuth, and approving access."
url: "https://swe.quest/articles/building-uscreen-s-remote-multi-tenant-mcp-server-inside-a-rails-app-1185c6f769ffbf8b"
canonical: "https://evilmartians.com/chronicles/building-uscreens-remote-multi-tenant-mcp-server-inside-a-rails-app"
source: "Evil Martians"
published: "2026-11-11"
difficulty: "medium"
kind: "Case study"
reading_minutes: 14
tags: ["ai-agents","ruby","multi-tenancy","identity-auth","api-design"]
---

# Building Uscreen’s remote, multi-tenant MCP server inside a Rails app

A post on [Evil Martians](https://swe.quest/sources/evil-martians.md), published 2026-11-11, 14 min read, Case study. Original: [https://evilmartians.com/chronicles/building-uscreens-remote-multi-tenant-mcp-server-inside-a-rails-app](https://evilmartians.com/chronicles/building-uscreens-remote-multi-tenant-mcp-server-inside-a-rails-app)

## Summary

Evil Martians moved Uscreen's local, NPM-installed MCP server into Uscreen's Rails monolith, so creators connect an AI client by pasting a URL, signing in via OAuth, and approving access. The official \`mcp\` gem was chosen over fast-mcp for stateless Streamable HTTP transport, per-request \`server\_context\`, and active maintenance. Doorkeeper provides OAuth 2.1 with dynamic client registration. 57 tools inherit from a shared \`Mcp::ApplicationTool\` base that handles scope checks, serialization and error mapping, and every lookup is scoped through the tenant Account. Structured ERB tool descriptions (purpose/returns/use\_when/do\_not\_use\_when) steer the model away from neighbouring tools, and destructive tools default to a dry-run preview, which is a safer default rather than an approval mechanism.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [AI agents](https://swe.quest/tags/ai-agents.md) (AI & ML)
- [Ruby](https://swe.quest/tags/ruby.md) (Languages)
- [Multi-tenancy](https://swe.quest/tags/multi-tenancy.md) (Architecture & design)
- [Identity & auth](https://swe.quest/tags/identity-auth.md) (Security)
- [API design](https://swe.quest/tags/api-design.md) (Backend & APIs)

## Prerequisites

- Ruby on Rails ([easy posts on Ruby](https://swe.quest/tags/ruby.md?difficulty=easy))
- OAuth 2.0 basics ([easy posts on Identity & auth](https://swe.quest/tags/identity-auth.md?difficulty=easy))
- Model Context Protocol basics

## Keywords

Model Context Protocol, Uscreen, Doorkeeper, mcp gem, fast-mcp, OAuth 2.1, Streamable HTTP, Rails

## Related posts

- [Every app needs an MCP server, and you can build it with Neon](https://swe.quest/articles/every-app-needs-an-mcp-server-and-you-can-build-it-with-neon-1a5ce4eab0583eca.md): Neon · 2026-11-25 · Easy · 11 min read · AI agents, Identity & auth, Serverless, PostgreSQL
  An MCP server lets users drive an app from AI assistants like ChatGPT, Claude and Cursor through tools the app defines, which keeps authorization and validation in app code instead of exposing the UI or raw database access.
- [Solving the MCP Authentication Headache with Vercel & Better Auth](https://swe.quest/articles/solving-the-mcp-authentication-headache-with-vercel-better-auth-749640ed1439e99c.md): Neon · 2025-05-23 · Medium · 5 min read · Identity & auth, AI agents, TypeScript
  Remote MCP servers can authenticate users with OAuth instead of plaintext bearer tokens or UUIDs stored in a client's mcp.json, using Better Auth's MCP plugin together with Vercel's @vercel/mcp-adapter in a Next.js app.
- [Bringing MCP to the Cloud](https://swe.quest/articles/bringing-mcp-to-the-cloud-de1944b558e43ff0.md): Neon · 2025-04-11 · Medium · 8 min read · AI agents, Identity & auth, API design, JavaScript
  Neon moved its MCP server from a locally spawned stdio process authenticated by a long-lived API key to a hosted server at mcp.neon.tech, using SSE for server-to-client messages and HTTP POST to a /messages endpoint routed by an in-memory session map.
- [Better Rails for Agents: A New Remote MCP and Railway Agent in the CLI](https://swe.quest/articles/better-rails-for-agents-a-new-remote-mcp-and-railway-agent-in-the-cli-4b9abaf62a02f3cd.md): Railway · 2026-04-17 · Medium · 13 min read · AI agents, API design, Developer tools, TypeScript
  Railway shipped a remote MCP server at mcp.railway.com, which connects to MCP clients over OAuth with no local install, and a new \`railway agent\` CLI command for interactive, scripted or CI use with JSON output.
- [Learnings from building our public MCP server](https://swe.quest/articles/learnings-from-building-our-public-mcp-server-4745c00cbf09b9ab.md): Wealthfront Engineering · 2026-11-02 · Medium · 8 min read · AI agents, Identity & auth, API design, Payments & fintech
  Wealthfront built a public MCP server so users can connect their cash and investing accounts to AI applications, using Streamable HTTP transport with synchronous calls only, all capabilities exposed as tools with per-tool scope enforcement, and OAuth for authentication.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
