FastMCP Multi-Tenancy
A serverless, multi-tenant implementation of MCP servers designed to run on Vercel with fluid compute mode enabled.
Overview
This library extends the FastMCP server implementation to support:
- Serverless execution on Vercel with fluid compute mode
- Multi-tenancy where multiple users can connect to the same endpoint
- State persistence using Redis for session management
- API compatibility with the standard FastMCP implementation
Requirements
- Python 3.9+
- Redis instance (for session state persistence)
- Vercel account (for deployment)
Installation
Quick Start
Create a new Vercel serverless function:
Deployment to Vercel
- Set up your Vercel project
- Enable fluid compute mode in your Vercel project settings
- Add the Redis URL as an environment variable (
REDIS_URL
) - Deploy your project
Architecture
The FastMCP multi-tenancy implementation uses:
- Redis storage for session state persistence
- Vercel-compatible SSE for server-sent events that work in serverless environments
- FastAPI for handling HTTP requests
The key components are:
FastMCPMultiTenant
- The main server classVercelSseServerTransport
- SSE implementation for VercelRedisSessionStorage
- Redis-backed storage for sessionsMultiTenantServerSession
- Session implementation with Redis persistence
API Compatibility
This implementation maintains API compatibility with the standard FastMCP server:
The same tool, resource, and prompt decorators work with both implementations.
Redis Configuration
The Redis instance is used to store:
- Session state
- Message queues
- Client capabilities
You can use any Redis provider (Redis Cloud, Upstash, etc.) as long as it provides a standard Redis URL.
Local Development
For local development, run:
Limitations
- Long-running operations should be designed to be resumable, as serverless functions have execution time limits
- The fluid compute mode on Vercel helps with maintaining connections but has its own limitations
- Redis storage adds some latency compared to in-memory storage
License
Same as the MCP Python SDK.
This server cannot be installed
A serverless, multi-tenant implementation of MCP servers that runs on Vercel with fluid compute mode, allowing multiple users to connect to the same endpoint while maintaining session state through Redis.