feat: add embedded MCP server and Makefile
Add an MCP (Model Context Protocol) server that starts on 127.0.0.1:9427 at app launch, sharing connection pools with the Tauri IPC layer. This lets Claude (or any MCP client) query PostgreSQL through Tusk's existing connections. MCP tools: list_connections, execute_query, list_schemas, list_tables, describe_table. Also add a Makefile with targets for dev, build (cross-platform), install/uninstall, lint, and formatting. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
138
Makefile
Normal file
138
Makefile
Normal file
@@ -0,0 +1,138 @@
|
||||
APP_NAME := tusk
|
||||
VERSION := $(shell grep '"version"' src-tauri/tauri.conf.json | head -1 | sed 's/.*: "//;s/".*//')
|
||||
PREFIX := /usr/local
|
||||
BINDIR := $(PREFIX)/bin
|
||||
DATADIR := $(PREFIX)/share
|
||||
BUNDLE_DIR := src-tauri/target/release/bundle
|
||||
|
||||
# Rust cross-compilation target (override: make build TARGET=aarch64-unknown-linux-gnu)
|
||||
TARGET :=
|
||||
TARGET_FLAG := $(if $(TARGET),--target $(TARGET),)
|
||||
TARGET_DIR := $(if $(TARGET),src-tauri/target/$(TARGET)/release,src-tauri/target/release)
|
||||
|
||||
# ──────────────────────────────────────────────
|
||||
# Development
|
||||
# ──────────────────────────────────────────────
|
||||
|
||||
.PHONY: dev
|
||||
dev: node_modules ## Run app in dev mode (Vite HMR + Rust backend)
|
||||
npm run tauri dev
|
||||
|
||||
.PHONY: dev-frontend
|
||||
dev-frontend: node_modules ## Run only the Vite frontend dev server
|
||||
npm run dev
|
||||
|
||||
.PHONY: check
|
||||
check: ## Check Rust compilation without building
|
||||
cd src-tauri && cargo check $(TARGET_FLAG)
|
||||
|
||||
.PHONY: lint
|
||||
lint: node_modules ## Run ESLint + cargo clippy
|
||||
npm run lint
|
||||
cd src-tauri && cargo clippy $(TARGET_FLAG) -- -D warnings
|
||||
|
||||
.PHONY: fmt
|
||||
fmt: ## Format Rust code
|
||||
cd src-tauri && cargo fmt
|
||||
|
||||
.PHONY: fmt-check
|
||||
fmt-check: ## Check Rust formatting
|
||||
cd src-tauri && cargo fmt --check
|
||||
|
||||
# ──────────────────────────────────────────────
|
||||
# Build
|
||||
# ──────────────────────────────────────────────
|
||||
|
||||
.PHONY: build
|
||||
build: node_modules ## Build release binary + bundles for current platform
|
||||
npm run tauri build $(TARGET_FLAG)
|
||||
|
||||
.PHONY: build-debug
|
||||
build-debug: node_modules ## Build debug binary
|
||||
npm run tauri build -- --debug $(TARGET_FLAG)
|
||||
|
||||
.PHONY: build-linux
|
||||
build-linux: node_modules ## Build for Linux (deb + AppImage + rpm)
|
||||
npm run tauri build
|
||||
|
||||
.PHONY: build-macos
|
||||
build-macos: node_modules ## Build for macOS (dmg + app bundle) — run on macOS
|
||||
npm run tauri build
|
||||
|
||||
.PHONY: build-macos-universal
|
||||
build-macos-universal: node_modules ## Build universal macOS binary (x86_64 + aarch64)
|
||||
npm run tauri build -- --target universal-apple-darwin
|
||||
|
||||
.PHONY: build-windows
|
||||
build-windows: node_modules ## Build for Windows (msi + nsis) — run on Windows
|
||||
npm run tauri build
|
||||
|
||||
# ──────────────────────────────────────────────
|
||||
# Install / Uninstall (Linux)
|
||||
# ──────────────────────────────────────────────
|
||||
|
||||
define DESKTOP_ENTRY
|
||||
[Desktop Entry]
|
||||
Name=Tusk
|
||||
Comment=PostgreSQL Database Management GUI
|
||||
Exec=$(BINDIR)/$(APP_NAME)
|
||||
Icon=$(APP_NAME)
|
||||
Terminal=false
|
||||
Type=Application
|
||||
Categories=Development;Database;
|
||||
Keywords=postgresql;database;sql;
|
||||
endef
|
||||
export DESKTOP_ENTRY
|
||||
|
||||
.PHONY: install
|
||||
install: build ## Build release and install to system (PREFIX=/usr/local)
|
||||
install -Dm755 $(TARGET_DIR)/$(APP_NAME) $(DESTDIR)$(BINDIR)/$(APP_NAME)
|
||||
@mkdir -p $(DESTDIR)$(DATADIR)/applications
|
||||
@echo "$$DESKTOP_ENTRY" > $(DESTDIR)$(DATADIR)/applications/$(APP_NAME).desktop
|
||||
@for size in 32x32 128x128; do \
|
||||
if [ -f src-tauri/icons/$$size.png ]; then \
|
||||
install -Dm644 src-tauri/icons/$$size.png \
|
||||
$(DESTDIR)$(DATADIR)/icons/hicolor/$$size/apps/$(APP_NAME).png; \
|
||||
fi; \
|
||||
done
|
||||
@echo "Installed $(APP_NAME) $(VERSION) to $(DESTDIR)$(BINDIR)/$(APP_NAME)"
|
||||
|
||||
.PHONY: uninstall
|
||||
uninstall: ## Remove installed files
|
||||
rm -f $(DESTDIR)$(BINDIR)/$(APP_NAME)
|
||||
rm -f $(DESTDIR)$(DATADIR)/applications/$(APP_NAME).desktop
|
||||
rm -f $(DESTDIR)$(DATADIR)/icons/hicolor/32x32/apps/$(APP_NAME).png
|
||||
rm -f $(DESTDIR)$(DATADIR)/icons/hicolor/128x128/apps/$(APP_NAME).png
|
||||
@echo "Uninstalled $(APP_NAME)"
|
||||
|
||||
# ──────────────────────────────────────────────
|
||||
# Utilities
|
||||
# ──────────────────────────────────────────────
|
||||
|
||||
.PHONY: clean
|
||||
clean: ## Remove build artifacts
|
||||
rm -rf dist
|
||||
cd src-tauri && cargo clean
|
||||
|
||||
.PHONY: clean-frontend
|
||||
clean-frontend: ## Remove only frontend build output
|
||||
rm -rf dist node_modules/.vite
|
||||
|
||||
.PHONY: deps
|
||||
deps: node_modules ## Install all dependencies
|
||||
@echo "Dependencies ready"
|
||||
|
||||
node_modules: package.json
|
||||
npm install
|
||||
@touch node_modules
|
||||
|
||||
.PHONY: version
|
||||
version: ## Show app version
|
||||
@echo "$(APP_NAME) $(VERSION)"
|
||||
|
||||
.PHONY: help
|
||||
help: ## Show this help
|
||||
@grep -E '^[a-zA-Z_-]+:.*##' $(MAKEFILE_LIST) | \
|
||||
awk 'BEGIN {FS = ":.*## "}; {printf " \033[36m%-22s\033[0m %s\n", $$1, $$2}'
|
||||
|
||||
.DEFAULT_GOAL := help
|
||||
Reference in New Issue
Block a user