summaryrefslogtreecommitdiff
path: root/mcp-servers/token-gated-mcp-server/.claude/hooks/log-mcp-commands.sh
diff options
context:
space:
mode:
authorTheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com>2026-01-16 08:30:14 +0900
committerTheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com>2026-01-16 08:30:14 +0900
commit3fbb9a18372f2b6a675dd6c039ba52be76f3eeb4 (patch)
treeaa694a36cdd323a7853672ee7a2ba60409ac3b06 /mcp-servers/token-gated-mcp-server/.claude/hooks/log-mcp-commands.sh
updates
Diffstat (limited to 'mcp-servers/token-gated-mcp-server/.claude/hooks/log-mcp-commands.sh')
-rwxr-xr-xmcp-servers/token-gated-mcp-server/.claude/hooks/log-mcp-commands.sh83
1 files changed, 83 insertions, 0 deletions
diff --git a/mcp-servers/token-gated-mcp-server/.claude/hooks/log-mcp-commands.sh b/mcp-servers/token-gated-mcp-server/.claude/hooks/log-mcp-commands.sh
new file mode 100755
index 0000000..9b3d09e
--- /dev/null
+++ b/mcp-servers/token-gated-mcp-server/.claude/hooks/log-mcp-commands.sh
@@ -0,0 +1,83 @@
+#!/bin/bash
+
+# Hook script to log MCP-related commands for debugging
+# Used in PreToolUse hooks for Bash tool
+
+# Parse the command from input
+command=$(echo "$CLAUDE_HOOK_DATA" | jq -r '.tool_input.command // empty')
+description=$(echo "$CLAUDE_HOOK_DATA" | jq -r '.tool_input.description // "No description"')
+
+# Exit if no command
+if [ -z "$command" ]; then
+ exit 0
+fi
+
+# Create log directory if it doesn't exist
+LOG_DIR="$HOME/.claude/logs"
+mkdir -p "$LOG_DIR"
+
+# Log file with date
+LOG_FILE="$LOG_DIR/token-gate-$(date +%Y%m%d).log"
+
+# Timestamp for log entry
+timestamp=$(date '+%Y-%m-%d %H:%M:%S')
+
+# Log FastMCP commands
+if [[ "$command" == *"fastmcp"* ]]; then
+ echo "[$timestamp] FastMCP: $command - $description" >> "$LOG_FILE"
+ echo "🚀 Running FastMCP command..."
+
+ # Provide helpful hints
+ if [[ "$command" == *"dev"* ]]; then
+ echo "💡 Tip: Use 'npx fastmcp inspect' for visual debugging"
+ fi
+fi
+
+# Log ngrok commands
+if [[ "$command" == *"ngrok"* ]]; then
+ echo "[$timestamp] ngrok: $command" >> "$LOG_FILE"
+ echo "🌐 Setting up ngrok tunnel..."
+ echo "💡 Remember to use the HTTPS URL with /mcp endpoint in claude.ai"
+fi
+
+# Log npm/node commands related to MCP
+if [[ "$command" == *"npm"* ]] || [[ "$command" == *"node"* ]] || [[ "$command" == *"tsx"* ]]; then
+ if [[ "$command" == *"radius"* ]] || [[ "$command" == *"mcp"* ]] || [[ "$command" == *"server"* ]]; then
+ echo "[$timestamp] MCP Server: $command" >> "$LOG_FILE"
+ fi
+fi
+
+# Log token configuration checks
+if [[ "$command" == *"EVMAUTH"* ]] || [[ "$command" == *"echo"* ]]; then
+ if [[ "$command" == *"CONTRACT"* ]] || [[ "$command" == *"CHAIN"* ]] || [[ "$command" == *"TOKEN"* ]]; then
+ echo "[$timestamp] Config Check: $command" >> "$LOG_FILE"
+ echo "🔍 Checking token configuration..."
+ fi
+fi
+
+# Log RPC tests
+if [[ "$command" == *"curl"* ]] && [[ "$command" == *"rpc"* ]]; then
+ echo "[$timestamp] RPC Test: $command" >> "$LOG_FILE"
+ echo "🔗 Testing RPC connection..."
+fi
+
+# Security check - warn about potentially dangerous commands
+if [[ "$command" == *"rm -rf"* ]] || [[ "$command" == *"sudo rm"* ]]; then
+ echo "⚠️ DANGER: Destructive command detected!"
+ echo "[$timestamp] BLOCKED: $command" >> "$LOG_FILE"
+ exit 2 # Block the command
+fi
+
+# Warn about npm publish in development
+if [[ "$command" == *"npm publish"* ]]; then
+ echo "⚠️ WARNING: About to publish to npm registry!"
+ echo " Ensure version is updated and changes are committed"
+ echo "[$timestamp] NPM Publish: $command" >> "$LOG_FILE"
+
+ if [ "$NODE_ENV" != "production" ]; then
+ echo "❌ Blocking npm publish in non-production environment"
+ exit 2
+ fi
+fi
+
+exit 0 \ No newline at end of file