Files
KNEL-AIMiddleware/mcp-discourse-wrapper.sh
T
mrcharles 1957dcbc7e feat(creds): centralize credentials to ~/.creds/, add KNELCredsManager
Rewire all MCP wrappers, docker-compose services, and validate scripts
to source credentials from ~/.creds/ instead of scattered per-service
.env files. This removes credential duplication and prepares for the
HashiCorp Vault migration.

Add KNELCredsManager under tooling-cli with:
- Containerized Bitwarden CLI (pinned image, host stays clean)
- scripts/bw wrapper with session management and data persistence
- README documenting credential layout, consumer wiring, and roadmap

Also fixes latent bug in MCP wrappers that were silently getting empty
creds from ambient shell env — they now explicitly source ~/.creds/.

Tracked in Redmine #407. Discourse: https://community.turnsys.com/t/308

💘 Generated with Crush

Assisted-by: Crush
2026-08-10 09:14:14 -05:00

31 lines
1.1 KiB
Bash
Executable File

#!/bin/sh
# Wrapper script for discourse-mcp
# Ensures clean container with proper name
CONTAINER_NAME="kneldevstack-aimiddleware-discourse-mcp-crush"
IMAGE_NAME="kneldevstack-aimiddleware-discourse-mcp"
# Force remove existing container if it exists (in any state)
if docker ps -a --filter "name=${CONTAINER_NAME}" --format '{{.Names}}' 2>/dev/null | grep -q "^${CONTAINER_NAME}$"; then
docker rm -f "${CONTAINER_NAME}" >/dev/null 2>&1
# Wait for container to be fully removed
while docker ps -a --filter "name=${CONTAINER_NAME}" --format '{{.Names}}' 2>/dev/null | grep -q "^${CONTAINER_NAME}$"; do
sleep 0.05
done
fi
# Load credentials from central store
CREDS_FILE="/home/reachableceo/.creds/discourse.env"
if [ -f "$CREDS_FILE" ]; then
set -a
. "$CREDS_FILE"
set +a
fi
# Start MCP server with explicit name and environment variables
exec docker run -i --rm --name "${CONTAINER_NAME}" \
-e "DISCOURSE_URL=${DISCOURSE_URL:-}" \
-e "DISCOURSE_API_KEY=${DISCOURSE_API_KEY:-}" \
-e "DISCOURSE_API_USERNAME=${DISCOURSE_API_USERNAME:-}" \
"${IMAGE_NAME}" "$@"