27 lines
1.1 KiB
Bash
27 lines
1.1 KiB
Bash
#!/usr/bin/env bash
|
|
# Prints a Cursor MCP install deeplink.
|
|
# Usage: scripts/cursor-deeplink.sh <server-name> '<transport-json>'
|
|
# transport-json = {"command":"...","args":[...]}
|
|
set -euo pipefail
|
|
name="${1:-}"
|
|
config="${2:-}"
|
|
if [[ -z "$name" || -z "$config" ]]; then
|
|
echo "Aufruf: scripts/cursor-deeplink.sh <server-name> '<transport-json>'" >&2
|
|
exit 1
|
|
fi
|
|
python3 -c '
|
|
import base64, json, sys, urllib.parse
|
|
name, raw = sys.argv[1], sys.argv[2]
|
|
transport = json.loads(raw)
|
|
# Unwrap { name: transport } if the caller passed it that way.
|
|
if set(transport.keys()) == {name} and isinstance(transport[name], dict):
|
|
transport = transport[name]
|
|
cmd = transport.get("command") or ""
|
|
if len(cmd) >= 3 and cmd[1] == ":" and "\\" in cmd:
|
|
transport = dict(transport)
|
|
transport["command"] = cmd.replace("\\\\", "/").replace("\\", "/")
|
|
# config = transport only; name= is a separate query param.
|
|
b64 = base64.urlsafe_b64encode(json.dumps(transport, separators=(",", ":")).encode("utf-8")).decode("ascii").rstrip("=")
|
|
print(f"cursor://anysphere.cursor-deeplink/mcp/install?name={urllib.parse.quote(name)}&config={b64}")
|
|
' "$name" "$config"
|