Skip to content

Commit d2cc821

Browse files
Add mcp blueprint (#1999)
1 parent c11a278 commit d2cc821

File tree

2 files changed

+70
-1
lines changed

2 files changed

+70
-1
lines changed

blueprints/index.html.erb

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,16 @@ nav: firecracker
1818
<% default_date = Date.new(1970, 1, 1) %>
1919

2020
<%# Select published pages, sort by date descending (handling missing dates), then loop %>
21-
<% current_page.children.select { |p| p.data['published'] != false }.sort_by { |p| p.data['date'] || default_date }.reverse.each do |page| %>
21+
<% current_page.children.select { |p| p.data['published'] != false }.sort_by { |p|
22+
date_value = p.data['date']
23+
if date_value.nil?
24+
default_date
25+
elsif date_value.is_a?(String)
26+
Date.parse(date_value) rescue default_date
27+
else
28+
date_value
29+
end
30+
}.reverse.each do |page| %>
2231
<li>
2332
<%= link_to_page page %>
2433
</li>
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
---
2+
title: Deploying Remote MCP Servers
3+
layout: docs
4+
nav: firecracker
5+
date: 2025-04-11
6+
---
7+
The Model Context Protocol (MCP) is a fun new way to give LLMs new powers. Originally developed by Anthropic, the protocol has since been adopted by OpenAI (with Google Gemini support in the works at the time of writing).
8+
9+
The protocol defines a standardized way of connecting tools and providing additional context to LLMs, not dissimilar to the way USB provides a standardized way to connect computers to peripherals and devices. Fly Machines are tightly isolated VMs that are perfect for running MCP servers.
10+
11+
This blueprint will help you understand, at a very high level, how to build, deploy, and connect remote MCP servers on Fly.io. Keep in mind that this is an nascent, still-emerging protocol – details are subject to change. For specific implementation details, the [Model Context Protocol](https://modelcontextprotocol.io/) site is the authoritative source of truth (complete with [a handy .txt version for LLM prompting](https://modelcontextprotocol.io/llms-full.txt)).
12+
13+
## Remote MCP Servers
14+
15+
MCP to date has been largely local-only, but the protocol also [specs out transports](https://modelcontextprotocol.io/specification/2025-03-26/basic/transports) for remote MCP servers. Remote MCP servers solve a bunch of problems:
16+
17+
- Easier to update a centralized server instead of dispersed, local packages
18+
- You can give MCP clients persistent connections that don't evaporate when someone closes their laptop
19+
- Securely sandbox MCP server activity in case the robots go rogue
20+
21+
## Single Tenant or Multi-tenant
22+
23+
There are broadly two patterns you might want to follow when deploying a remote MCP server to Fly.io:
24+
25+
1. Single, multi-tenant MCP server
26+
1. Single-tenant, per-user MCP servers
27+
28+
We're partial to the single-tenant pattern – it ensures proper isolation, and also helps with minimize your Fly.io bill: unused Machines can stop and start as needed, so you won't waste resources on idle users. `fly-replay` makes it easy to route requests to the correct app / Fly Machine (see more detail about this pattern in [Per-user Dev Environments with Fly Machines](https://fly.io/docs/blueprints/per-user-dev-environments/)).
29+
30+
## Multi-tenant MCP Servers
31+
32+
<img src="/static/images/docs-mcp-multi-tenant.webp" alt="Diagram showing multi-tenant MCP server architecture on Fly.io">
33+
34+
You'll need two main components:
35+
36+
1. **MCP-Remote Shim (optional)**: Tiny client-side proxy that connects local MCP clients to your remote servers (only needed if the MCP client doesn't support auth and / or streamable HTTP requests to a remote MCP server). Handles authentication via a secret shared between the shim and the router app (authentication could be a simple API token or a full OAuth dance). Securely stores and refreshes tokens as needed.
37+
1. **MCP Server App**: This runs the actual MCP goodness and authenticates requests from the MCP client. Should have a single streamable HTTP endpoint path for MCP client connections, as well as any specific business logic or other integrations.
38+
39+
## Single-tenant MCP Servers
40+
41+
<img src="/static/images/docs-mcp-single-tenant.webp" alt="Diagram showing single-tenant MCP server architecture on Fly.io">
42+
43+
There are three main components:
44+
45+
1. **Router App**: Handles auth, and routes requests to per-user apps + Fly Machines with `fly-replay` magic. Optionally handles user management and permissions.
46+
1. **MCP Server Apps**: Per-user (or per-team) apps that run your actual MCP goodness. Should have a single streamable HTTP endpoint path for MCP client connections, as well as any specific business logic or other integrations.
47+
- **MCP-Remote Shim (optional)**: Tiny client-side proxy that connects local MCP clients to your remote servers (only needed if the MCP client doesn't support auth and / or streamable HTTP requests to a remote MCP server). Handles authentication via a secret shared between the shim and the router app (authentication could be a simple API token or a full OAuth dance). Securely stores and refreshes tokens as needed.
48+
49+
## How Users Experience It
50+
51+
From your users' perspective, the experience should be delightfully simple:
52+
53+
1. They add a new MCP server to their MCP client with a simple one-liner
54+
1. The user is walked through an authentication flow (ie a browser window pops open to kick off the OAuth dance or provide an API key)
55+
1. After logging in, the MCP client can now access all the tools you've exposed
56+
1. The connection persists across restarts without re-authentication
57+
58+
## Taking It Further
59+
60+
If you'd like your MCP servers to connect to third party OAuth APIs without having to directly handle API tokens, consider using [ssokenizer](https://github.com/superfly/ssokenizer) (or [tokenizer](https://github.com/superfly/tokenizer) for generic, non-OAuth flows).

0 commit comments

Comments
 (0)