summaryrefslogtreecommitdiff
path: root/Makefile
blob: dfcc77df9489761818e9b7c9cf2eddd9f12aa2de (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
# Go MCP Servers Makefile
.PHONY: all build test clean install uninstall fmt vet lint e2e help

# Variables
GOCMD = go
GOBUILD = $(GOCMD) build
GOTEST = $(GOCMD) test
GOFMT = $(GOCMD) fmt
GOVET = $(GOCMD) vet
BINDIR = bin
INSTALLDIR = /usr/local/bin

# Server binaries
SERVERS = git filesystem fetch memory sequential-thinking time maildir signal gitlab imap bash speech
BINARIES = $(addprefix $(BINDIR)/mcp-,$(SERVERS))

# Build flags
LDFLAGS = -ldflags="-s -w"
BUILD_FLAGS = $(LDFLAGS) -trimpath

all: build ## Build all servers

build: $(BINARIES) ## Build all MCP servers

$(BINDIR)/mcp-%: cmd/%/main.go
	@mkdir -p $(BINDIR)
	@if [ "$*" = "signal" ]; then \
		CGO_ENABLED=1 $(GOBUILD) $(BUILD_FLAGS) -o $@ ./cmd/$*; \
	else \
		$(GOBUILD) $(BUILD_FLAGS) -o $@ ./cmd/$*; \
	fi

test: ## Run all tests
	$(GOTEST) -v ./...

test-smoke: clean build
	@echo "Running smoke tests for all MCP servers..."
	@for server in $(SERVERS); do \
		echo "Testing mcp-$$server..."; \
		echo '{"jsonrpc": "2.0", "id": 1, "method": "initialize", "params": {}}' | ./bin/mcp-$$server . | jq '.'; \
		echo '{"jsonrpc": "2.0", "id": 1, "method": "tools/list", "params": {}}' | ./bin/mcp-$$server . | jq '.'; \
		echo '{"jsonrpc": "2.0", "id": 1, "method": "resources/list", "params": {}}' | ./bin/mcp-$$server . | jq '.'; \
		echo '{"jsonrpc": "2.0", "id": 1, "method": "prompts/list", "params": {}}' | ./bin/mcp-$$server . | jq '.'; \
		echo '{"jsonrpc": "2.0", "id": 1, "method": "roots/list", "params": {}}' | ./bin/mcp-$$server . | jq '.'; \
	done

test-coverage: ## Run tests with coverage
	$(GOTEST) -cover ./...

e2e: clean build ## Run end-to-end integration tests
	@echo "Running e2e integration tests..."
	cd test/integration && $(GOTEST) -v -timeout=30s ./...

clean: ## Clean build artifacts
	rm -rf $(BINDIR)

install: build ## Install binaries to system (requires sudo)
	@echo "Installing MCP servers to $(INSTALLDIR)..."
	@for binary in $(BINARIES); do \
		echo "Installing $$binary to $(INSTALLDIR)"; \
		install -m 755 $$binary $(INSTALLDIR)/; \
	done
	@echo "Installation complete!"

uninstall: ## Remove installed binaries
	@echo "Removing MCP servers from $(INSTALLDIR)..."
	@for server in $(SERVERS); do \
		rm -f $(INSTALLDIR)/mcp-$$server; \
	done
	@echo "Uninstall complete!"

fmt: ## Format Go source code
	$(GOFMT) ./...

vet: ## Run go vet
	$(GOVET) ./...

lint: fmt vet ## Run formatting and vetting

dev-setup: ## Set up development environment
	@echo "Setting up development environment..."
	@go mod download
	@go mod tidy
	@echo "Development environment ready!"

release: clean test build ## Build release version
	@echo "Building release binaries..."
	@for server in $(SERVERS); do \
		echo "Building mcp-$$server..."; \
		CGO_ENABLED=0 GOOS=linux GOARCH=amd64 $(GOBUILD) $(BUILD_FLAGS) -o $(BINDIR)/linux-amd64/mcp-$$server ./cmd/$$server; \
		CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 $(GOBUILD) $(BUILD_FLAGS) -o $(BINDIR)/darwin-amd64/mcp-$$server ./cmd/$$server; \
		CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 $(GOBUILD) $(BUILD_FLAGS) -o $(BINDIR)/darwin-arm64/mcp-$$server ./cmd/$$server; \
		CGO_ENABLED=0 GOOS=windows GOARCH=amd64 $(GOBUILD) $(BUILD_FLAGS) -o $(BINDIR)/windows-amd64/mcp-$$server.exe ./cmd/$$server; \
	done
	@echo "Release build complete!"

benchmark: ## Run benchmarks
	$(GOTEST) -bench=. -benchmem ./...

deps: ## Download dependencies
	$(GOCMD) mod download
	$(GOCMD) mod tidy

verify: test lint ## Verify code quality

docker-build: ## Build Docker image
	docker build -t mcp-servers .

docker-run: docker-build ## Run servers in Docker
	docker run -it mcp-servers

# Individual server targets
git: $(BINDIR)/mcp-git ## Build git server only
filesystem: $(BINDIR)/mcp-filesystem ## Build filesystem server only  
fetch: $(BINDIR)/mcp-fetch ## Build fetch server only
memory: $(BINDIR)/mcp-memory ## Build memory server only
sequential-thinking: $(BINDIR)/mcp-sequential-thinking ## Build sequential-thinking server only
time: $(BINDIR)/mcp-time ## Build time server only
maildir: $(BINDIR)/mcp-maildir ## Build maildir server only
signal: $(BINDIR)/mcp-signal ## Build signal server only
gitlab: $(BINDIR)/mcp-gitlab ## Build gitlab server only
imap: $(BINDIR)/mcp-imap ## Build imap server only
bash: $(BINDIR)/mcp-bash ## Build bash server only
speech: $(BINDIR)/mcp-speech ## Build speech server only

help: ## Show this help message
	@echo "Go MCP Servers - Available targets:"
	@echo ""
	@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "  \033[36m%-20s\033[0m %s\n", $$1, $$2}'
	@echo ""
	@echo "Individual servers:"
	@echo "  git, filesystem, fetch, memory, sequential-thinking, time, maildir, signal, gitlab, imap, bash, speech"