From 3fbb9a18372f2b6a675dd6c039ba52be76f3eeb4 Mon Sep 17 00:00:00 2001 From: TheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com> Date: Fri, 16 Jan 2026 08:30:14 +0900 Subject: updates --- .../simple-mcp-server/.claude/hooks/pre-build.sh | 144 +++++++++++++++++++++ 1 file changed, 144 insertions(+) create mode 100755 mcp-servers/simple-mcp-server/.claude/hooks/pre-build.sh (limited to 'mcp-servers/simple-mcp-server/.claude/hooks/pre-build.sh') diff --git a/mcp-servers/simple-mcp-server/.claude/hooks/pre-build.sh b/mcp-servers/simple-mcp-server/.claude/hooks/pre-build.sh new file mode 100755 index 0000000..a72ff45 --- /dev/null +++ b/mcp-servers/simple-mcp-server/.claude/hooks/pre-build.sh @@ -0,0 +1,144 @@ +#!/bin/bash + +# Pre-Build Hook for Simple MCP Server +# Runs before building for production + +set -e + +# Colors for output +RED='\033[0;31m' +GREEN='\033[0;32m' +YELLOW='\033[1;33m' +BLUE='\033[0;34m' +NC='\033[0m' # No Color + +echo -e "${BLUE}๐Ÿ”จ Pre-Build Hook${NC}" +echo "======================================" + +# Check for uncommitted changes +if git diff --quiet && git diff --staged --quiet; then + echo -e "${GREEN}โœ“ Working directory clean${NC}" +else + echo -e "${YELLOW}โš  Warning: Uncommitted changes detected${NC}" + git status --short +fi + +# Lint check +echo -e "\n${YELLOW}๐Ÿ” Running lint check...${NC}" +if npx eslint src --ext .ts 2>/dev/null; then + echo -e "${GREEN} โœ“ Linting passed${NC}" +else + echo -e "${RED} โœ— Linting failed${NC}" + echo " Run 'npm run lint:fix' to fix issues" + exit 1 +fi + +# Type validation +echo -e "\n${YELLOW}๐Ÿ“ Running type check...${NC}" +if npx tsc --noEmit; then + echo -e "${GREEN} โœ“ Type checking passed${NC}" +else + echo -e "${RED} โœ— Type checking failed${NC}" + exit 1 +fi + +# Test suite +echo -e "\n${YELLOW}๐Ÿงช Running tests...${NC}" +if npm test 2>/dev/null; then + echo -e "${GREEN} โœ“ All tests passed${NC}" +else + echo -e "${RED} โœ— Tests failed${NC}" + exit 1 +fi + +# Dependency audit +echo -e "\n${YELLOW}๐Ÿ”’ Checking dependencies...${NC}" +AUDIT_RESULT=$(npm audit --production 2>&1) +if echo "$AUDIT_RESULT" | grep -q "found 0 vulnerabilities"; then + echo -e "${GREEN} โœ“ No vulnerabilities found${NC}" +else + echo -e "${YELLOW} โš  Security vulnerabilities detected${NC}" + echo " Run 'npm audit fix' to resolve" +fi + +# Version validation +echo -e "\n${YELLOW}๐Ÿท๏ธ Checking version...${NC}" +PACKAGE_VERSION=$(node -p "require('./package.json').version") +echo " Current version: $PACKAGE_VERSION" + +# Check if version tag exists +if git rev-parse "v$PACKAGE_VERSION" >/dev/null 2>&1; then + echo -e "${GREEN} โœ“ Version tag exists${NC}" +else + echo -e "${YELLOW} โš  Version tag v$PACKAGE_VERSION not found${NC}" + echo " Create with: git tag v$PACKAGE_VERSION" +fi + +# Check package.json required fields +echo -e "\n${YELLOW}๐Ÿ“ฆ Validating package.json...${NC}" +NAME=$(node -p "require('./package.json').name" 2>/dev/null) +DESCRIPTION=$(node -p "require('./package.json').description" 2>/dev/null) +MAIN=$(node -p "require('./package.json').main" 2>/dev/null) + +if [ -z "$NAME" ]; then + echo -e "${RED} โœ— Missing 'name' field${NC}" + exit 1 +fi + +if [ -z "$DESCRIPTION" ]; then + echo -e "${YELLOW} โš  Missing 'description' field${NC}" +fi + +if [ -z "$MAIN" ]; then + echo -e "${YELLOW} โš  Missing 'main' field${NC}" +fi + +echo -e "${GREEN} โœ“ Package metadata valid${NC}" + +# MCP specific checks +echo -e "\n${YELLOW}๐Ÿ”Œ Checking MCP implementation...${NC}" + +# Check for required MCP files +if [ -f "src/index.ts" ]; then + echo -e "${GREEN} โœ“ Entry point exists${NC}" +else + echo -e "${RED} โœ— Missing src/index.ts${NC}" + exit 1 +fi + +# Count capabilities +TOOL_COUNT=0 +RESOURCE_COUNT=0 +PROMPT_COUNT=0 + +if [ -d "src/tools" ]; then + TOOL_COUNT=$(find src/tools -name "*.ts" -not -name "index.ts" | wc -l) +fi + +if [ -d "src/resources" ]; then + RESOURCE_COUNT=$(find src/resources -name "*.ts" -not -name "index.ts" | wc -l) +fi + +if [ -d "src/prompts" ]; then + PROMPT_COUNT=$(find src/prompts -name "*.ts" -not -name "index.ts" | wc -l) +fi + +echo " Capabilities:" +echo " - Tools: $TOOL_COUNT" +echo " - Resources: $RESOURCE_COUNT" +echo " - Prompts: $PROMPT_COUNT" + +if [ $TOOL_COUNT -eq 0 ] && [ $RESOURCE_COUNT -eq 0 ] && [ $PROMPT_COUNT -eq 0 ]; then + echo -e "${YELLOW} โš  No MCP capabilities implemented${NC}" +fi + +# Final summary +echo "" +echo "======================================" +echo -e "${GREEN}โœ… Pre-build checks complete${NC}" +echo "Ready to build for production!" +echo "" +echo "Next steps:" +echo " 1. npm run build" +echo " 2. npm test" +echo " 3. npm publish (if deploying to npm)" -- cgit v1.2.3