Building Uscreen’s remote, multi-tenant MCP server inside a Rails app
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.
Related posts
- Every app needs an MCP server, and you can build it with Neon
Neon easyNovice
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. A production server needs a public HTTPS endpoint, OAuth 2.1 with Client ID Metadata Documents to identify users, per-user database access, and tool annotations to be listed in plugin stores. Neon's pitch covers each piece: Neon Functions host the server next to Postgres, Managed Better Auth's OAuth provider plugin issues tokens whose `sub` matches user IDs in the same database, and branches isolate development. A demo app (a 5x5 shared grid with a single paint_square tool) shows the whole build done through prompts to a coding agent.
- Solving the MCP Authentication Headache with Vercel & Better Auth
Neon mediumAdept
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. Setup touches three files: add the mcp plugin with a login page to the Better Auth config, expose the .well-known/oauth-authorization-server discovery route, and wrap the MCP handler so it resolves the user's session via getMCPSession and returns 401 when none exists. The session's user ID can then scope tool access to that user's own data. Clients such as Cursor, connecting through mcp-remote, open a login popup on first use.
- Bringing MCP to the Cloud
Neon mediumAdept
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. Authentication uses OAuth 2.1: the MCP server acts as an OAuth server to MCP clients, with dynamic client registration, PKCE and refresh tokens, and as an OAuth client to Neon upstream. Each session gets its own MCP server instance scoped to the user's Neon token. The server runs as a Docker image on Fly. Open issues include the Node.js dependency introduced by mcp-remote and clients restarting the OAuth flow instead of using refresh tokens.
- Better Rails for Agents: A New Remote MCP and Railway Agent in the CLI
Railway mediumAdeptRailway 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. The MCP surface is kept deliberately small at 7 tools, because every tool definition costs client context and multi-step operations cost a round-trip each. Questions such as "why is my deploy crashing" go to a `railway-agent` tool that runs the multi-step investigation server-side and returns one answer. Instead of a separate service, the MCP server is a stateless Koa route inside the main backend. It reuses the existing OIDC provider and permission controllers, passes per-request context through AsyncLocalStorage, and wraps tools in a factory that handles auth and errors.
- Learnings from building our public MCP server
Wealthfront Engineering mediumAdeptWealthfront 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. For OAuth client registration they weighed Client ID Metadata Documents, which few agents support, against Dynamic Client Registration (RFC 7591), which carries abuse and DoS hardening scope. They chose user-generated client IDs bound to the creating user, trading setup friction for a faster, safer launch. Testing showed that intent-based tools beat entity-based CRUD-style tools, and that precise parameter and output descriptions prevent agents from misreading fields like an internal accountId.