2026-02-21 14:00:24 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
set -e
|
|
|
|
|
|
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
|
|
|
|
PROJECT_ROOT="$(dirname "$SCRIPT_DIR")"
|
|
|
|
|
cd "$PROJECT_ROOT"
|
|
|
|
|
|
2026-02-21 14:04:07 +00:00
|
|
|
# Load .env if present
|
|
|
|
|
if [ -f .env ]; then
|
|
|
|
|
set -a; source .env; set +a
|
|
|
|
|
fi
|
2026-02-21 14:00:24 +00:00
|
|
|
|
feat: implement v2 3-tier architecture (mcpctl → mcplocal → mcpd)
- Rename local-proxy to mcplocal with HTTP server, LLM pipeline, mcpd discovery
- Add LLM pre-processing: token estimation, filter cache, metrics, Gemini CLI + DeepSeek providers
- Add mcpd auth (login/logout) and MCP proxy endpoints
- Update CLI: dual URLs (mcplocalUrl/mcpdUrl), auth commands, --direct flag
- Add tiered health monitoring, shell completions, e2e integration tests
- 57 test files, 597 tests passing
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-22 11:42:06 +00:00
|
|
|
# Ensure tools are on PATH
|
|
|
|
|
export PATH="$HOME/.npm-global/bin:$HOME/.bun/bin:$HOME/.local/bin:$PATH"
|
|
|
|
|
|
2026-03-13 23:01:51 +00:00
|
|
|
# Architecture detection / cross-compilation support
|
|
|
|
|
# MCPCTL_TARGET_ARCH overrides native detection (e.g. "amd64" or "arm64")
|
|
|
|
|
source "$SCRIPT_DIR/arch-helper.sh"
|
|
|
|
|
resolve_arch "${MCPCTL_TARGET_ARCH:-}"
|
|
|
|
|
# Sets: NFPM_ARCH, BUN_TARGET, ARCH_SUFFIX
|
|
|
|
|
|
2026-03-13 23:11:35 +00:00
|
|
|
# Check and install missing build dependencies
|
|
|
|
|
source "$SCRIPT_DIR/ensure-deps.sh"
|
|
|
|
|
ensure_build_deps
|
|
|
|
|
|
2026-03-03 19:07:39 +00:00
|
|
|
echo "==> Running unit tests..."
|
|
|
|
|
pnpm test:run
|
|
|
|
|
echo ""
|
|
|
|
|
|
2026-02-21 14:00:24 +00:00
|
|
|
echo "==> Building TypeScript..."
|
|
|
|
|
pnpm build
|
|
|
|
|
|
2026-02-27 17:05:05 +00:00
|
|
|
echo "==> Generating shell completions..."
|
|
|
|
|
pnpm completions:generate
|
|
|
|
|
|
2026-03-13 23:01:51 +00:00
|
|
|
echo "==> Bundling standalone binaries (target: ${NFPM_ARCH})..."
|
2026-02-21 14:00:24 +00:00
|
|
|
mkdir -p dist
|
2026-03-13 23:01:51 +00:00
|
|
|
rm -f "dist/mcpctl${ARCH_SUFFIX}" "dist/mcpctl-local${ARCH_SUFFIX}"
|
|
|
|
|
# Only remove RPMs for the target arch (preserve cross-compiled packages)
|
|
|
|
|
ls dist/mcpctl-*.${NFPM_ARCH}.rpm 2>/dev/null | xargs -r rm -f
|
2026-02-26 00:06:31 +00:00
|
|
|
|
|
|
|
|
# Ink optionally imports react-devtools-core which isn't installed.
|
|
|
|
|
# Provide a no-op stub so bun can bundle it (it's only invoked when DEV=true).
|
|
|
|
|
if [ ! -e node_modules/react-devtools-core ]; then
|
|
|
|
|
ln -s ../src/cli/stubs/react-devtools-core node_modules/react-devtools-core
|
|
|
|
|
fi
|
|
|
|
|
|
2026-03-13 23:01:51 +00:00
|
|
|
bun build src/cli/src/index.ts --compile ${BUN_TARGET:+--target "$BUN_TARGET"} --outfile "dist/mcpctl${ARCH_SUFFIX}"
|
|
|
|
|
bun build src/mcplocal/src/main.ts --compile ${BUN_TARGET:+--target "$BUN_TARGET"} --outfile "dist/mcpctl-local${ARCH_SUFFIX}"
|
|
|
|
|
|
|
|
|
|
# If cross-compiling, copy arch-suffixed binaries to the names nfpm expects
|
|
|
|
|
if [ -n "$ARCH_SUFFIX" ]; then
|
|
|
|
|
cp "dist/mcpctl${ARCH_SUFFIX}" dist/mcpctl
|
|
|
|
|
cp "dist/mcpctl-local${ARCH_SUFFIX}" dist/mcpctl-local
|
|
|
|
|
fi
|
2026-02-21 14:00:24 +00:00
|
|
|
|
2026-03-13 23:01:51 +00:00
|
|
|
echo "==> Packaging RPM (arch: ${NFPM_ARCH})..."
|
|
|
|
|
export NFPM_ARCH
|
2026-02-21 14:00:24 +00:00
|
|
|
nfpm pkg --packager rpm --target dist/
|
|
|
|
|
|
2026-03-13 23:01:51 +00:00
|
|
|
RPM_FILE=$(ls dist/mcpctl-*.${NFPM_ARCH}.rpm 2>/dev/null | head -1)
|
2026-02-21 14:00:24 +00:00
|
|
|
echo "==> Built: $RPM_FILE"
|
|
|
|
|
echo " Size: $(du -h "$RPM_FILE" | cut -f1)"
|
2026-03-13 23:01:51 +00:00
|
|
|
if command -v rpm &>/dev/null; then
|
|
|
|
|
rpm -qpi "$RPM_FILE"
|
|
|
|
|
fi
|
2026-03-09 22:43:40 +00:00
|
|
|
|
|
|
|
|
echo ""
|
2026-03-13 23:01:51 +00:00
|
|
|
echo "==> Packaging DEB (arch: ${NFPM_ARCH})..."
|
|
|
|
|
# Only remove DEBs for the target arch
|
|
|
|
|
ls dist/mcpctl*_${NFPM_ARCH}.deb 2>/dev/null | xargs -r rm -f
|
2026-03-09 22:43:40 +00:00
|
|
|
nfpm pkg --packager deb --target dist/
|
|
|
|
|
|
2026-03-13 23:01:51 +00:00
|
|
|
DEB_FILE=$(ls dist/mcpctl*_${NFPM_ARCH}.deb 2>/dev/null | head -1)
|
2026-03-09 22:43:40 +00:00
|
|
|
echo "==> Built: $DEB_FILE"
|
|
|
|
|
echo " Size: $(du -h "$DEB_FILE" | cut -f1)"
|