@@ -8,6 +8,11 @@ GOTEST=$(GOCMD) test
88GOGET =$(GOCMD ) get
99GOMOD =$(GOCMD ) mod
1010
11+ # Node.js parameters for MCP server
12+ NPM =npm
13+ MCP_DIR =mcp-docs-server
14+ MCP_DIST =$(MCP_DIR ) /dist
15+
1116# Binary details
1217BINARY_NAME =vapi
1318BUILD_DIR =build
@@ -21,20 +26,56 @@ GIT_COMMIT=$(shell git rev-parse --short HEAD 2>/dev/null || echo "unknown")
2126# Build flags - note the lowercase variable names to match main.go
2227LDFLAGS =-ldflags "-X main.version=$(VERSION ) -X main.commit=$(GIT_COMMIT ) -X main.date=$(BUILD_TIME ) -X main.builtBy=make"
2328
24- # Default target
25- all : test build
29+ # Default target - build both CLI and MCP server
30+ all : test build build-mcp
2631
2732# Create build directory
2833$(BUILD_DIR ) :
2934 @mkdir -p $(BUILD_DIR )
3035
31- # Build the binary
36+ # Build the CLI binary
3237build : $(BUILD_DIR )
3338 @echo " Building $( BINARY_NAME) ..."
3439 $(GOBUILD ) $(LDFLAGS ) -o $(BINARY_PATH ) -v
3540
41+ # Build MCP server
42+ build-mcp :
43+ @echo " Building MCP docs server..."
44+ @if [ ! -d " $( MCP_DIR) /node_modules" ]; then \
45+ echo " Installing MCP server dependencies..." ; \
46+ cd $(MCP_DIR ) && $(NPM ) install; \
47+ fi
48+ @cd $(MCP_DIR ) && $(NPM ) run build
49+ @echo " ✅ MCP server built successfully"
50+
51+ # Install MCP server dependencies
52+ mcp-deps :
53+ @echo " Installing MCP server dependencies..."
54+ @cd $(MCP_DIR ) && $(NPM ) install
55+
56+ # Clean MCP server
57+ clean-mcp :
58+ @echo " Cleaning MCP server..."
59+ @rm -rf $(MCP_DIR ) /dist
60+ @rm -rf $(MCP_DIR ) /node_modules
61+
62+ # Test MCP server
63+ test-mcp :
64+ @echo " Testing MCP server..."
65+ @cd $(MCP_DIR ) && $(NPM ) test
66+
67+ # Lint MCP server
68+ lint-mcp :
69+ @echo " Linting MCP server..."
70+ @cd $(MCP_DIR ) && $(NPM ) run lint
71+
72+ # Publish MCP server to npm
73+ publish-mcp :
74+ @echo " Publishing MCP server to npm..."
75+ @cd $(MCP_DIR ) && $(NPM ) publish
76+
3677# Build for all platforms
37- build-all : $(BUILD_DIR )
78+ build-all : $(BUILD_DIR ) build-mcp
3879 @echo " Building for all platforms..."
3980 # macOS AMD64
4081 GOOS=darwin GOARCH=amd64 $(GOBUILD ) $(LDFLAGS ) -o $(BUILD_DIR ) /$(BINARY_NAME ) -darwin-amd64
5091 @echo " Running tests..."
5192 $(GOTEST ) -v ./...
5293
94+ # Run all tests (CLI + MCP server)
95+ test-all : test test-mcp
96+
5397# Run tests with coverage
5498test-coverage :
5599 @echo " Running tests with coverage..."
@@ -63,6 +107,9 @@ clean:
63107 rm -rf $(BUILD_DIR )
64108 rm -f coverage.out coverage.html
65109
110+ # Clean everything (CLI + MCP server)
111+ clean-all : clean clean-mcp
112+
66113# Run go mod tidy
67114tidy :
68115 @echo " Tidying modules..."
@@ -73,18 +120,33 @@ deps:
73120 @echo " Downloading dependencies..."
74121 $(GOMOD ) download
75122
123+ # Install all dependencies (CLI + MCP server)
124+ deps-all : deps mcp-deps
125+
76126# Run linters
77127lint :
78128 @echo " Running linters..."
79129 golangci-lint run
80130
131+ # Run all linters (CLI + MCP server)
132+ lint-all : lint lint-mcp
133+
81134# Install the binary locally
82135install : build
83136 @echo " Installing $( BINARY_NAME) ..."
84137 @mkdir -p $(HOME ) /.local/bin
85138 @cp $(BINARY_PATH ) $(HOME ) /.local/bin/
86139 @echo " Installed to $( HOME) /.local/bin/$( BINARY_NAME) "
87140
141+ # Install MCP server globally
142+ install-mcp : build-mcp
143+ @echo " Installing MCP server globally..."
144+ @cd $(MCP_DIR ) && $(NPM ) install -g .
145+ @echo " ✅ MCP server installed globally"
146+
147+ # Install everything
148+ install-all : install install-mcp
149+
88150# Run the binary
89151run : build
90152 $(BINARY_PATH )
@@ -114,22 +176,43 @@ version-bump-patch:
114176
115177# Help target to show available commands
116178help :
117- @echo " Available targets:"
179+ @echo " 🚀 Vapi CLI & MCP Server Build System"
180+ @echo " "
181+ @echo " 📦 CLI Commands:"
118182 @echo " build Build the CLI binary"
119183 @echo " install Install the CLI to ~/.local/bin"
120- @echo " test Run all tests"
121- @echo " lint Run linters"
122- @echo " clean Clean build artifacts"
184+ @echo " test Run CLI tests"
185+ @echo " lint Run CLI linters"
186+ @echo " clean Clean CLI build artifacts"
187+ @echo " "
188+ @echo " 🔧 MCP Server Commands:"
189+ @echo " build-mcp Build the MCP docs server"
190+ @echo " install-mcp Install MCP server globally"
191+ @echo " test-mcp Run MCP server tests"
192+ @echo " lint-mcp Run MCP server linters"
193+ @echo " clean-mcp Clean MCP server artifacts"
194+ @echo " publish-mcp Publish MCP server to npm"
195+ @echo " "
196+ @echo " 🎯 Combined Commands:"
197+ @echo " all Build both CLI and MCP server"
198+ @echo " build-all Build CLI for all platforms + MCP server"
199+ @echo " test-all Run all tests (CLI + MCP server)"
200+ @echo " lint-all Run all linters (CLI + MCP server)"
201+ @echo " clean-all Clean everything"
202+ @echo " deps-all Install all dependencies"
203+ @echo " install-all Install CLI and MCP server"
123204 @echo " "
124- @echo " Version management:"
205+ @echo " 📋 Version management:"
125206 @echo " version Show current version"
126207 @echo " version-set Set version (requires VERSION=x.y.z)"
127208 @echo " version-bump-major Bump major version (1.2.3 -> 2.0.0)"
128209 @echo " version-bump-minor Bump minor version (1.2.3 -> 1.3.0)"
129210 @echo " version-bump-patch Bump patch version (1.2.3 -> 1.2.4)"
130211 @echo " "
131212 @echo " Examples:"
213+ @echo " make all # Build everything"
214+ @echo " make install-all # Install CLI + MCP server"
132215 @echo " make version-set VERSION=1.2.3"
133- @echo " make version-bump-patch "
216+ @echo " make publish-mcp # Publish MCP server to npm "
134217
135- .PHONY : all build build-all test test-coverage clean tidy deps lint install run help
218+ .PHONY : all build build-mcp build- all test test-mcp test-all test- coverage clean clean-mcp clean-all tidy deps mcp-deps deps-all lint lint-mcp lint-all install install-mcp install-all run publish-mcp help
0 commit comments