page:recipes:mcp server:starlette:response streaming

Host MCP server with Starlette: Streamed Responses

Summary

Deploy an MCP server built with Starlette on Ample using the streaming response service pattern. Compute runs the app in an isolated microVM behind a public HTTPS URL, and a managed PostgreSQL 16 database is auto-provisioned and injected as DATABASE_URL. It has been verified on Starlette with the following characteristics of a Server-Sent Events endpoint:

Note: Your event schema, reconnection strategy, and any per-request duration ceiling beyond the 70 seconds measured were not separately tested; treat the MCP server-specific behavior as part of your application code.

Representative Queries

Resource Requirements

Infrastructure Requirements

  1. Compute

    • Status: Verified
    • Summary: Apps run in isolated x86_64 Firecracker microVMs that auto-pause when idle and wake on request; sizes are the priced VM sizes.
  2. Postgres

    • Status: Verified
    • Summary: Managed PostgreSQL 16 runs in its own microVM and is auto-provisioned when an app needs a database, with no DATABASE_URL supplied.

Prerequisites

Tested Configuration

Workflow Steps

  1. Build and start

    • Command: pip install into .ample/python from requirements.txt, then uvicorn from run.py reading PORT on the python-3.12 template. The server must bind 0.0.0.0 on PORT.
  2. Implement the pattern on PostgreSQL

    • Body: Copy the approach into your schema; keep migrations idempotent and run them with --release-command.
  3. Deploy

    • Command: ample deploy . --name --public --start "python3 run.py"
  4. Verify

    • Command: ample logs --kind build

Example

Success Checks

  1. App responds on its public URL

    • Kind: http_get
    • Path: /
    • Expect: ample canary starlette patterns
  2. Streaming-response-service self-test

    • Kind: http_get
    • Path: /p/streaming-response-service
    • Expect: an SSE stream: data: id=, then chunk events one interval apart (read incrementally: first chunk within seconds, chunks spread over the interval), then data: done; /status?id= reports sent=N disconnected=true|false done=true|false

Limitations

Cost Estimate

Evidence Summary

  1. Kind: canary_run
    • Summary: Starlette pattern fixture deployed on Ample; checks passed for streaming-response-service and configuration-secrets.
    • Observed At: 2026-09-21T01:21:36Z
  2. Limitations: Unknowns; compliance attestations are unknown; none are claimed.