#!/bin/sh # Connect your coding agent to Mixpeek. # # curl -fsSL https://mixpeek.com/install | sh # # Adds the hosted Mixpeek MCP server (https://mcp.mixpeek.com/mcp) to every # agent it finds on this machine: Claude Code, Codex, Gemini CLI and Cursor. # It installs no binaries and needs no root. Read it before you run it: # https://mixpeek.com/install # # Your API key comes from MIXPEEK_API_KEY, or the script asks for it. # Create one at https://studio.mixpeek.com/settings/api-keys # # Docs: https://mixpeek.com/docs/agent-integrations/mcp set -eu MCP_URL="${MIXPEEK_MCP_URL:-https://mcp.mixpeek.com/mcp}" NAME="mixpeek" say() { printf '%s\n' "$*"; } ok() { printf ' \033[32m+\033[0m %s\n' "$*"; } skip() { printf ' - %s\n' "$*"; } have() { command -v "$1" >/dev/null 2>&1; } say "" say "Mixpeek: connect your agent" say "" KEY="${MIXPEEK_API_KEY:-}" if [ -z "$KEY" ]; then # Ask on the terminal: stdin is the script itself when piped from curl. # Test by opening the tty, since it can exist and still fail to open. if (exec /dev/null; then say "No MIXPEEK_API_KEY in your environment." say "Create a key at https://studio.mixpeek.com/settings/api-keys, then paste it here." stty -echo /dev/null || true printf 'API key: ' >/dev/tty 2>/dev/null || true IFS= read -r KEY /dev/null || KEY="" stty echo /dev/null || true printf '\n' >/dev/tty 2>/dev/null || true fi fi KEY=$(printf '%s' "$KEY" | tr -d '[:space:]') if [ -z "$KEY" ]; then say "No API key, so nothing was changed." say "Run again with: MIXPEEK_API_KEY=your_key sh -c \"\$(curl -fsSL https://mixpeek.com/install)\"" exit 1 fi AUTH="Authorization: Bearer $KEY" added=0 # Claude Code if have claude; then claude mcp remove --scope user "$NAME" >/dev/null 2>&1 || true if claude mcp add --scope user --transport http "$NAME" "$MCP_URL" --header "$AUTH" >/dev/null 2>&1; then ok "Claude Code (user scope)"; added=$((added + 1)) else skip "Claude Code: 'claude mcp add' failed. Add it by hand: claude mcp add --scope user --transport http $NAME $MCP_URL --header \"Authorization: Bearer \"" fi fi # Gemini CLI if have gemini; then gemini mcp remove --scope user "$NAME" >/dev/null 2>&1 || true if gemini mcp add --scope user --transport http "$NAME" "$MCP_URL" -H "$AUTH" >/dev/null 2>&1; then ok "Gemini CLI (user scope)"; added=$((added + 1)) else skip "Gemini CLI: 'gemini mcp add' failed." fi fi # Codex reads the bearer token from an environment variable, so the key is not # written to its config. MIXPEEK_API_KEY must be set in the shell that runs codex. CODEX_NEEDS_ENV=0 if have codex; then codex mcp remove "$NAME" >/dev/null 2>&1 || true if codex mcp add "$NAME" --url "$MCP_URL" --bearer-token-env-var MIXPEEK_API_KEY >/dev/null 2>&1; then ok "Codex (reads MIXPEEK_API_KEY from your environment)"; added=$((added + 1)); CODEX_NEEDS_ENV=1 else skip "Codex: 'codex mcp add' failed." fi fi # Cursor: merge into ~/.cursor/mcp.json, keeping a backup of the old file. if [ -d "$HOME/.cursor" ]; then if have python3; then if MIXPEEK_KEY="$KEY" MIXPEEK_URL="$MCP_URL" MIXPEEK_NAME="$NAME" python3 - <<'PY' import json, os, shutil p = os.path.expanduser("~/.cursor/mcp.json") cfg = {} if os.path.exists(p): shutil.copyfile(p, p + ".bak") with open(p) as f: txt = f.read().strip() cfg = json.loads(txt) if txt else {} cfg.setdefault("mcpServers", {})[os.environ["MIXPEEK_NAME"]] = { "url": os.environ["MIXPEEK_URL"], "headers": {"Authorization": "Bearer " + os.environ["MIXPEEK_KEY"]}, } with open(p, "w") as f: json.dump(cfg, f, indent=2) f.write("\n") PY then ok "Cursor (~/.cursor/mcp.json; previous file saved as mcp.json.bak)"; added=$((added + 1)) else skip "Cursor: could not update ~/.cursor/mcp.json (is it valid JSON?)" fi else skip "Cursor: python3 not found, so ~/.cursor/mcp.json was left alone." fi fi say "" if [ "$added" -eq 0 ]; then say "No supported agent found (Claude Code, Codex, Gemini CLI, Cursor)." say "Add this MCP server to your agent's config:" say "" say " {\"mcpServers\": {\"$NAME\": {\"url\": \"$MCP_URL\"," say " \"headers\": {\"Authorization\": \"Bearer \"}}}}" say "" say "Docs: https://mixpeek.com/docs/agent-integrations/mcp" exit 0 fi say "Connected $added agent(s) to $MCP_URL." if [ "$CODEX_NEEDS_ENV" -eq 1 ] && [ -z "${MIXPEEK_API_KEY:-}" ]; then say "" say "For Codex, add this to your shell profile: export MIXPEEK_API_KEY=" fi say "" say "Restart your agent, then try:" say " \"Use Mixpeek to list my namespaces\"" say "" say "Docs: https://mixpeek.com/docs/agent-integrations/mcp"