Files
freshservice-claude/plugin/make-plugin.sh

56 lines
1.8 KiB
Bash
Raw Normal View History

#!/usr/bin/env bash
# Build a personalized freshservice.plugin for Claude Desktop / Cowork.
#
# Each person runs this ONCE with their own Freshservice API key. The output
# .plugin file contains your key — do not share it.
#
# Usage (interactive):
# ./make-plugin.sh
# Or non-interactive:
# FS_KEY=... MCP_TOKEN=... ./make-plugin.sh
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
TEMPLATE="$SCRIPT_DIR/template"
SERVER_URL="${SERVER_URL:-http://192.168.101.12:3839/mcp}"
FS_DOMAIN="${FS_DOMAIN:-pesco.freshservice.com}"
if [ -z "${FS_KEY:-}" ]; then
printf "Your Freshservice API key (Freshservice → profile picture → Profile settings → API key): "
read -r FS_KEY
fi
if [ -z "${MCP_TOKEN:-}" ]; then
printf "Shared MCP server token (ask IT / Spencer): "
read -r MCP_TOKEN
fi
[ -n "$FS_KEY" ] || { echo "ERROR: API key is required." >&2; exit 1; }
[ -n "$MCP_TOKEN" ] || { echo "ERROR: MCP token is required." >&2; exit 1; }
BUILD="$(mktemp -d)"
trap 'rm -rf "$BUILD"' EXIT
cp -R "$TEMPLATE/." "$BUILD/"
# Stamp placeholders using bash substitution (safe for special characters).
for f in "$BUILD/.mcp.json"; do
content="$(cat "$f")"
content="${content//__SERVER_URL__/$SERVER_URL}"
content="${content//__FS_DOMAIN__/$FS_DOMAIN}"
content="${content//__FS_KEY__/$FS_KEY}"
content="${content//__MCP_TOKEN__/$MCP_TOKEN}"
printf '%s' "$content" > "$f"
done
# Sanity check: no placeholders left anywhere.
if grep -rq "__[A-Z_]*__" "$BUILD"; then
echo "ERROR: unfilled placeholders remain; aborting." >&2
exit 1
fi
OUT="$SCRIPT_DIR/freshservice.plugin"
rm -f "$OUT"
(cd "$BUILD" && zip -r -q "$OUT" . -x "*.DS_Store")
echo "Built: $OUT"
echo "Install it in Claude Desktop (Cowork → Customize → add plugin), then start a new chat."
echo "REMINDER: this file contains your personal API key — don't share it."