Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 67 additions & 0 deletions setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2112,6 +2112,72 @@ setup_seo_mcps() {
return 0
}

# Setup Google Analytics MCP (disabled by default)
setup_google_analytics_mcp() {
print_info "Setting up Google Analytics MCP..."

local opencode_config="$HOME/.config/opencode/opencode.json"

# Check if opencode.json exists
if [[ ! -f "$opencode_config" ]]; then
print_warning "OpenCode config not found at $opencode_config - skipping Google Analytics MCP"
return 0
fi

# Check if jq is available
if ! command -v jq &> /dev/null; then
print_warning "jq not found - cannot add Google Analytics MCP to config"
print_info "Install jq and re-run setup, or manually add the MCP config"
return 0
fi

# Check if pipx is available
if ! command -v pipx &> /dev/null; then
print_warning "pipx not found - Google Analytics MCP requires pipx"
print_info "Install pipx: brew install pipx (macOS) or pip install pipx"
print_info "Then re-run setup to add Google Analytics MCP"
return 0
fi

# Check if google-analytics-mcp already exists in config
if jq -e '.mcp["google-analytics-mcp"]' "$opencode_config" > /dev/null 2>&1; then
print_info "Google Analytics MCP already configured in OpenCode"
return 0
fi

# Add google-analytics-mcp to opencode.json (disabled by default)
local tmp_config
tmp_config=$(mktemp)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This flow overwrites opencode.json but doesn’t create a backup first; since other steps (e.g., update_opencode_config) do, it may be worth aligning here to reduce the risk of user config loss if something goes wrong.

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎


if jq '.mcp["google-analytics-mcp"] = {
"type": "local",
"command": ["pipx", "run", "analytics-mcp"],
"environment": {
"GOOGLE_APPLICATION_CREDENTIALS": "",
"GOOGLE_PROJECT_ID": ""
},
"enabled": false
}' "$opencode_config" > "$tmp_config" 2>/dev/null; then
Comment on lines +2152 to +2160

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The current jq command will fail if the .mcp key does not exist in opencode.json. To make the script more robust, you should ensure that the .mcp object exists before trying to add a property to it. You can use the //= operator in jq to create it if it's missing.

Suggested change
if jq '.mcp["google-analytics-mcp"] = {
"type": "local",
"command": ["pipx", "run", "analytics-mcp"],
"environment": {
"GOOGLE_APPLICATION_CREDENTIALS": "",
"GOOGLE_PROJECT_ID": ""
},
"enabled": false
}' "$opencode_config" > "$tmp_config" 2>/dev/null; then
if jq '(.mcp //= {})["google-analytics-mcp"] = {
"type": "local",
"command": ["pipx", "run", "analytics-mcp"],
"environment": {
"GOOGLE_APPLICATION_CREDENTIALS": "",
"GOOGLE_PROJECT_ID": ""
},
"enabled": false
}' "$opencode_config" > "$tmp_config" 2>/dev/null; then

mv "$tmp_config" "$opencode_config"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mv "$tmp_config" "$opencode_config" isn’t checked for success before printing the "Added" message; if the move fails (permissions, disk, etc.), the user could get a false success signal and be left with a stray temp file.

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎

print_success "Added Google Analytics MCP to OpenCode (disabled by default)"
print_info "To enable: Set credentials and change enabled to true in opencode.json"
print_info "Or use the google-analytics subagent which enables it automatically"
else
rm -f "$tmp_config"
print_warning "Failed to add Google Analytics MCP to config"
fi

# Show setup instructions
print_info "Google Analytics MCP setup:"
print_info " 1. Enable Google Analytics Admin & Data APIs in Google Cloud Console"
print_info " 2. Configure ADC: gcloud auth application-default login --scopes https://www.googleapis.com/auth/analytics.readonly,https://www.googleapis.com/auth/cloud-platform"
print_info " 3. Update GOOGLE_APPLICATION_CREDENTIALS path in opencode.json"
print_info " 4. Set GOOGLE_PROJECT_ID in opencode.json"
print_info "Documentation: ~/.aidevops/agents/services/analytics/google-analytics.md"

return 0
}

# Check for tool updates after setup
check_tool_updates() {
print_info "Checking for tool updates..."
Expand Down Expand Up @@ -2262,6 +2328,7 @@ main() {
confirm_step "Setup osgrep (local semantic search)" && setup_osgrep
confirm_step "Setup Beads task management" && setup_beads
confirm_step "Setup SEO MCP servers (DataForSEO, Serper)" && setup_seo_mcps
confirm_step "Setup Google Analytics MCP" && setup_google_analytics_mcp
confirm_step "Setup browser automation tools" && setup_browser_tools
confirm_step "Setup AI orchestration frameworks info" && setup_ai_orchestration
confirm_step "Setup OpenCode plugins" && setup_opencode_plugins
Expand Down
Loading