SaaS Template MCP
Relevant source files
The following files were used as context for generating this wiki page:
The SaaS Template MCP is a reusable system designed to transform any Model Context Protocol (MCP) server into a production-ready, paid SaaS product. It provides a standardized stack for handling MCP transports (SSE and stdio), integrated billing via Stripe, usage tracking, and a ready-to-use landing page. This template is part of the eng-platform custom MCP server suite, serving as a foundation for building commercial AI capabilities.
The system facilitates rapid deployment by offering pre-configured workflows for various platforms like Railway and Fly.io. It includes a scaffolding engine that generates customized project layouts based on developer requirements, including pricing tiers, feature lists, and tool definitions.
System Architecture
The architecture of the SaaS Template MCP is designed to bridge the gap between a local MCP tool and a cloud-hosted commercial service. It utilizes a middleware-heavy approach to handle authentication and billing without complicating the core tool logic.
The diagram shows how various clients interact with the server core through transport layers, filtered by auth and billing middleware before reaching the functional tools.
Sources: mcp-servers/mcp-saas-template/README.md, mcp-servers/mcp-saas-template/template/README.md
Key Components
| Component | Description | File Reference |
|---|---|---|
server.py | Core MCP protocol server implementation with billing middleware. | mcp-servers/mcp-saas-template/README.md |
billing.py | Manages API keys, Stripe metered usage, and usage accounting. | mcp-servers/mcp-saas-template/README.md |
create_mcp_saas.py | CLI tool to scaffold new projects from the template. | mcp-servers/mcp-saas-template/create_mcp_saas.py |
site/index.html | A landing page and consumer web panel for non-MCP users. | mcp-servers/mcp-saas-template/template/site/index.html |
deploy.sh | One-command operations workflow for setup, benchmarking, and deployment. | mcp-servers/mcp-saas-template/template/README.md |
Project Scaffolding
The create_mcp_saas.py script automates the creation of a new MCP SaaS product. It performs token replacement across the template directory to inject project-specific metadata, pricing, and server configurations.
Scaffolding Logic Flow
The flow represents the automated generation process where user input is transformed into a deployable project structure.
Sources: mcp-servers/mcp-saas-template/create_mcp_saas.py:112-146
Configuration Options
The generator supports various flags to customize the output project:
- Identification:
--name,--description,--slug,--author-name. - Networking:
--port,--api-base-url. - Billing:
--pricing-free-calls,--pricing-pro-price,--pricing-pro-calls. - Content:
--features-file,--tools-file(JSON overrides for the landing page).
Sources: mcp-servers/mcp-saas-template/create_mcp_saas.py:164-181
Billing and Usage Tracking
The template features a standalone billing.py module designed for easy integration. It uses JSON files for default persistence (suitable for rapid launch) but is architected to be swappable for Redis or PostgreSQL.
Billing Endpoints
The system exposes several REST endpoints for managing the SaaS lifecycle:
| Endpoint | Method | Purpose |
|---|---|---|
/billing/keys | POST | Creates a new API key. |
/billing/usage | GET | Returns a user's usage summary. |
/billing/activity | GET | Shows recent per-user tool calls. |
/billing/metrics | GET | Admin-only view for revenue and total usage. |
/billing/checkout | POST | Initiates a Stripe checkout session. |
/billing/webhook | POST | Handles Stripe events (payment success, etc). |
Sources: mcp-servers/mcp-saas-template/README.md, mcp-servers/mcp-saas-template/template/README.md
Usage Flow
The sequence diagram illustrates how tool execution is decoupled from usage reporting to ensure performance while maintaining billing accuracy.
Sources: mcp-servers/mcp-saas-template/README.md, mcp-servers/mcp-saas-template/template/README.md
Consumer Web Panel
The template includes a site/index.html file that serves two purposes: a landing page and a "Consumer Panel." This panel allows users to execute MCP tools directly via standard HTTP calls without needing a specialized MCP client like Claude Desktop.
Consumer Integration logic
The web panel interacts with a specific /consumer/run endpoint on the backend. It allows users to:
- Select a tool from the auto-populated list (derived from
TOOLS_JSON). - Input arguments as JSON.
- Execute the tool and view output in a formatted code block.
Sources: mcp-servers/mcp-saas-template/template/site/index.html:362-421
Deployment and Benchmarking
The system includes a deploy.sh script to manage the operational lifecycle of the generated MCP server.
- Setup:
./deploy.sh setupconfigures the environment and dependencies. - Start:
./deploy.sh startlaunches the server via Docker Compose. - Benchmark:
./deploy.sh benchmarkgenerates competitive pricing analysis, creating reports in thereports/directory and updating the landing page's comparison table (public-comparison.json). - Cloud Support: Specific workflows are provided for Railway and Fly.io.
Sources: mcp-servers/mcp-saas-template/README.md, mcp-servers/mcp-saas-template/template/README.md
Conclusion
The SaaS Template MCP is a comprehensive framework for commercializing AI tools. By standardizing the "boring" parts of SaaS development—billing, auth, landing pages, and deployment—it allows developers to focus entirely on the domain-specific logic of their MCP tools. Its modular design ensures that as a project scales, the underlying storage and auth layers can be upgraded without a total rewrite of the tool implementations.