# Template servers

A server manifest documents Dryv runtime endpoints. It is infrastructure wiring, not project generation configuration.

Use it for local development, private plugin renderers and hosted API/template-server deployments. Keep server URLs and launch commands out of `dryv.yaml` and `dryv.pack.yaml`.

The source-checkout API default registry is `source/engine/python/api/dryv.server.yaml`.

## Shape

A server manifest describes one or more runtime endpoints:

```yaml
apiVersion: dryv.server/v1alpha1
servers:
  - kind: TEMPLATE_SERVER
    name: jinja
    url: http://127.0.0.1:8765
    command:
      - dryv-jinja
      - serve
  - kind: DRYV_API_SERVER
    name: local
    url: http://127.0.0.1:8750
```

`TEMPLATE_SERVER.name` is the renderer name packs require. The API connects to `url` and reads the server's live discovery response before rendering when that manifest is supplied to the API process as runtime configuration. If the URL is unavailable and `command` is present, the local API may launch the command from the manifest directory and retry discovery.

The API template renderer uses only `TEMPLATE_SERVER` entries. `command` is valid only for `TEMPLATE_SERVER`; API endpoints remain observational connection targets. `DRYV_API_SERVER` entries are for clients and tools that need to discover an API endpoint.

## Packs and Custom Renderers

Packs continue to declare renderer needs by name/capability in `dryv.pack.yaml`:

```yaml
requires:
  - name: my-renderer
```

An advanced pack may include a server manifest beside the pack as optional runtime metadata, but it is not activated automatically. The project, CLI or API process must opt into that manifest explicitly.

This keeps rare custom plugin wiring possible without letting a pack silently make the engine call arbitrary URLs.

## Local and Remote Rules

Local template plugins work when the Dryv API process can reach their `url` or launch their `command`.

Remote APIs can only use URLs reachable from the remote API environment. A local `command` in a manifest sent to a remote API is not useful unless that remote API process has the same command and working directory available.

The client-facing API discovery endpoint exposes live server identity, URLs and capabilities. It does not expose manifest paths or launch commands.

## CLI resolution and doctor

Project commands resolve the API in this order:

```text
explicit --api
    ↓
project dryv.server.yaml
    ↓
normal default
```

The resolution source is preserved as `explicit`, `manifest` or `default` and is visible in CLI discovery/doctor machine evidence.

Ordinary generation uses the Template Servers already connected to the resolved API. A project `dryv.server.yaml` does not mutate a running API's renderer registry per request.

`dryv server validate` checks manifest wiring without network access. `dryv server doctor` checks the resolved API plus every configured Template Server. With explicit `--launch`, an unreachable Template Server may be started from its manifest-declared command after the workspace trust boundary is satisfied. The CLI never launches a `DRYV_API_SERVER` from the manifest.
