> ## Documentation Index
> Fetch the complete documentation index at: https://docs.springwinter.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Deploy AI backends, MCP servers and workers

> Separate HTTP APIs from background workers, protect model credentials, and design durable state and retries for AI applications running in customer-owned AWS.

An AI backend can run as a SpringWinter web server when it exposes supported HTTP traffic, or as a worker when it consumes background jobs without a public endpoint. Calling an external model API does not require a GPU. Durable agent memory and work queues must live outside temporary task filesystems.

## Select the workload type

| Requirement | Starting point | Checks before deployment |
| - | - | - |
| HTTP API or private gateway application exposed over HTTPS | Web server | Authentication, request limits, health path, public exposure and provider timeouts. |
| Remote MCP endpoint | Web server, with configuration | Actual HTTP transport, authentication, endpoint path and client compatibility. |
| Queue consumer or persistent agent loop | Worker | Graceful shutdown, bounded retries, idempotency and durable state. |
| Local stdio MCP server | Not a public HTTP endpoint unchanged | Keep local, or implement and review a supported remote transport. |
| Cron-like scheduling | Separate design required | No first-class scheduler or cron deployment contract is promised. |
| Self-hosted GPU inference | Separate model-endpoint capability | Check availability and validation; general web/worker Fargate compute has no GPU. |

See the canonical [compatibility reference](https://docs.springwinter.dev/reference/compatibility.md). Model endpoints and Bedrock are separate features from ordinary containers. Do not infer operational availability from an exposed API or general AWS GPU support.

## Architecture and prerequisites

```mermaid theme={null}
flowchart LR
    Operator[Developer or agent] --> Control[SpringWinter control plane]
    Control -->|Approved provisioning| AWS
    Client[Authenticated client] --> Web
    subgraph AWS[Customer-owned AWS account]
        Web[HTTP or remote MCP web server]
        Queue[Private Valkey]
        Worker[Background worker]
        State[Private SQL database]
        Objects[Private S3 objects]
        Web --> Queue
        Queue --> Worker
        Worker --> State
        Worker --> Objects
    end
    Web --> Models[External model API]
    Worker --> Models
```

This is one possible design. The example worker below uses Valkey only and does not call a model. You need a reviewed repository, lockfiles, Dockerfile, AWS connection and GitHub authorization. Add a model-provider account only if the application needs one. Provider token usage has separate costs and rate limits.

A remote MCP server needs its own authentication and authorization. HTTPS alone is insufficient. Do not expose an unauthenticated server that can read source, run shell commands or access account data. Follow the MCP implementation's current official deployment and security guidance for the chosen transport.

## Reproduce the reviewed worker example

```bash theme={null}
git clone --branch v0.1.0 --depth 1 \
  https://github.com/SpringWinter-Research/templates.git springwinter-templates
cd springwinter-templates/worker-valkey
uv sync --frozen
uv run python -m unittest
docker build -t springwinter-valkey-worker .
```

The unit tests use a fake cache. They do not require or open an existing service. The container build requires Docker. See the [tagged worker README](https://github.com/SpringWinter-Research/templates/blob/v0.1.0/worker-valkey/README.md) for locked dependencies and source.

The sample consumes a stream and uppercases its `text` field. It records a deterministic result before acknowledgment. It uses database 0, TLS and a cluster-aware client. A standalone Redis process is not a substitute for the required cluster behavior. Verify `XAUTOCLAIM` support on the selected service.

## Deploy and verify

Create or explicitly reuse a compatible private Valkey cache. In the dashboard, deploy a GitHub worker with the correct Dockerfile and context. Configure runtime `REDIS_URL` securely. Do not give a worker a web port, health path or public URL.

For an HTTP AI API, choose a web server instead, bind to `0.0.0.0`, and supply an unauthenticated health endpoint that returns HTTP 200 without exposing secrets. Store model keys as runtime secrets, never browser build variables.

A [coding agent](https://docs.springwinter.dev/guides/coding-agents.md) can prepare either plan. REST clients must use the separate [Workers API](https://docs.springwinter.dev/api-reference/workers.md), [Web servers API](https://docs.springwinter.dev/api-reference/web-servers.md) and [Caches API](https://docs.springwinter.dev/api-reference/caches.md). Read their current source requirements and response envelopes.

Observe the exact deployment workflow. With authorization and synthetic input, enqueue one harmless job and verify its result and acknowledgment. For a remote MCP server, test a harmless authenticated tool call from the intended client. Do not infer successful MCP operation from an HTTP health response.

## Delivery, retention and shutdown limits

The worker sample is at-least-once delivery, not exactly once. Results expire after one day; stream entries do not expire automatically. Select a trim/archive policy. Work that can outlast the sample's 60-second claim interval needs ownership renewal before multiple consumers are safe. Add bounded retries and dead-letter handling before using business jobs.

Handle SIGTERM and store resumable state externally. A long-running worker can be restarted or replaced; it is not a guarantee that one process runs forever. Avoid repeating paid model calls after an uncertain failure unless you can reconcile the result or use a provider-supported idempotency mechanism.

## Cost, security and cleanup

Use [cost estimation](https://docs.springwinter.dev/guides/cost-estimation.md) for worker compute, Valkey, logs, storage and transfer. Add model token charges and bounded per-job budgets. Provider rate limits and maximum concurrency are not billing caps.

Keep prompts, model keys and customer payloads out of diagnostics. Use synthetic data for verification. Restrict any downstream tool permissions to the intended task. Stop unsupported privileged-container or GPU requirements rather than silently substituting resources.

For cleanup, stop producers before deleting consumers and queues. Decide whether pending jobs, state and objects must be retained. Revoke temporary provider keys separately. See [deployment troubleshooting](https://docs.springwinter.dev/troubleshooting/deployments.md).

## Questions

**Does persistent agent mean persistent local disk?** No. It means the application preserves its required state in supported durable services and resumes safely after replacement.

**Can I run a scheduled script?** A worker can run application code, but this guide does not claim a managed schedule resource. Design timing, overlap prevention and failure behavior separately.

Related: [full-stack architecture](https://docs.springwinter.dev/guides/full-stack-apps.md), [customer-owned AWS](https://docs.springwinter.dev/guides/customer-owned-aws.md), [environment variables](https://docs.springwinter.dev/concepts/environment-variables.md).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.