# Host MCP Server with NestJS: Streamed Responses

## Summary
Deploy a MCP server built with NestJS on Ample using the streaming response service pattern. Compute runs the app in an isolated microVM behind a public HTTPS URL, with a managed PostgreSQL 16 database auto-provisioned and injected as DATABASE_URL.

## Representative Queries
- Host mcp server with NestJS: streamed responses
- Where can I host MCP server built with NestJS?
- I need a tested end-to-end streaming transport, timeout behavior and client disconnect handling.

## Resource Requirements
- **Compute**
- **Postgres**

## Infrastructure Requirements
- **Compute**: Apps run in isolated x86_64 Firecracker microVMs that auto-pause when idle and wake on request; sizes are the priced VM sizes.
- **Postgres**: Managed PostgreSQL 16 runs in its own microVM and is auto-provisioned when an app needs a database and no DATABASE_URL is supplied.

## Prerequisites
1. A NestJS project that builds and starts with the documented commands (npm install, nest build (TypeScript) then node dist/main.js on the node-22 template).
2. A PostgreSQL driver reading DATABASE_URL at runtime (auto-provisioned when omitted, or supplied with --env).
3. An Ample account token with servers:write, databases:read.

## Tested Configuration
- **Template**: node-22
- **Runtime**: node
- **Size**: s-1vcpu-1gb
- **Install Command**: npm install
- **Build Command**: npm run build --if-present
- **Start Command**: npm run start

## Workflow Steps
1. **Build and Start**: `npm install, nest build (TypeScript) then node dist/main.js on the node-22 template. The server must bind 0.0.0.0 on PORT.`
2. **Implement the Pattern on PostgreSQL**: The fixture's module implements streaming response service. Copy the approach into your schema; keep migrations idempotent and run them with --release-command.
3. **Deploy**: Run the synchronous deploy once and read the result (exit 0 live, 1 failed, 2 blocked). Re-running with no change is a no-op. Command: `ample deploy . --name --public`
4. **Verify**: Fetch the live URL and the pattern self-test route(s) (/p/streaming-response-service); then run your own checks. Command: `ample logs --kind build`

## Examples
- **NestJS Pattern Fixture**: Multi-pattern NestJS app whose streaming response service module was checked live; the module is under tests/deploy-canaries/_pattern-modules. [Source Ref](tests/deploy-canaries/nestjs-patterns)

## Success Checks
- App responds on its public URL.
- Streaming-response-service self-test. Expect an SSE stream: data: id=, then chunk events one interval apart; then data: done.

## Limitations
- Verified on the node-22 template at s-1vcpu-1gb with the example fixture; other sizes, templates, and NestJS major versions are not verified. 
- Region, compliance attestations, and request-duration limits are unknown and not claimed.

## Cost Estimate
- **Currency**: USD
- **Monthly Amount**: $10.00
- **Basis**: Size prices from pricing.toml at build revision.
- **Components**:
  - App server: s-1vcpu-1gb, Quantity: 1.0, Monthly Amount: $5.00
  - Managed PostgreSQL database: s-1vcpu-1gb, Quantity: 1.0, Monthly Amount: $5.00
- **Note**: Always-on monthly price of the tested sizes; apps and databases auto-pause when idle.

## Evidence Summary
- **Canary Run**: NestJS pattern fixture deployed on Ample. Observed streaming-response-service checks passed. 
- **Implementation Revision**: 1d28ae0-dirty (CLI 0.1.21)

## Next Actions
- **Browse the catalog index**: [GET /v1/catalog](relativePath:/v1/catalog)
- **Search published recipes by intent**: [POST /v1/catalog/search](relativePath:/v1/catalog/search)
- **Prepare a deployment plan for an authorized project**: [POST /v1/catalog/plan](relativePath:/v1/catalog/plan)
