#!/bin/sh # Datapika setup for AI coding agents. # # curl -fsSL https://datapika.com/install.sh | sh # curl -fsSL https://datapika.com/install.sh | sh -s -- --dry-run # # 1. Downloads the Datapika skill (SKILL.md) from # github.com/lnvestor/datapika-examples and writes it to # /datapika/SKILL.md for each agent found in your home folder. # 2. Registers the Datapika MCP server for Claude Code, Cursor and Codex. # # No sudo, no telemetry, nothing outside your home folder. Safe to re-run: # files that are already current are left alone, and any file it changes is # copied to .bak- first. SKILL_URL="https://raw.githubusercontent.com/lnvestor/datapika-examples/main/plugins/datapika/skills/datapika/SKILL.md" MCP_URL="https://mcp.apify.com/?tools=fetch-actor-details,openclawai/job-board-scraper,openclawai/linkedin-jobs-scraper,openclawai/reddit-scraper,openclawai/tiktok-douyin-bilibili-scraper,openclawai/career-site-ats-jobs-scraper,openclawai/airbnb-scraper,openclawai/google-maps-scraper,openclawai/meta-ad-library-scraper,openclawai/google-flights-scraper,openclawai/tiktok-shop-scraper,openclawai/threads-scraper,openclawai/kuaishou-scraper,openclawai/google-ads-transparency-scraper,openclawai/hotel-rental-scraper,openclawai/wechat-scraper,openclawai/indeed-ziprecruiter-scraper,openclawai/youtube-video-scraper,openclawai/trustpilot-reviews-scraper,openclawai/bilibili-scraper,openclawai/influencer-finder,openclawai/b2b-leads-finder" SITE="https://datapika.com" usage() { cat <<'EOF' Datapika setup for AI coding agents Usage: curl -fsSL https://datapika.com/install.sh | sh curl -fsSL https://datapika.com/install.sh | sh -s -- [options] sh install.sh [options] Options: -n, --dry-run Show what would change, change nothing -h, --help Show this help Skill: writes datapika/SKILL.md into the skills folder of each agent found: Claude Code ~/.claude/skills Cursor ~/.cursor/skills Codex ~/.agents/skills (the folder current Codex versions read) Gemini CLI ~/.gemini/skills OpenCode ~/.config/opencode/skills Copilot CLI ~/.copilot/skills Shared ~/.agents/skills MCP server "datapika": Claude Code claude mcp add --scope user --transport http datapika Cursor adds it to ~/.cursor/mcp.json (needs python3, else prints it) Codex adds [mcp_servers.datapika] to ~/.codex/config.toml Changed files are backed up to .bak- first. EOF } say() { printf '%s\n' "$*"; } log() { DONE="$DONE $*" say " $*" } fail() { FAILED=1 DONE="$DONE ! $*" say " ! $*" >&2 } short() { printf '%s' "$1" | sed "s|^$HOME/|~/|"; } backup() { # backup : copy an existing file aside before changing it [ -f "$1" ] || return 0 cp -p "$1" "$1.bak-$STAMP" } fetch() { # fetch if command -v curl >/dev/null 2>&1; then curl -fsSL --retry 2 --connect-timeout 10 --max-time 60 "$1" -o "$2" elif command -v wget >/dev/null 2>&1; then wget -q -T 60 -O "$2" "$1" else echo "Need curl or wget to download the skill." >&2 return 1 fi } has_python() { command -v python3 >/dev/null 2>&1 || return 1 # On a Mac without developer tools /usr/bin/python3 is only an installer stub. if [ "$(command -v python3)" = /usr/bin/python3 ] && [ "$(uname -s)" = Darwin ]; then xcode-select -p >/dev/null 2>&1 || return 1 fi return 0 } merge_cursor_json() { # merge_cursor_json python3 - "$1" "$2" <<'PY' import json, os, sys path, url = sys.argv[1], sys.argv[2] try: data = {} if os.path.exists(path): with open(path, encoding="utf-8") as f: text = f.read() if text.strip(): data = json.loads(text) if not isinstance(data, dict): raise ValueError("top level is not a JSON object") servers = data.setdefault("mcpServers", {}) if not isinstance(servers, dict): raise ValueError("mcpServers is not a JSON object") servers.setdefault("datapika", {"url": url}) tmp = path + ".datapika-tmp" with open(tmp, "w", encoding="utf-8") as f: json.dump(data, f, indent=2) f.write("\n") os.replace(tmp, path) except Exception as exc: sys.stderr.write(" %s\n" % exc) sys.exit(1) PY } install_skill() { say "Skill" TMP_SKILL=$(mktemp 2>/dev/null || mktemp -t datapika) trap 'rm -f "$TMP_SKILL"' EXIT trap 'exit 130' INT TERM if ! fetch "$SKILL_URL" "$TMP_SKILL" || ! head -n 1 "$TMP_SKILL" | grep -q '^---' || ! grep -q '^name: datapika' "$TMP_SKILL"; then fail "Could not download the skill from $SKILL_URL" return fi chmod 644 "$TMP_SKILL" claude_root="$HOME/.claude" [ -n "$CLAUDE_CONFIG_DIR" ] && claude_root="$CLAUDE_CONFIG_DIR" config_root="$HOME/.config" [ -n "$XDG_CONFIG_HOME" ] && config_root="$XDG_CONFIG_HOME" # agent|folder that shows it is installed|its skills folder agents="Claude Code|$claude_root|$claude_root/skills Cursor|$HOME/.cursor|$HOME/.cursor/skills Codex|$CODEX_ROOT|$HOME/.agents/skills Gemini CLI|$HOME/.gemini|$HOME/.gemini/skills OpenCode|$config_root/opencode|$config_root/opencode/skills Copilot CLI|$HOME/.copilot|$HOME/.copilot/skills Shared|$HOME/.agents|$HOME/.agents/skills" found=0 seen=" " old_ifs=$IFS IFS=' ' set -f for row in $agents; do name=$(printf '%s' "$row" | cut -d'|' -f1) root=$(printf '%s' "$row" | cut -d'|' -f2) dir=$(printf '%s' "$row" | cut -d'|' -f3) [ -d "$root" ] || continue found=1 case "$seen" in *" $dir "*) continue ;; *) ;; esac seen="$seen$dir " target="$dir/datapika/SKILL.md" if [ -f "$target" ] && cmp -s "$TMP_SKILL" "$target"; then log "= $name: $(short "$target") is already current" elif [ "$DRY_RUN" = 1 ]; then if [ -f "$target" ]; then log "~ $name: would update $(short "$target") (old copy backed up)" else log "+ $name: would write $(short "$target")" fi else verb="wrote" [ -f "$target" ] && verb="updated" if mkdir -p "$dir/datapika" && backup "$target" && cp "$TMP_SKILL" "$target"; then log "+ $name: $verb $(short "$target")" else fail "$name: could not write $(short "$target")" fi fi done set +f IFS=$old_ifs if [ "$found" = 0 ]; then say " No agent folder found (~/.claude, ~/.cursor, ~/.codex, ~/.gemini," say " ~/.config/opencode, ~/.copilot, ~/.agents). Install your agent, open it" say " once, then run this again." fi } install_mcp() { say "MCP server" mcp_seen=0 # Claude Code: let its own CLI write ~/.claude.json. With no config file # yet nothing is registered, and asking claude would create the file. claude_json="$HOME/.claude.json" [ -n "$CLAUDE_CONFIG_DIR" ] && claude_json="$CLAUDE_CONFIG_DIR/.claude.json" if command -v claude >/dev/null 2>&1; then mcp_seen=1 if [ -f "$claude_json" ] && claude mcp get datapika /dev/null 2>&1; then log "= Claude Code: MCP server \"datapika\" already registered, left as is" elif [ "$DRY_RUN" = 1 ]; then log "+ Claude Code: would run claude mcp add --scope user --transport http datapika " elif claude mcp add --scope user --transport http datapika "$MCP_URL" /dev/null 2>&1; then log "+ Claude Code: added MCP server \"datapika\" (user scope)" else fail "Claude Code: claude mcp add failed. Run it yourself:" say " claude mcp add --scope user --transport http datapika \"$MCP_URL\"" fi elif [ -d "$HOME/.claude" ]; then mcp_seen=1 say " - Claude Code: the claude command is not on PATH. When it is, run:" say " claude mcp add --scope user --transport http datapika \"$MCP_URL\"" fi # Cursor: merge into ~/.cursor/mcp.json and keep every other server. cursor_mcp="$HOME/.cursor/mcp.json" if [ -d "$HOME/.cursor" ]; then mcp_seen=1 if [ -f "$cursor_mcp" ] && grep -q '"datapika"[[:space:]]*:' "$cursor_mcp"; then log "= Cursor: \"datapika\" already in $(short "$cursor_mcp"), left as is" elif ! has_python; then say " - Cursor: python3 not found, so $(short "$cursor_mcp") was not edited." say " Add this inside \"mcpServers\":" say " \"datapika\": { \"url\": \"$MCP_URL\" }" elif [ "$DRY_RUN" = 1 ]; then log "+ Cursor: would add \"datapika\" to $(short "$cursor_mcp")" elif backup "$cursor_mcp" && merge_cursor_json "$cursor_mcp" "$MCP_URL"; then log "+ Cursor: added \"datapika\" to $(short "$cursor_mcp")" else fail "Cursor: could not edit $(short "$cursor_mcp"), left it unchanged. Add this inside \"mcpServers\":" say " \"datapika\": { \"url\": \"$MCP_URL\" }" fi fi # Codex: append a streamable HTTP server block to config.toml. codex_config="$CODEX_ROOT/config.toml" if [ -d "$CODEX_ROOT" ]; then mcp_seen=1 if [ -f "$codex_config" ] && grep -Eq '^[[:space:]]*\[?[[:space:]]*mcp_servers\.("datapika"|datapika)([^A-Za-z0-9_-]|$)' "$codex_config"; then log "= Codex: [mcp_servers.datapika] already in $(short "$codex_config"), left as is" elif [ "$DRY_RUN" = 1 ]; then log "+ Codex: would add [mcp_servers.datapika] to $(short "$codex_config")" elif backup "$codex_config" && printf '\n[mcp_servers.datapika]\nurl = "%s"\n' "$MCP_URL" >>"$codex_config"; then log "+ Codex: added [mcp_servers.datapika] to $(short "$codex_config")" else fail "Codex: could not edit $(short "$codex_config")" fi fi if [ "$mcp_seen" = 0 ]; then say " No Claude Code, Cursor or Codex found. Other clients: add this URL as an" say " HTTP MCP server named datapika:" say " $MCP_URL" fi } main() { DRY_RUN=0 for arg in "$@"; do case "$arg" in -n | --dry-run) DRY_RUN=1 ;; -h | --help) usage; exit 0 ;; *) printf 'Unknown option: %s\n\n' "$arg" >&2; usage >&2; exit 2 ;; esac done if [ -z "$HOME" ] || [ ! -d "$HOME" ]; then echo "HOME is not set to a folder; nothing to do." >&2 exit 1 fi STAMP=$(date +%Y%m%d%H%M%S) FAILED=0 DONE="" CODEX_ROOT="$HOME/.codex" [ -n "$CODEX_HOME" ] && CODEX_ROOT="$CODEX_HOME" if [ "$DRY_RUN" = 1 ]; then say "Datapika setup (dry run: nothing will be changed)" else say "Datapika setup" fi say "" install_skill say "" install_mcp say "" if [ "$DRY_RUN" = 1 ]; then say "Dry run finished. Nothing was changed. Run again without --dry-run to apply." exit "$FAILED" fi if [ -z "$DONE" ]; then say "Nothing to set up here. See $SITE/skills for the manual steps." exit "$FAILED" fi if [ "$FAILED" = 1 ]; then say "Datapika setup finished with errors (marked ! above)." else say "Datapika setup finished." fi say "" say "Next:" say " 1. Restart your agent so it loads the skill and the MCP server." say " 2. Sign in to Apify when your agent first uses a Datapika tool (Claude" say " Code: /mcp; Codex: codex mcp login datapika). A free Apify account" say " works; runs bill per result to that account." say " 3. Ask your agent one of these:" say " - Pull 20 fresh data engineer jobs in Austin from LinkedIn and Indeed." say " - Show this week's top posts in r/dataengineering with their top comments." say " - Get the 50 newest Trustpilot reviews for notion.so and sum up the complaints." say "" say "Docs: $SITE/skills | Prices: $SITE/actors" exit "$FAILED" } # Everything runs from here, so a partly downloaded script does nothing. main "$@"