#!/usr/bin/env bash
# ==============================================================================
# MCP Config Forge Deterministic Installer : Context7 Up-to-Date Library Docs MCP Server (@upstash/context7-mcp)
# Generated by https://neatjar.com/mcp-forge/mcp-config/context7
# ==============================================================================
set -euo pipefail

echo "[1/3] Writing Cursor MCP configuration (.cursor/mcp.json)..."
mkdir -p .cursor
cat << 'EOF_CURSOR' > .cursor/mcp.json
{
  "mcpServers": {
    "context7": {
      "command": "npx",
      "args": [
        "-y",
        "@upstash/context7-mcp@latest"
      ],
      "env": {
        "CONTEXT7_API_KEY": "ctx7sk_optional_higher_rate_limit_key"
      }
    }
  }
}
EOF_CURSOR

echo "[2/3] Writing VS Code Copilot MCP configuration (.vscode/mcp.json)..."
mkdir -p .vscode
cat << 'EOF_VSCODE' > .vscode/mcp.json
{
  "servers": {
    "context7": {
      "type": "stdio",
      "command": "npx",
      "args": [
        "-y",
        "@upstash/context7-mcp@latest"
      ],
      "env": {
        "CONTEXT7_API_KEY": "ctx7sk_optional_higher_rate_limit_key"
      }
    }
  }
}
EOF_VSCODE

echo "[3/3] Claude Code CLI registration command ready:"
echo "  claude mcp add context7 -e CONTEXT7_API_KEY="ctx7sk_optional_higher_rate_limit_key" -- npx -y @upstash/context7-mcp@latest"
echo "Done! Verify your server at https://neatjar.com/mcp-forge/mcp-config/context7"
