如何在 256MB 容器中建置 11 個無需代理伺服器的遠端 MCP 伺服器:架構與免費設定生成器
Building 11 Zero-Proxy Remote MCP Servers in 256MB Containers (Architecture + Free Config Generator)
作者在過去一週建置並部署 11 個託管式 Streamable HTTP Remote MCP 伺服器,每個均運行於 256 MB Node.js 22 容器,且不使用無頭瀏覽器或代理伺服器。
Most tutorials for Model Context Protocol (MCP) servers assume two things:
- Users want to install Node/Python locally and babysit
stdioprocesses. - Web-data tools need heavyweight Playwright containers and residential proxies.
In practice, neither scales well for real AI agents in Claude Desktop, Cursor, Windsurf, or n8n.
Over the past week I built and deployed 11 hosted Streamable HTTP Remote MCP servers (/mcp), every single one running in a 256 MB Node.js 22 container with zero headless browsers and zero proxies.
Here are the architectural lessons that actually mattered in production—plus the open-source STDIO/HTTP bridge and a free 1-click JSON config generator.
1. Stateless Streamable HTTP (/mcp) Beats Long-Lived Sessions
For hosted remote MCP servers behind serverless/standby autoscalers, sticky in-memory sessions break on cold restarts. Using @modelcontextprotocol/sdk's StreamableHTTPServerTransport in stateless JSON-response mode (sessionIdGenerator: undefined, enableJsonResponse: true) creates a clean server + transport per request and tears it down cleanly on res.on('close').
Result: Zero memory leaks, sub-200ms warm tool execution, and 256 MB RAM ceiling.
2. Two-Stage Docker Builds Cut Image Size & Avoid NODE_ENV=production Traps
Base Node production images often run with NODE_ENV=production, causing npm install to silently skip TypeScript (tsc). Using a clean 2-stage Dockerfile (npm install --include=dev && npm run build in builder, copying only dist/ to the runtime stage with --omit=dev) keeps deployments fast and deterministic.
3. Real-World Public API Gotchas We Hit (So You Don't Have To)
-
Substack:
/api/v1/archivemigrated fromoffset=(now returns HTTP 400) tocursor=<nextCursor>. -
Kalshi v2: Live prices now live in dollar-denominated fields (
yes_bid_dollars,yes_ask_dollars) and querying/trade-api/v2/events?status=open&with_nested_markets=trueavoids noisy combo-parlay clutter. -
SEC EDGAR XBRL (
companyfacts): Always merge across multiple US-GAAP revenue tags (Revenues,RevenueFromContractWithCustomerExcludingAssessedTax,SalesRevenueNet) and filter duration length (300+ days for annual 10-K) so prior-year comparative rows never overwrite current fiscal years. -
Empty-Input QA Hardening: Always provide real
defaultvalues in schemas and runtime fallbacks when{}is passed so automated health checks never fail.
Try Them Live or Generate Your MCP Config in 1 Click
- Open-Source STDIO Bridge & All 11 Hosted Endpoints (MIT): https://github.com/shawn1905/zero-proxy-mcp-suite
- Free 1-Click Remote MCP Config Generator + 2026 MoR Fee Calculator: https://shawn1905.github.io/indie-builder-toolkit/
- Full Apify Store Portfolio (Substack, ESPN 16 Leagues, 5-Board Remote Jobs, Google News, Polymarket & Kalshi, Shopify, Podcasts, YC 6,400+ Startups, SEC EDGAR, Website Contacts & Tech Stack, Fast Website-to-Markdown): https://apify.com/shawn1905
If you are building automated workflows on top of these endpoints, I also bundled 5 ready-to-run self-hosted n8n workflows + Docker Compose here: https://fengyetnot.gumroad.com/l/skuqx
Curious what remote MCP data sources developers here still struggle to find without paying $200/mo in proxies—drop them below!
來源:DEV Community · dev.to