Files
kit/examples/scripts/env-substitution-script.sh
T
Ed Zynda 7244485ce2 fix: script mode streaming display and example script formatting
- Accumulate stream chunks in a buffer and flush through
  DisplayAssistantMessageWithModel at boundaries (tool calls, step
  complete), mirroring the TUI's StreamComponent accumulate-and-flush
  strategy. Text accompanying tool calls now renders identically to
  solo assistant responses.

- Fix example-script.sh: add missing --- frontmatter delimiters and
  convert legacy command/args format to new type+command list format
  so Viper YAML parsing works correctly.

- Fix env-substitution-script.sh: add missing execute permission.
2026-02-26 15:30:39 +03:00

42 lines
1.3 KiB
Bash
Executable File

#!/usr/bin/env -S mcphost script
---
# Example script demonstrating both environment variable and script argument substitution
# Environment variables are processed first, then script arguments
mcpServers:
github:
type: local
command: ["gh", "api"]
environment:
GITHUB_TOKEN: "${env://GITHUB_TOKEN}"
DEBUG: "${env://DEBUG:-false}"
filesystem:
type: builtin
name: fs
options:
allowed_directories: ["${env://WORK_DIR:-/tmp}"]
model: "${env://MODEL:-anthropic/claude-sonnet-4-5-20250929}"
debug: ${env://DEBUG:-false}
---
List ${repo_type:-public} repositories for user ${username}.
Use the GitHub API to fetch ${count:-10} repositories.
Working directory is ${env://WORK_DIR:-/tmp}.
# Usage:
# 1. Set environment variables:
# export GITHUB_TOKEN="ghp_your_token_here"
# export DEBUG="true"
# export WORK_DIR="/home/user/projects"
#
# 2. Run with script arguments:
# mcphost script env-substitution-script.sh --args:username alice --args:repo_type private --args:count 5
#
# This will:
# - Use GITHUB_TOKEN from environment
# - Set DEBUG=true from environment
# - Use WORK_DIR=/home/user/projects from environment
# - Use username=alice from script args
# - Use repo_type=private from script args
# - Use count=5 from script args