Documentation

Examples

Practical Seristack YAML examples for CLI automation, HTTP endpoints, MCP tools, variable validation, output aggregation, and production-friendly internal APIs.

1. Simple CLI stack

Run a basic stack from the command line.

stacks:
  - name: hello
    count: 1
    cmds:
      - echo "Hello from Seristack"
seristack trigger -c config.yaml -s hello

2. Expose a stack as an HTTP API

Set method and optionally urlPath to expose a stack through the HTTP server.

stacks:
  - name: greet-api
    method: GET
    urlPath: /greet
    count: 1
    vars:
      - name: name
        value: engineer
    cmds:
      - echo "Hello {{.Vars.name}}"
seristack run -c config.yaml --addr 127.0.0.1 --port 8080
curl 'http://127.0.0.1:8080/greet?name=alice'

3. Expose a stack as an MCP tool

Set description to make the stack available as an MCP tool.

stacks:
  - name: system-info
    description: Returns basic system information
    count: 1
    cmds:
      - uname -a
seristack mcp --type streamableHTTP --addr 127.0.0.1 --port 8080

4. Validate runtime input

Use variable rules to restrict values before commands run.

stacks:
  - name: deploy
    method: POST
    urlPath: /deploy
    count: 1
    vars:
      - name: env
        required: true
        allowed_value: [dev, stage, prod]
      - name: service
        required: true
        allowed_regex: regex("^[a-zA-Z0-9_-]+$")
    cmds:
      - echo "Deploying {{.Vars.service}} to {{.Vars.env}}"

5. Stack dependencies

Use dependsOn to run stacks in order.

stacks:
  - name: build
    count: 1
    cmds:
      - go build ./...

  - name: test
    dependsOn: [build]
    count: 1
    cmds:
      - go test ./...

6. Aggregate command output

Use {{.Self.result}} inside output to post-process command output.

stacks:
  - name: collect-metadata
    count: 2
    executionMode: SEQUENTIAL
    cmds:
      - echo "{\"index\": {{.Count.index}}, \"status\": \"ok\"}"
    output: |
      echo '{{.Self.result}}' | grep "^{" | jq -s '{records: ., total: length}'

7. Discard saved output

Use discardOutput to remove stack outputs from the in-memory registry after a stack completes.

stacks:
  - name: first-step
    count: 1
    cmds:
      - echo "temporary output"

  - name: cleanup
    dependsOn: [first-step]
    discardOutput: [first-step]
    count: 1
    cmds:
      - echo "first-step output discarded"

8. Command timeouts

Set a per-command timeout using Go duration syntax.

stacks:
  - name: quick-health-check
    count: 1
    timeouts: 30s
    cmds:
      - curl -f http://localhost:8080/health
Examples: 500ms, 30s, 5m, 1h, 1h30m, 2.5h.

9. Production-friendly local binding

Bind Seristack to localhost/private networking and put Nginx or Caddy in front for TLS, auth, rate limits, and request size limits.

seristack run --config config.yaml --addr 127.0.0.1 --port 8080
seristack mcp --type streamableHTTP --addr 127.0.0.1 --port 8080