#!/bin/sh # Convert env vars to discourse-mcp CLI arguments, then exec the server. # # Env vars: # DISCOURSE_URL - base URL of the Discourse site # DISCOURSE_API_KEY - API key # DISCOURSE_API_USERNAME - username for the API key # # When DISCOURSE_URL is set, the server is tethered to that site with auth # pre-configured. Otherwise, the client must call discourse_select_site. set -e ARGS="" if [ -n "${DISCOURSE_URL}" ]; then ARGS="${ARGS} --site ${DISCOURSE_URL}" if [ -n "${DISCOURSE_API_KEY}" ]; then AUTH_PAIR="{\"site\":\"${DISCOURSE_URL}\"" AUTH_PAIR="${AUTH_PAIR},\"api_key\":\"${DISCOURSE_API_KEY}\"" if [ -n "${DISCOURSE_API_USERNAME}" ]; then AUTH_PAIR="${AUTH_PAIR},\"api_username\":\"${DISCOURSE_API_USERNAME}\"" fi AUTH_PAIR="${AUTH_PAIR}}" ARGS="${ARGS} --auth-pairs '[${AUTH_PAIR}]'" fi fi ARGS="${ARGS} --allow-writes --read-only false" exec eval node dist/index.js ${ARGS} "$@"