flipside-mcp-extension/Makefile
Erik Brakke 63f6080f01
Add comprehensive unit tests for MCP proxy server (#7)
* Add comprehensive unit tests for MCP proxy server

- Add main_test.go with full test coverage for proxy functionality
- Test client creation, authentication, URL conversion, and error handling
- Include mock MCP server for integration testing
- Update Makefile to run unit tests via 'make test'
- Add build target for local development
- Ensure proper proxy call forwarding and authentication verification

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Add comprehensive CI/CD pipeline with GitHub Actions

- Add test.yml workflow for basic unit testing on PRs and pushes
- Add ci.yml workflow with comprehensive testing, linting, and security scanning
- Include cross-platform build verification (Linux, macOS, Windows)
- Add golangci-lint configuration for consistent code quality
- Add PR template for structured pull request reviews
- Enable test coverage reporting with race detection
- Include security scanning with gosec and govulncheck
- Integrate Makefile testing to verify build system works

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Update README with testing and CI/CD documentation

- Add comprehensive testing section with coverage details
- Document CI/CD pipeline and quality gates
- Include local testing commands for contributors
- Explain how to ensure PRs pass all checks

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Fix linting and formatting issues for CI compliance

- Fix errcheck violations: handle ParseBool and JSON encoding errors
- Fix gofmt issues: remove trailing whitespace and ensure newlines
- Update GitHub Actions to use upload-artifact@v4 (v3 deprecated)
- Ensure all error return values are properly checked
- Add proper error handling in mock server responses

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* ignore some ci checks for now

---------

Co-authored-by: Claude <noreply@anthropic.com>
2025-07-02 11:02:58 -06:00

321 lines
15 KiB
Makefile

.PHONY: clean test dxt dxt-tar dist deps help dxt-node dxt-all release-major release-minor release-patch
# Default target
help:
@echo "Available targets:"
@echo " dxt-all - Build and package both Go and Node.js desktop extensions"
@echo " dxt - Create DXT packages for Go desktop extension"
@echo " dxt-node - Create DXT package for Node.js desktop extension"
@echo " dxt-tar - Create tar.gz packages that preserve executable permissions"
@echo " test - Test the Go binary"
@echo " clean - Clean build artifacts"
@echo " deps - Install dependencies"
@echo " release-major - Create major version release (e.g., 1.2.3 -> 2.0.0)"
@echo " release-minor - Create minor version release (e.g., 1.2.3 -> 1.3.0)"
@echo " release-patch - Create patch version release (e.g., 1.2.3 -> 1.2.4)"
@echo " help - Show this help message"
# Release commands
release-major:
@$(MAKE) _release BUMP_TYPE=major
release-minor:
@$(MAKE) _release BUMP_TYPE=minor
release-patch:
@$(MAKE) _release BUMP_TYPE=patch
_release:
@echo "Creating $(BUMP_TYPE) release..."
@current_version=$$(jq -r '.version' manifest.json); \
echo "Current version: $$current_version"; \
IFS='.' read -ra VERSION_PARTS <<< "$$current_version"; \
major=$${VERSION_PARTS[0]}; \
minor=$${VERSION_PARTS[1]}; \
patch=$${VERSION_PARTS[2]}; \
if [ "$(BUMP_TYPE)" = "major" ]; then \
major=$$((major + 1)); \
minor=0; \
patch=0; \
elif [ "$(BUMP_TYPE)" = "minor" ]; then \
minor=$$((minor + 1)); \
patch=0; \
else \
patch=$$((patch + 1)); \
fi; \
new_version="$$major.$$minor.$$patch"; \
echo "New version will be: $$new_version"; \
echo "This will create git tag: v$$new_version"; \
echo "Continue? [y/N]"; \
read -r confirm; \
if [ "$$confirm" = "y" ] || [ "$$confirm" = "Y" ]; then \
echo "Creating release v$$new_version..."; \
git tag "v$$new_version"; \
git push origin "v$$new_version"; \
echo "✅ Release v$$new_version created and pushed!"; \
echo "🚀 GitHub Actions will now build and publish the release."; \
echo "📦 Release will be available at: https://github.com/flipside-org/flipside-mcp-extension/releases/tag/v$$new_version"; \
else \
echo "❌ Release cancelled."; \
fi
# Build and package both implementations
dxt-all: clean dxt dxt-node
@echo "Both Go and Node.js implementations have been built and packaged"
@echo ""
@echo "Available DXT packages:"
@ls -la dist/*.dxt
# Build local binary
build:
go build -ldflags="-s -w" -o remote-mcp-proxy .
chmod +x remote-mcp-proxy
# Build for all supported platforms
build-all: clean
# macOS
GOOS=darwin GOARCH=amd64 go build -ldflags="-s -w" -o dist/remote-mcp-proxy-darwin-amd64 .
chmod +x dist/remote-mcp-proxy-darwin-amd64
GOOS=darwin GOARCH=arm64 go build -ldflags="-s -w" -o dist/remote-mcp-proxy-darwin-arm64 .
chmod +x dist/remote-mcp-proxy-darwin-arm64
# Linux
GOOS=linux GOARCH=amd64 go build -ldflags="-s -w" -o dist/remote-mcp-proxy-linux-amd64 .
chmod +x dist/remote-mcp-proxy-linux-amd64
GOOS=linux GOARCH=arm64 go build -ldflags="-s -w" -o dist/remote-mcp-proxy-linux-arm64 .
chmod +x dist/remote-mcp-proxy-linux-arm64
# Windows
GOOS=windows GOARCH=amd64 go build -ldflags="-s -w" -o dist/remote-mcp-proxy-windows-amd64.exe .
chmod +x dist/remote-mcp-proxy-windows-amd64.exe
GOOS=windows GOARCH=arm64 go build -ldflags="-s -w" -o dist/remote-mcp-proxy-windows-arm64.exe .
chmod +x dist/remote-mcp-proxy-windows-arm64.exe
# Create DXT packages using official dxt CLI
dxt: build-all
mkdir -p dist/dxt-staging
# macOS x64
mkdir -p dist/dxt-staging/darwin-amd64
cp dist/remote-mcp-proxy-darwin-amd64 dist/dxt-staging/darwin-amd64/remote-mcp-proxy
chmod 755 dist/dxt-staging/darwin-amd64/remote-mcp-proxy
@echo "Verifying permissions for darwin-amd64:"
@ls -la dist/dxt-staging/darwin-amd64/remote-mcp-proxy
@echo "Testing executable can run:"
@dist/dxt-staging/darwin-amd64/remote-mcp-proxy --help 2>/dev/null || echo "Binary is executable (no --help flag expected)"
cp manifest.json dist/dxt-staging/darwin-amd64/
cp README.md dist/dxt-staging/darwin-amd64/ 2>/dev/null || true
cd dist/dxt-staging/darwin-amd64 && npx @anthropic-ai/dxt pack . ../flipside-remote-mcp-proxy-darwin-amd64.dxt
# macOS ARM64
mkdir -p dist/dxt-staging/darwin-arm64
cp dist/remote-mcp-proxy-darwin-arm64 dist/dxt-staging/darwin-arm64/remote-mcp-proxy
chmod 755 dist/dxt-staging/darwin-arm64/remote-mcp-proxy
@echo "Verifying permissions for darwin-arm64:"
@ls -la dist/dxt-staging/darwin-arm64/remote-mcp-proxy
cp manifest.json dist/dxt-staging/darwin-arm64/
cp README.md dist/dxt-staging/darwin-arm64/ 2>/dev/null || true
cd dist/dxt-staging/darwin-arm64 && npx @anthropic-ai/dxt pack . ../flipside-remote-mcp-proxy-darwin-arm64.dxt
# Linux x64
mkdir -p dist/dxt-staging/linux-amd64
cp dist/remote-mcp-proxy-linux-amd64 dist/dxt-staging/linux-amd64/remote-mcp-proxy
chmod 755 dist/dxt-staging/linux-amd64/remote-mcp-proxy
cp manifest.json dist/dxt-staging/linux-amd64/
cp README.md dist/dxt-staging/linux-amd64/ 2>/dev/null || true
cd dist/dxt-staging/linux-amd64 && npx @anthropic-ai/dxt pack . ../flipside-remote-mcp-proxy-linux-amd64.dxt
# Linux ARM64
mkdir -p dist/dxt-staging/linux-arm64
cp dist/remote-mcp-proxy-linux-arm64 dist/dxt-staging/linux-arm64/remote-mcp-proxy
chmod 755 dist/dxt-staging/linux-arm64/remote-mcp-proxy
cp manifest.json dist/dxt-staging/linux-arm64/
cp README.md dist/dxt-staging/linux-arm64/ 2>/dev/null || true
cd dist/dxt-staging/linux-arm64 && npx @anthropic-ai/dxt pack . ../flipside-remote-mcp-proxy-linux-arm64.dxt
# Windows x64
mkdir -p dist/dxt-staging/windows-amd64
cp dist/remote-mcp-proxy-windows-amd64.exe dist/dxt-staging/windows-amd64/remote-mcp-proxy.exe
chmod 755 dist/dxt-staging/windows-amd64/remote-mcp-proxy.exe
cp manifest.json dist/dxt-staging/windows-amd64/
cp README.md dist/dxt-staging/windows-amd64/ 2>/dev/null || true
cd dist/dxt-staging/windows-amd64 && npx @anthropic-ai/dxt pack . ../flipside-remote-mcp-proxy-windows-amd64.dxt
# Windows ARM64
mkdir -p dist/dxt-staging/windows-arm64
cp dist/remote-mcp-proxy-windows-arm64.exe dist/dxt-staging/windows-arm64/remote-mcp-proxy.exe
chmod 755 dist/dxt-staging/windows-arm64/remote-mcp-proxy.exe
cp manifest.json dist/dxt-staging/windows-arm64/
cp README.md dist/dxt-staging/windows-arm64/ 2>/dev/null || true
cd dist/dxt-staging/windows-arm64 && npx @anthropic-ai/dxt pack . ../flipside-remote-mcp-proxy-windows-arm64.dxt
# Move final DXT files to dist root
mv dist/dxt-staging/*.dxt dist/
@echo "DXT packages created:"
@ls -la dist/*.dxt
@echo ""
@echo "Creating tar.gz packages that preserve permissions:"
@cd dist/dxt-staging/darwin-amd64 && tar -czf ../../flipside-intelligence-mcp-darwin-amd64.tar.gz .
@cd dist/dxt-staging/darwin-arm64 && tar -czf ../../flipside-intelligence-mcp-darwin-arm64.tar.gz .
@cd dist/dxt-staging/linux-amd64 && tar -czf ../../flipside-intelligence-mcp-linux-amd64.tar.gz .
@cd dist/dxt-staging/linux-arm64 && tar -czf ../../flipside-intelligence-mcp-linux-arm64.tar.gz .
@cd dist/dxt-staging/windows-amd64 && tar -czf ../../flipside-intelligence-mcp-windows-amd64.tar.gz .
@cd dist/dxt-staging/windows-arm64 && tar -czf ../../flipside-intelligence-mcp-windows-arm64.tar.gz .
@echo "Tar.gz packages created (preserves permissions):"
@ls -la dist/*.tar.gz
@echo ""
@echo "Testing DXT extraction and permissions (darwin-amd64):"
@mkdir -p dist/test-extract && cd dist/test-extract && unzip -q ../flipside-remote-mcp-proxy-darwin-amd64.dxt
@echo "Permissions after DXT extraction:"
@ls -la dist/test-extract/remote-mcp-proxy 2>/dev/null || echo "Binary not found in expected location"
@rm -rf dist/test-extract
# Create tar.gz packages that preserve executable permissions (alternative to DXT)
dxt-tar: build-all
mkdir -p dist/dxt-staging
# macOS x64
mkdir -p dist/dxt-staging/darwin-amd64
cp dist/remote-mcp-proxy-darwin-amd64 dist/dxt-staging/darwin-amd64/remote-mcp-proxy
chmod 755 dist/dxt-staging/darwin-amd64/remote-mcp-proxy
cp manifest.json dist/dxt-staging/darwin-amd64/
cp README.md dist/dxt-staging/darwin-amd64/ 2>/dev/null || true
cd dist/dxt-staging/darwin-amd64 && tar -czf ../../flipside-intelligence-mcp-darwin-amd64.tar.gz .
# macOS ARM64
mkdir -p dist/dxt-staging/darwin-arm64
cp dist/remote-mcp-proxy-darwin-arm64 dist/dxt-staging/darwin-arm64/remote-mcp-proxy
chmod 755 dist/dxt-staging/darwin-arm64/remote-mcp-proxy
cp manifest.json dist/dxt-staging/darwin-arm64/
cp README.md dist/dxt-staging/darwin-arm64/ 2>/dev/null || true
cd dist/dxt-staging/darwin-arm64 && tar -czf ../../flipside-intelligence-mcp-darwin-arm64.tar.gz .
# Linux x64
mkdir -p dist/dxt-staging/linux-amd64
cp dist/remote-mcp-proxy-linux-amd64 dist/dxt-staging/linux-amd64/remote-mcp-proxy
chmod 755 dist/dxt-staging/linux-amd64/remote-mcp-proxy
cp manifest.json dist/dxt-staging/linux-amd64/
cp README.md dist/dxt-staging/linux-amd64/ 2>/dev/null || true
cd dist/dxt-staging/linux-amd64 && tar -czf ../../flipside-intelligence-mcp-linux-amd64.tar.gz .
# Linux ARM64
mkdir -p dist/dxt-staging/linux-arm64
cp dist/remote-mcp-proxy-linux-arm64 dist/dxt-staging/linux-arm64/remote-mcp-proxy
chmod 755 dist/dxt-staging/linux-arm64/remote-mcp-proxy
cp manifest.json dist/dxt-staging/linux-arm64/
cp README.md dist/dxt-staging/linux-arm64/ 2>/dev/null || true
cd dist/dxt-staging/linux-arm64 && tar -czf ../../flipside-intelligence-mcp-linux-arm64.tar.gz .
# Windows x64
mkdir -p dist/dxt-staging/windows-amd64
cp dist/remote-mcp-proxy-windows-amd64.exe dist/dxt-staging/windows-amd64/remote-mcp-proxy.exe
chmod 755 dist/dxt-staging/windows-amd64/remote-mcp-proxy.exe
cp manifest.json dist/dxt-staging/windows-amd64/
cp README.md dist/dxt-staging/windows-amd64/ 2>/dev/null || true
cd dist/dxt-staging/windows-amd64 && tar -czf ../../flipside-intelligence-mcp-windows-amd64.tar.gz .
# Windows ARM64
mkdir -p dist/dxt-staging/windows-arm64
cp dist/remote-mcp-proxy-windows-arm64.exe dist/dxt-staging/windows-arm64/remote-mcp-proxy.exe
chmod 755 dist/dxt-staging/windows-arm64/remote-mcp-proxy.exe
cp manifest.json dist/dxt-staging/windows-arm64/
cp README.md dist/dxt-staging/windows-arm64/ 2>/dev/null || true
cd dist/dxt-staging/windows-arm64 && tar -czf ../../flipside-intelligence-mcp-windows-arm64.tar.gz .
@echo "Tar.gz packages created (preserves executable permissions):"
@ls -la dist/*.tar.gz
@echo ""
@echo "Testing tar.gz extraction and permissions (darwin-amd64):"
@mkdir -p dist/test-extract && cd dist/test-extract && tar -xzf ../flipside-intelligence-mcp-darwin-amd64.tar.gz
@echo "Permissions after tar.gz extraction:"
@ls -la dist/test-extract/remote-mcp-proxy
@echo "Testing if binary is executable:"
@dist/test-extract/remote-mcp-proxy --help 2>/dev/null || echo "Binary is executable (no --help flag expected)"
@rm -rf dist/test-extract
# Legacy zip-based distribution (kept for compatibility)
dist: build-all
mkdir -p dist/dxt
# macOS x64
mkdir -p dist/dxt/flipside-remote-mcp-proxy-darwin-amd64
cp dist/remote-mcp-proxy-darwin-amd64 dist/dxt/flipside-remote-mcp-proxy-darwin-amd64/remote-mcp-proxy
cp manifest.json dist/dxt/flipside-remote-mcp-proxy-darwin-amd64/
cp README.md dist/dxt/flipside-remote-mcp-proxy-darwin-amd64/ 2>/dev/null || true
cd dist/dxt && zip -r flipside-remote-mcp-proxy-darwin-amd64.dxt flipside-remote-mcp-proxy-darwin-amd64/
# macOS ARM64
mkdir -p dist/dxt/flipside-remote-mcp-proxy-darwin-arm64
cp dist/remote-mcp-proxy-darwin-arm64 dist/dxt/flipside-remote-mcp-proxy-darwin-arm64/remote-mcp-proxy
cp manifest.json dist/dxt/flipside-remote-mcp-proxy-darwin-arm64/
cp README.md dist/dxt/flipside-remote-mcp-proxy-darwin-arm64/ 2>/dev/null || true
cd dist/dxt && zip -r flipside-remote-mcp-proxy-darwin-arm64.dxt flipside-remote-mcp-proxy-darwin-arm64/
# Linux x64
mkdir -p dist/dxt/flipside-remote-mcp-proxy-linux-amd64
cp dist/remote-mcp-proxy-linux-amd64 dist/dxt/flipside-remote-mcp-proxy-linux-amd64/remote-mcp-proxy
cp manifest.json dist/dxt/flipside-remote-mcp-proxy-linux-amd64/
cp README.md dist/dxt/flipside-remote-mcp-proxy-linux-amd64/ 2>/dev/null || true
cd dist/dxt && zip -r flipside-remote-mcp-proxy-linux-amd64.dxt flipside-remote-mcp-proxy-linux-amd64/
# Linux ARM64
mkdir -p dist/dxt/flipside-remote-mcp-proxy-linux-arm64
cp dist/remote-mcp-proxy-linux-arm64 dist/dxt/flipside-remote-mcp-proxy-linux-arm64/remote-mcp-proxy
cp manifest.json dist/dxt/flipside-remote-mcp-proxy-linux-arm64/
cp README.md dist/dxt/flipside-remote-mcp-proxy-linux-arm64/ 2>/dev/null || true
cd dist/dxt && zip -r flipside-remote-mcp-proxy-linux-arm64.dxt flipside-remote-mcp-proxy-linux-arm64/
# Windows x64
mkdir -p dist/dxt/flipside-remote-mcp-proxy-windows-amd64
cp dist/remote-mcp-proxy-windows-amd64.exe dist/dxt/flipside-remote-mcp-proxy-windows-amd64/remote-mcp-proxy.exe
cp manifest.json dist/dxt/flipside-remote-mcp-proxy-windows-amd64/
cp README.md dist/dxt/flipside-remote-mcp-proxy-windows-amd64/ 2>/dev/null || true
cd dist/dxt && zip -r flipside-remote-mcp-proxy-windows-amd64.dxt flipside-remote-mcp-proxy-windows-amd64/
# Windows ARM64
mkdir -p dist/dxt/flipside-remote-mcp-proxy-windows-arm64
cp dist/remote-mcp-proxy-windows-arm64.exe dist/dxt/flipside-remote-mcp-proxy-windows-arm64/remote-mcp-proxy.exe
cp manifest.json dist/dxt/flipside-remote-mcp-proxy-windows-arm64/
cp README.md dist/dxt/flipside-remote-mcp-proxy-windows-arm64/ 2>/dev/null || true
cd dist/dxt && zip -r flipside-remote-mcp-proxy-windows-arm64.dxt flipside-remote-mcp-proxy-windows-arm64/
# Test the binary
test:
@echo "Running Go unit tests..."
go test -v
@echo ""
@echo "Running functional test..."
@$(MAKE) build
@echo '{"jsonrpc":"2.0","id":1,"method":"tools/list"}' | MCP_REMOTE_URL=http://localhost:8080 ./remote-mcp-proxy || echo "Functional test requires running server"
# Clean build artifacts
clean:
rm -rf dist/
rm -f remote-mcp-proxy remote-mcp-proxy.exe
# Install dependencies
deps:
go mod tidy
go mod download
# Create DXT package for Node.js
dxt-node: clean
@echo "Creating Node.js DXT package..."
mkdir -p dist/dxt-staging/node
cp -r node/* dist/dxt-staging/node/
cp README.md dist/dxt-staging/node/ 2>/dev/null || true
cd dist/dxt-staging/node && npx -y @anthropic-ai/dxt pack . ../flipside-mcp-proxy-node.dxt || (echo "Error: Failed to create DXT package. Is @anthropic-ai/dxt installed?" && exit 1)
mv dist/dxt-staging/flipside-mcp-proxy-node.dxt dist/
@echo "Node.js DXT package created:"
@ls -la dist/flipside-mcp-proxy-node.dxt
@echo ""
@echo "Testing DXT extraction:"
@mkdir -p dist/test-extract && cd dist/test-extract && unzip -q ../flipside-mcp-proxy-node.dxt
@echo "Contents after DXT extraction:"
@ls -la dist/test-extract/
@rm -rf dist/test-extract