MCPay Build
MCPay Build
MCPay Build is an MCP server that acts as a no-code builder for MCP Servers with built-in monetization.
It lets developers design, preview, and deploy MCP servers to GitHub + Vercel β and instantly monetize tool usage with x402 micropayments via MCPay.
π Build β Preview β Deploy β Monetize
Our vision is an agent-to-agent economy powered by microtransactions, where AI agents can autonomously pay to use tools. MCPay Build provides the rails to make that future possible.
πΌοΈ Workflow
βββββββββββββ βββββββββββββ βββββββββββββ βββββββββββββββββ
β Build β ββββΆ β Preview β ββββΆ β Deploy β ββββΆ β Monetize β
β (AI/MCP) β β (sandbox) β β (Vercel) β β (MCPay/x402) β
βββββββββββββ βββββββββββββ βββββββββββββ βββββββββββββββββ
Big Picture
This repo implements an MCP server βfactoryβ:
Lets an AI/chat (or you) spin up a brand-new MCP server in memory.
Provides tools to edit files, manage deps, run type checks, format, version, and preview live.
Deploys your server into a real Node.js environment using Vercel Sandbox.
Monetizes expensive operations (
preview,run_command,stream_logs, etc.) using MCPay (per-call x402 micropayments).
Flow:
Create session β edit files β preview in sandbox β get live URL β iterate β export as ZIP β monetize tools.
β¨ Features
MCPay integration β free + paid tools side-by-side, billed automatically
Simple API β
server.tool(...)&server.paidTool(...)viamcpay/handlerVercel-ready β
vercel.json+ function exports (GET/POST/OPTIONS)Type-safe β modern TypeScript + Zod validation
Dev UX β session/file/diff/format tools,
ts-check, logs, live preview
π Quickstart
1. Install dependencies
pnpm install2. Configure environment
MCPAY_API_KEY=your_api_key # required for paid tools
MCPAY_API_URL=https://api.mcpay.tech # optional3. Run locally
pnpm dlx vercel devServer runs at http://localhost:3000.
4. Connect from MCP client
Add to ~/.cursor/mcp.json:
{
"mcpServers": {
"mcpay-local": { "url": "http://localhost:3000" }
}
}Under the Hood
Main runtime & routing
Hono as the HTTP framework.
Open CORS (all origins/headers/methods allowed).
GET /β serves a system prompt describing tools + philosophy.All other routes β handled by
createPaidMcpHandler(...).Function exports (
GET/POST/OPTIONS) β deploys cleanly to Vercel.
State & storage
Sessions in Vercel KV (
session:{id}) with virtual file system + sandbox metadata.Commits in KV (
commit:{session}:{commit}) for full snapshots.Logs/ZIPs uploaded to Vercel Blob with public URLs.
Templates & defaults
When you run create_session, it seeds:
index.tsβ MCP server template (withhello+get-timetools).package.json,tsconfig.json,.gitignore,.env.example,README.md.
Preview = live sandbox
preview tool does:
Loads session + hashes files.
Reuses existing sandbox if files unchanged (<30 min).
Else:
Creates fresh Vercel Sandbox (Node 22, 2 vCPUs).
Uploads files.
Detects Node/npm versions.
Installs deps (npm/yarn/pnpm).
Runs build if available.
Starts server (
npm startor fallback).Health-checks endpoints until ready.
Aggregates logs (uploads long logs to Blob).
Returns: sandbox ID, preview URL, logs, node/npm versions, status.
Built-in Tools
Paid (metered via MCPay)
create_sessionβ bootstrap projectpreviewβ deploy to sandbox, return live URLdownload_sessionβ zip + upload projectrun_commandβ exec arbitrary shell in sandboxstream_logsβ live-tail logs
Free
File ops:
add_or_update_file,delete_file,get_file,list_files,get_all_codebaseEnv ops:
add_env_key,list_env_keys,delete_env_keyPackage ops:
add_dependency,debug_package_jsonQuality:
ts_check,npm_audit,format_fileVersioning:
commit,diff,revert,get_logsInfo:
get_environment_info,get_session_stats,stop_preview,force_refresh_sandbox
Monetization
MCP handler is created with
createPaidMcpHandler.Paid tools have explicit
{ price, currency }.Requires
MCPAY_API_KEY(and optionalMCPAY_API_URL).
Example:
server.paidTool(
"analyze-data",
"Analyze data (paid)",
{ price: 0.1, currency: "USD" },
{ data: z.string(), format: z.enum(["json","csv"]) },
async ({ data, format }) => ({
content: [{ type: "text", text: `Analyzed ${format} data` }]
})
);π Typical Flow
create_sessionβ new IDadd_or_update_fileβ editindex.tsts_check+format_filecommitβ snapshotpreviewβ live sandbox URLstream_logsβ monitor in real timedownload_sessionβ zip/export
π¦ Deployment
Deploy to Vercel:
pnpm dlx vercelSet env vars in project settings:
MCPAY_API_KEYMCPAY_API_URL(optional)
β Notes
Blob uploads are public β donβt commit secrets.
Sandbox per tool (for some ops) β isolation at cost of speed/$$.
.env handling β only keys are tracked; actual secrets must be set in runtime env.
π License
MIT