{
    "tailapp": 2,
    "manifest": {
        "format": 2,
        "app_id": "mcp-servers",
        "name": "MCP Servers",
        "version": 1,
        "schema": "tailapps/v0",
        "exported_at": 1796033856,
        "from": "gallery",
        "connections": [],
        "files": {
            "app.json": "57e181616fccbb244d028b4584a97e9942f6b9b2ad98d224cc41e0d47a872f0d"
        },
        "signature": "1/J0XuIzfByn7Ky4ghC7u0/Xfca85zQCxF0BuAmDp3CIDf0bdJb8Lo9jK18Hy/1/J5/dWGtL75GAiKB5gayaCA==",
        "key_id": "gallery-1"
    },
    "app": {
        "schema": "tailapps/v0",
        "app": "mcp-servers",
        "name": "MCP Servers",
        "description": "Every MCP server in your AI apps in one list: test one and see its tools, switch it off without deleting it, add from the MCP Registry, and see your skills. Mac only.",
        "icon": "server.rack",
        "version": 1,
        "permissions": [
            "script:scan.sh",
            "script:codex.sh",
            "script:stamp.sh",
            "script:test.sh",
            "script:toggle.sh",
            "script:install.sh",
            "script:skills.sh",
            "script:skill-switch.sh",
            "net:registry.modelcontextprotocol.io",
            "files.write:claude_code",
            "files.write:claude_desktop",
            "files.write:cursor",
            "files.write:vscode",
            "files.write:windsurf",
            "files.write:gemini",
            "files.write:codex",
            "files.write:claude_skills",
            "files.write:codex_skills"
        ],
        "settings": {
            "claude_code": {
                "type": "file",
                "label": "Claude Code (~/.claude.json)",
                "default": "~/.claude.json"
            },
            "claude_desktop": {
                "type": "file",
                "label": "Claude Desktop",
                "default": "~/Library/Application Support/Claude/claude_desktop_config.json"
            },
            "cursor": {
                "type": "file",
                "label": "Cursor (~/.cursor/mcp.json)",
                "default": "~/.cursor/mcp.json"
            },
            "vscode": {
                "type": "file",
                "label": "VS Code (User/mcp.json)",
                "default": "~/Library/Application Support/Code/User/mcp.json"
            },
            "windsurf": {
                "type": "file",
                "label": "Windsurf (mcp_config.json)",
                "default": "~/.codeium/windsurf/mcp_config.json"
            },
            "gemini": {
                "type": "file",
                "label": "Gemini CLI (~/.gemini/settings.json)",
                "default": "~/.gemini/settings.json"
            },
            "codex": {
                "type": "file",
                "label": "Codex (~/.codex/config.toml)",
                "default": "~/.codex/config.toml"
            },
            "claude_skills": {
                "type": "folder",
                "label": "Claude Code skills folder",
                "default": "~/.claude/skills"
            },
            "codex_skills": {
                "type": "folder",
                "label": "Codex skills folder",
                "default": "~/.codex/skills"
            }
        },
        "state": {
            "servers": {
                "type": "list",
                "default": []
            },
            "names": {
                "type": "list",
                "default": []
            },
            "apps": {
                "type": "list",
                "default": []
            },
            "tested": {
                "type": "list",
                "default": []
            },
            "query": {
                "type": "text",
                "default": ""
            },
            "results": {
                "type": "list",
                "default": []
            },
            "install_to": {
                "type": "list",
                "default": []
            }
        },
        "sources": {
            "stamp": {
                "script": "stamp.sh",
                "args": [
                    "$settings.claude_code",
                    "$settings.claude_desktop",
                    "$settings.cursor",
                    "$settings.vscode",
                    "$settings.windsurf",
                    "$settings.gemini",
                    "$settings.codex",
                    "$settings.claude_skills",
                    "$settings.codex_skills"
                ],
                "parse": "text",
                "every": 20,
                "on": "open",
                "on_change": "scan"
            },
            "skills": {
                "script": "skills.sh",
                "args": [
                    "$settings.claude_code",
                    "$settings.claude_desktop",
                    "$settings.cursor",
                    "$settings.vscode",
                    "$settings.windsurf",
                    "$settings.gemini",
                    "$settings.codex",
                    "$settings.claude_skills",
                    "$settings.codex_skills"
                ],
                "every": 120,
                "on": "open"
            }
        },
        "actions": {
            "scan": {
                "steps": [
                    {
                        "script": "codex.sh",
                        "args": [
                            "$settings.claude_code",
                            "$settings.claude_desktop",
                            "$settings.cursor",
                            "$settings.vscode",
                            "$settings.windsurf",
                            "$settings.gemini",
                            "$settings.codex",
                            "$settings.claude_skills",
                            "$settings.codex_skills"
                        ],
                        "as": "codex",
                        "parse": "text"
                    },
                    {
                        "script": "scan.sh",
                        "args": [
                            "$settings.claude_code",
                            "$settings.claude_desktop",
                            "$settings.cursor",
                            "$settings.vscode",
                            "$settings.windsurf",
                            "$settings.gemini",
                            "$settings.codex",
                            "$settings.claude_skills",
                            "$settings.codex_skills",
                            "$codex | parse:'toml' | pick:'mcp_servers'"
                        ],
                        "as": "out"
                    },
                    {
                        "set": {
                            "servers": "$out.servers",
                            "apps": "$out.apps",
                            "names": "$out.names"
                        }
                    }
                ]
            },
            "open_server": {
                "args": {
                    "name": "text"
                },
                "steps": [
                    {
                        "open_card": "server",
                        "args": {
                            "name": "$args.name"
                        }
                    }
                ]
            },
            "test": {
                "args": {
                    "id": "text"
                },
                "steps": [
                    {
                        "script": "codex.sh",
                        "args": [
                            "$settings.claude_code",
                            "$settings.claude_desktop",
                            "$settings.cursor",
                            "$settings.vscode",
                            "$settings.windsurf",
                            "$settings.gemini",
                            "$settings.codex",
                            "$settings.claude_skills",
                            "$settings.codex_skills"
                        ],
                        "as": "codex",
                        "parse": "text"
                    },
                    {
                        "script": "test.sh",
                        "args": [
                            "$settings.claude_code",
                            "$settings.claude_desktop",
                            "$settings.cursor",
                            "$settings.vscode",
                            "$settings.windsurf",
                            "$settings.gemini",
                            "$settings.codex",
                            "$settings.claude_skills",
                            "$settings.codex_skills",
                            "$args.id",
                            "$codex | parse:'toml' | pick:'mcp_servers'"
                        ],
                        "as": "result",
                        "timeout": 150
                    },
                    {
                        "push": {
                            "tested": "$result"
                        },
                        "max": 30
                    },
                    {
                        "if": "$result.ok",
                        "then": [
                            {
                                "toast": "{$result.tools | count} tools"
                            }
                        ],
                        "else": [
                            {
                                "toast": "Didn't connect"
                            }
                        ]
                    }
                ],
                "timeout": 160
            },
            "switch": {
                "args": {
                    "id": "text",
                    "on": "bool"
                },
                "steps": [
                    {
                        "script": "toggle.sh",
                        "args": [
                            "$settings.claude_code",
                            "$settings.claude_desktop",
                            "$settings.cursor",
                            "$settings.vscode",
                            "$settings.windsurf",
                            "$settings.gemini",
                            "$settings.codex",
                            "$settings.claude_skills",
                            "$settings.codex_skills",
                            "$args.id",
                            "$args.on",
                            "$servers | where:'id':$args.id | pick:0"
                        ]
                    },
                    {
                        "refresh": "stamp"
                    },
                    {
                        "toast": {
                            "text": "{$args.on | map:{true:'Switched on', else:'Switched off'}} in {$servers | where:'id':$args.id | pick:0 | pick:'app_name'}",
                            "undo": "switch",
                            "args": {
                                "id": "$args.id",
                                "on": "$args.on | map:{true:false, else:true}"
                            }
                        }
                    }
                ]
            },
            "search": {
                "steps": [
                    {
                        "fetch": "https://registry.modelcontextprotocol.io/v0.1/servers?search={$query | url}&limit=40&version=latest",
                        "as": "res"
                    },
                    {
                        "set": {
                            "results": "$res.servers | pluck:'server'"
                        }
                    }
                ]
            },
            "open_install": {
                "args": {
                    "name": "text"
                },
                "steps": [
                    {
                        "set": {
                            "install_to": "$apps | where:'picked' | pluck:'id'"
                        }
                    },
                    {
                        "open_card": "install",
                        "args": {
                            "name": "$args.name"
                        }
                    }
                ]
            },
            "install": {
                "args": {
                    "name": "text"
                },
                "steps": [
                    {
                        "if": "$results | where:'name':$args.name | pick:0 | pick:'packages' | pick:0 | pick:'environmentVariables' | pluck:'name'",
                        "then": [
                            {
                                "ask": {
                                    "title": "Keys for {$args.name}",
                                    "message": "NAME=value, separated by ; (header NAME=value for a hosted server's headers). They go only into the AI apps' own files.",
                                    "input": "text",
                                    "default": "{$results | where:'name':$args.name | pick:0 | pick:'packages' | pick:0 | pick:'environmentVariables' | pluck:'name' | wrap:'':'=' | join:'; '}"
                                },
                                "as": "keys"
                            },
                            {
                                "script": "install.sh",
                                "args": [
                                    "$settings.claude_code",
                                    "$settings.claude_desktop",
                                    "$settings.cursor",
                                    "$settings.vscode",
                                    "$settings.windsurf",
                                    "$settings.gemini",
                                    "$settings.codex",
                                    "$settings.claude_skills",
                                    "$settings.codex_skills",
                                    "$results | where:'name':$args.name | pick:0",
                                    "$install_to",
                                    "$keys"
                                ],
                                "as": "done"
                            },
                            {
                                "refresh": "stamp"
                            },
                            {
                                "if": "$done.installed | count",
                                "then": [
                                    {
                                        "toast": "Added {$done.name} to {$done.installed | join}"
                                    },
                                    {
                                        "close_card": true
                                    }
                                ],
                                "else": [
                                    {
                                        "toast": "Not added: {$done.skipped | pick:0 | pick:'why'}"
                                    }
                                ]
                            }
                        ],
                        "else": [
                            {
                                "if": "$results | where:'name':$args.name | pick:0 | pick:'remotes' | pick:0 | pick:'headers' | pluck:'name'",
                                "then": [
                                    {
                                        "ask": {
                                            "title": "Keys for {$args.name}",
                                            "message": "NAME=value, separated by ; (header NAME=value for a hosted server's headers). They go only into the AI apps' own files.",
                                            "input": "text",
                                            "default": "{$results | where:'name':$args.name | pick:0 | pick:'remotes' | pick:0 | pick:'headers' | pluck:'name' | wrap:'header ':'=' | join:'; '}"
                                        },
                                        "as": "keys"
                                    },
                                    {
                                        "script": "install.sh",
                                        "args": [
                                            "$settings.claude_code",
                                            "$settings.claude_desktop",
                                            "$settings.cursor",
                                            "$settings.vscode",
                                            "$settings.windsurf",
                                            "$settings.gemini",
                                            "$settings.codex",
                                            "$settings.claude_skills",
                                            "$settings.codex_skills",
                                            "$results | where:'name':$args.name | pick:0",
                                            "$install_to",
                                            "$keys"
                                        ],
                                        "as": "done"
                                    },
                                    {
                                        "refresh": "stamp"
                                    },
                                    {
                                        "if": "$done.installed | count",
                                        "then": [
                                            {
                                                "toast": "Added {$done.name} to {$done.installed | join}"
                                            },
                                            {
                                                "close_card": true
                                            }
                                        ],
                                        "else": [
                                            {
                                                "toast": "Not added: {$done.skipped | pick:0 | pick:'why'}"
                                            }
                                        ]
                                    }
                                ],
                                "else": [
                                    {
                                        "script": "install.sh",
                                        "args": [
                                            "$settings.claude_code",
                                            "$settings.claude_desktop",
                                            "$settings.cursor",
                                            "$settings.vscode",
                                            "$settings.windsurf",
                                            "$settings.gemini",
                                            "$settings.codex",
                                            "$settings.claude_skills",
                                            "$settings.codex_skills",
                                            "$results | where:'name':$args.name | pick:0",
                                            "$install_to",
                                            ""
                                        ],
                                        "as": "done"
                                    },
                                    {
                                        "refresh": "stamp"
                                    },
                                    {
                                        "if": "$done.installed | count",
                                        "then": [
                                            {
                                                "toast": "Added {$done.name} to {$done.installed | join}"
                                            },
                                            {
                                                "close_card": true
                                            }
                                        ],
                                        "else": [
                                            {
                                                "toast": "Not added: {$done.skipped | pick:0 | pick:'why'}"
                                            }
                                        ]
                                    }
                                ]
                            }
                        ]
                    }
                ]
            },
            "open_skill": {
                "args": {
                    "id": "text"
                },
                "steps": [
                    {
                        "open_card": "skill",
                        "args": {
                            "id": "$args.id"
                        }
                    }
                ]
            },
            "switch_skill": {
                "args": {
                    "id": "text",
                    "on": "bool"
                },
                "steps": [
                    {
                        "script": "skill-switch.sh",
                        "args": [
                            "$settings.claude_code",
                            "$settings.claude_desktop",
                            "$settings.cursor",
                            "$settings.vscode",
                            "$settings.windsurf",
                            "$settings.gemini",
                            "$settings.codex",
                            "$settings.claude_skills",
                            "$settings.codex_skills",
                            "$args.id",
                            "$args.on"
                        ]
                    },
                    {
                        "refresh": "skills"
                    },
                    {
                        "toast": {
                            "text": "{$args.on | map:{true:'Skill switched on', else:'Skill switched off'}}",
                            "undo": "switch_skill",
                            "args": {
                                "id": "$args.id",
                                "on": "$args.on | map:{true:false, else:true}"
                            }
                        }
                    }
                ]
            }
        },
        "cards": [
            {
                "id": "main",
                "layout": {
                    "tabs": [
                        {
                            "label": "Servers",
                            "icon": "server.rack",
                            "count": "$names | count",
                            "children": [
                                {
                                    "list": "$names",
                                    "empty": "No MCP servers found in your AI apps yet. Add one from the Registry tab.",
                                    "item": {
                                        "cell": "$item.name",
                                        "subtitle": "{$item.apps | join}{$item.on | map:{0:' \u00b7 off', else:''}}",
                                        "leading": {
                                            "icon": "$item.kind | map:{stdio:'terminal', else:'globe'}",
                                            "hue": "$item.kind | map:{stdio:'blue', else:'teal'}"
                                        },
                                        "status": "$item.on | tone:{good:'>0', else:'neutral'}",
                                        "count": "$item.total",
                                        "accessory": "chevron",
                                        "on": "open_server",
                                        "args": {
                                            "name": "$item.name"
                                        }
                                    }
                                },
                                {
                                    "section": "AI apps",
                                    "collapsible": true,
                                    "collapsed": true,
                                    "children": [
                                        {
                                            "list": "$apps",
                                            "item": {
                                                "cell": "$item.name",
                                                "subtitle": "{$item.path}{$item.found | map:{true:'', else:' \u00b7 not found'}}{$item.picked | map:{true:'', else:' \u00b7 read only'}}{$item.error | map:{null:'', else:' \u00b7 read only: not plain JSON'}}",
                                                "status": "$item.found | map:{true:'good', else:'neutral'}",
                                                "count": "$item.count"
                                            }
                                        },
                                        {
                                            "text": "To switch servers off or add them, choose each app's file with the gear. Until then the card only reads it.",
                                            "size": "s",
                                            "emphasis": "subtle"
                                        }
                                    ]
                                }
                            ]
                        },
                        {
                            "label": "Skills",
                            "icon": "sparkles",
                            "count": "$skills | count",
                            "children": [
                                {
                                    "list": "$skills",
                                    "empty": "No skills found in ~/.claude/skills, ~/.codex/skills or your Claude Code plugins.",
                                    "item": {
                                        "cell": "$item.name",
                                        "subtitle": "{$item.agent}{$item.on | map:{true:'', else:' \u00b7 off'}} \u00b7 {$item.description | truncate:90}",
                                        "leading": {
                                            "icon": "sparkles",
                                            "hue": "$item.agent | hue"
                                        },
                                        "status": "$item.on | map:{true:'good', else:'neutral'}",
                                        "accessory": "chevron",
                                        "on": "open_skill",
                                        "args": {
                                            "id": "$item.id"
                                        }
                                    }
                                }
                            ]
                        },
                        {
                            "label": "Add",
                            "icon": "plus",
                            "children": [
                                {
                                    "field": "Search the MCP Registry",
                                    "type": "search",
                                    "bind": "$query",
                                    "placeholder": "github, postgres, figma\u2026",
                                    "on_submit": "search"
                                },
                                {
                                    "list": "$results",
                                    "empty": "Type a name and press Return to search the public MCP Registry.",
                                    "item": {
                                        "cell": "{$item.title | default:$item.name}",
                                        "subtitle": "$item.description | truncate:110",
                                        "leading": {
                                            "icon": "$item.remotes | count | map:{0:'shippingbox', else:'globe'}",
                                            "hue": "$item.remotes | count | map:{0:'blue', else:'teal'}"
                                        },
                                        "accessory": "chevron",
                                        "on": "open_install",
                                        "args": {
                                            "name": "$item.name"
                                        }
                                    }
                                }
                            ]
                        }
                    ]
                },
                "footer": {
                    "row": [
                        {
                            "text": "{$servers | where:'on' | count} on \u00b7 {$servers | count} in {$apps | where:'found' | count} apps",
                            "size": "s",
                            "emphasis": "subtle",
                            "grow": true
                        },
                        {
                            "button": "Read again",
                            "icon": "arrow.clockwise",
                            "icon_only": true,
                            "style": "plain",
                            "on": "scan",
                            "disabled": "$running.scan"
                        }
                    ],
                    "align": "center"
                }
            },
            {
                "id": "server",
                "params": {
                    "name": "text"
                },
                "layout": {
                    "column": [
                        {
                            "text": "$params.name",
                            "size": "l",
                            "emphasis": "strong"
                        },
                        {
                            "text": "{$servers | where:'name':$params.name | pick:0 | pick:'summary'}",
                            "mono": true,
                            "size": "s",
                            "lines": 2
                        },
                        {
                            "list": "$servers | where:'name':$params.name",
                            "item": {
                                "cell": "$item.app_name",
                                "subtitle": "{$item.scope_label}{$item.on | map:{true:'', else:' \u00b7 switched off'}}{$item.env | count | map:{0:'', else:' \u00b7 env '}}{$item.env | join}",
                                "status": "$item.on | map:{true:'good', else:'neutral'}",
                                "trailing": {
                                    "button": "$item.on | map:{true:'Switch off', else:'Switch on'}",
                                    "style": "plain",
                                    "on": "switch",
                                    "args": {
                                        "id": "$item.id",
                                        "on": "$item.on | map:{true:false, else:true}"
                                    },
                                    "disabled": "$running.switch"
                                }
                            }
                        },
                        {
                            "row": [
                                {
                                    "button": "Test",
                                    "icon": "bolt.horizontal",
                                    "style": "primary",
                                    "on": "test",
                                    "args": {
                                        "id": "{$servers | where:'name':$params.name | where:'on' | pick:0 | pick:'id' | default:'none'}"
                                    },
                                    "disabled": "$running.test"
                                },
                                {
                                    "badge": "{$tested | where:'name':$params.name | pick:0 | pick:'ok' | map:{true:'Connected', false:'Failed', else:'Not tested'}}",
                                    "tone": "$tested | where:'name':$params.name | pick:0 | pick:'ok' | map:{true:'good', false:'bad', else:'neutral'}",
                                    "busy": "$running.test"
                                },
                                {
                                    "spacer": true
                                }
                            ],
                            "align": "center"
                        },
                        {
                            "text": "{$tested | where:'name':$params.name | pick:0 | pick:'error'}",
                            "tone": "bad",
                            "size": "s",
                            "when": "$tested | where:'name':$params.name | pick:0 | pick:'error'"
                        },
                        {
                            "section": "Tools",
                            "trailing": {
                                "badge": "{$tested | where:'name':$params.name | pick:0 | pick:'tools' | count}"
                            },
                            "when": "$tested | where:'name':$params.name | pick:0 | pick:'ok'",
                            "children": [
                                {
                                    "list": "$tested | where:'name':$params.name | pick:0 | pick:'tools'",
                                    "empty": "It has no tools",
                                    "item": {
                                        "cell": "$item.name",
                                        "subtitle": "$item.description | truncate:140"
                                    }
                                }
                            ]
                        }
                    ],
                    "gap": "m"
                }
            },
            {
                "id": "install",
                "params": {
                    "name": "text"
                },
                "layout": {
                    "column": [
                        {
                            "text": "{$results | where:'name':$params.name | pick:0 | pick:'title' | default:$params.name}",
                            "size": "l",
                            "emphasis": "strong"
                        },
                        {
                            "text": "{$results | where:'name':$params.name | pick:0 | pick:'description'}",
                            "size": "s",
                            "emphasis": "subtle"
                        },
                        {
                            "text": "$params.name",
                            "mono": true,
                            "size": "s"
                        },
                        {
                            "list": "$results | where:'name':$params.name | pick:0 | pick:'packages' | pick:0 | pick:'environmentVariables'",
                            "item": {
                                "cell": "$item.name",
                                "subtitle": "$item.description | default:''",
                                "status": "$item.isRequired | map:{true:'warn', else:'neutral'}"
                            }
                        },
                        {
                            "text": "Add it to",
                            "size": "s",
                            "emphasis": "strong"
                        },
                        {
                            "checklist": "$apps | where:'found'",
                            "label": "{$item.name}{$item.picked | map:{true:'', else:' (choose its file first)'}}",
                            "value": "$item.id",
                            "bind": "$install_to"
                        },
                        {
                            "row": [
                                {
                                    "button": "Add",
                                    "icon": "plus",
                                    "style": "primary",
                                    "on": "install",
                                    "args": {
                                        "name": "$params.name"
                                    },
                                    "disabled": "$running.install"
                                },
                                {
                                    "spacer": true
                                }
                            ],
                            "align": "center"
                        },
                        {
                            "text": "Add asks for its keys, which go only into the AI apps' own files. A backup of each file is kept first.",
                            "size": "s",
                            "emphasis": "subtle"
                        }
                    ],
                    "gap": "m"
                }
            },
            {
                "id": "skill",
                "params": {
                    "id": "text"
                },
                "layout": {
                    "column": [
                        {
                            "text": "{$skills | where:'id':$params.id | pick:0 | pick:'name'}",
                            "size": "l",
                            "emphasis": "strong"
                        },
                        {
                            "text": "{$skills | where:'id':$params.id | pick:0 | pick:'agent'} \u00b7 {$skills | where:'id':$params.id | pick:0 | pick:'on' | map:{true:'on', else:'off'}}",
                            "size": "s",
                            "emphasis": "subtle"
                        },
                        {
                            "text": "{$skills | where:'id':$params.id | pick:0 | pick:'description'}"
                        },
                        {
                            "button": "{$skills | where:'id':$params.id | pick:0 | pick:'on' | map:{true:'Switch off', else:'Switch on'}}",
                            "on": "switch_skill",
                            "args": {
                                "id": "$params.id",
                                "on": "$skills | where:'id':$params.id | pick:0 | pick:'on' | map:{true:false, else:true}"
                            },
                            "when": "$skills | where:'id':$params.id | pick:0 | pick:'can_switch'",
                            "disabled": "$running.switch_skill"
                        },
                        {
                            "text": "To switch skills, choose the skills folder with the gear.",
                            "size": "s",
                            "emphasis": "subtle",
                            "when": "$skills | where:'id':$params.id | pick:0 | pick:'can_switch' | map:{true:false, else:true}"
                        },
                        {
                            "code": "$skills | where:'id':$params.id | pick:0 | pick:'body'",
                            "wrap": true,
                            "lines": 18
                        },
                        {
                            "text": "$skills | where:'id':$params.id | pick:0 | pick:'path'",
                            "mono": true,
                            "size": "s",
                            "emphasis": "subtle"
                        }
                    ],
                    "gap": "m"
                }
            }
        ],
        "views": {
            "menubar": {
                "icon": "server.rack",
                "label": "{$servers | where:'on' | count}",
                "card": "main"
            },
            "floating": {
                "card": "main",
                "width": "wide"
            }
        },
        "scripts": {
            "scan.sh": "#!/bin/sh\n# Args 1-9: the files and folders picked in the card's settings (empty when not picked). A picked one may be changed;\n# otherwise the card reads where each AI app keeps it, and changes nothing there.\nP_claude_code=$1 P_claude_desktop=$2 P_cursor=$3 P_vscode=$4 P_windsurf=$5 P_gemini=$6 P_codex=$7 P_claude_skills=$8 P_codex_skills=$9\nshift 9\nAS=\"$HOME/Library/Application Support\"\nAPPS=\"claude_code claude_desktop cursor vscode windsurf gemini codex\"\npicked() {\n  case \"$1\" in\n    claude_code) printf '%s' \"$P_claude_code\" ;; claude_desktop) printf '%s' \"$P_claude_desktop\" ;; cursor) printf '%s' \"$P_cursor\" ;;\n    vscode) printf '%s' \"$P_vscode\" ;; windsurf) printf '%s' \"$P_windsurf\" ;; gemini) printf '%s' \"$P_gemini\" ;; codex) printf '%s' \"$P_codex\" ;;\n    claude_skills) printf '%s' \"$P_claude_skills\" ;; codex_skills) printf '%s' \"$P_codex_skills\" ;;\n  esac\n}\ndefault_of() {\n  case \"$1\" in\n    claude_code) printf '%s' \"$HOME/.claude.json\" ;;\n    claude_desktop) printf '%s' \"$AS/Claude/claude_desktop_config.json\" ;;\n    cursor) printf '%s' \"$HOME/.cursor/mcp.json\" ;;\n    vscode) printf '%s' \"$AS/Code/User/mcp.json\" ;;\n    windsurf) printf '%s' \"$HOME/.codeium/windsurf/mcp_config.json\" ;;\n    gemini) printf '%s' \"$HOME/.gemini/settings.json\" ;;\n    codex) printf '%s' \"$HOME/.codex/config.toml\" ;;\n    claude_skills) printf '%s' \"$HOME/.claude/skills\" ;;\n    codex_skills) printf '%s' \"$HOME/.codex/skills\" ;;\n  esac\n}\nfile_of() { p=$(picked \"$1\"); [ -n \"$p\" ] && printf '%s' \"$p\" || default_of \"$1\"; }\nname_of() {\n  case \"$1\" in\n    claude_code) echo \"Claude Code\" ;; claude_desktop) echo \"Claude Desktop\" ;; cursor) echo \"Cursor\" ;;\n    vscode) echo \"VS Code\" ;; windsurf) echo \"Windsurf\" ;; gemini) echo \"Gemini CLI\" ;; codex) echo \"Codex\" ;;\n  esac\n}\n# Where an app keeps its servers inside its JSON file, as a jq path.\nbase_of() {\n  case \"$1\" in\n    claude_code) case \"$2\" in local:*) jq -cn --arg p \"${2#local:}\" '[\"projects\", $p, \"mcpServers\"]' ;; *) echo '[\"mcpServers\"]' ;; esac ;;\n    vscode) echo '[\"servers\"]' ;;\n    *) echo '[\"mcpServers\"]' ;;\n  esac\n}\nfail() { printf '%s\\n' \"$*\" >&2; exit 1; }\n# The card's own folder (tmp/<card>/): switched-off servers and backups live here, never in the card's state.\nOWN=$(dirname \"${TMPDIR%/}\")\nPARKED=\"$OWN/parked.json\"\n[ -f \"$PARKED\" ] || { umask 077; echo '[]' > \"$PARKED\"; }\n# A file may only be changed when the person picked it in settings.\nwritable_of() {\n  p=$(picked \"$1\")\n  [ -n \"$p\" ] || fail \"To change $(name_of \"$1\")'s servers, choose its file in this card's settings (the gear): $(default_of \"$1\" | sed \"s|^$HOME|~|\")\"\n  [ -f \"$p\" ] || fail \"$(name_of \"$1\")'s file isn't there any more: $p\"\n  printf '%s' \"$p\"\n}\n# A copy of the file before each change, the newest 30 kept.\nbackup() {\n  mkdir -p \"$OWN/backups\" && chmod 700 \"$OWN/backups\"\n  b=\"$OWN/backups/$2-$(date +%Y%m%d-%H%M%S)-$$.bak\"\n  cp -p \"$1\" \"$b\" || fail \"Couldn't back up $1\"\n  ls -t \"$OWN/backups\"/*.bak 2>/dev/null | tail -n +31 | while IFS= read -r old; do rm -f \"$old\"; done\n}\n# The file's modification time and size, taken before reading it (seen) and checked again just before writing\n# (unchanged), so a change the AI app made meanwhile isn't written over.\nstamp_of() { stat -c '%.9Y %s' \"$1\" 2>/dev/null || stat -f '%Fm %z' \"$1\" 2>/dev/null; }\nseen() { SEEN=$(stamp_of \"$1\"); }\nunchanged() { [ -z \"$SEEN\" ] || [ \"$(stamp_of \"$1\")\" = \"$SEEN\" ]; }\n# Write new text over a file in place (keeps its permissions; the sandbox allows only the picked file itself).\nreplace() {\n  [ -s \"$2\" ] || fail \"Nothing to write\"\n  unchanged \"$1\" || fail \"$1 changed while this ran, so nothing was written. Try again\"\n  cat \"$2\" > \"$1\" || fail \"Couldn't write $1\"\n}\n\n# Every MCP server in the AI apps' config files, as { apps, servers, names }. Values of env vars and headers never\n# leave this script (only their names), and arguments or URLs that look like keys are masked.\n# Arg 1: Codex's [mcp_servers] tables, as JSON (the card reads config.toml with parse:'toml').\ncodex=${1:-null}\n[ \"$codex\" = \"\" ] && codex=null\nout=\"$TMPDIR/servers.jsonl\"\napps=\"$TMPDIR/apps.jsonl\"\n: > \"$out\"; : > \"$apps\"\nNORM='\ndef mask_url: if . == null then null else\n  sub(\"://[^/@\\\\s]+@\"; \"://\u2022\u2022\u2022@\") | sub(\"(?<p>[?&][^=&]*(key|token|secret|auth)[^=&]*=)[^&]*\"; \"\\(.p)\u2022\u2022\u2022\"; \"gi\") end;\ndef mask_args: . as $a | [range(length) as $i | ($a[$i] | tostring) as $x | ($i > 0 and true | if . then ($a[$i-1] | tostring) else \"\" end) as $prev\n  | if ($prev | test(\"^(-H|--header|--headers)$\")) then (if ($x | test(\":\")) then ($x | sub(\":.*$\"; \": \u2022\u2022\u2022\")) else \"\u2022\u2022\u2022\" end)\n    elif ($prev | test(\"(?i)^-{1,2}[a-z_-]*(key|token|secret|password|auth)\")) then \"\u2022\u2022\u2022\"\n    elif ($x | test(\"^[A-Za-z][A-Za-z0-9+.-]*://\")) then ($x | mask_url)\n    elif ($x | test(\"(?i)bearer\\\\s\")) then ($x | sub(\"(?i)(?<b>bearer)\\\\s.*$\"; \"\\(.b) \u2022\u2022\u2022\"))\n    elif ($x | test(\"(?i)(key|token|secret|password)[^=]*=\")) then ($x | sub(\"=.*$\"; \"=\u2022\u2022\u2022\"))\n    elif ($x | test(\"^(sk|ghp|gho|ghs|github_pat|xox[a-z]|pk|rk)[-_][A-Za-z0-9_-]{12,}\")) then \"\u2022\u2022\u2022\"\n    else ($x | mask_url) end];\ndef one($app; $appname; $scope; $label):\n  if type != \"object\" then empty else to_entries[] | select(.value | type == \"object\") | .value as $v | ($v.url // $v.serverUrl // $v.httpUrl) as $url | {\n    id: ($app + \":\" + $scope + \":\" + .key), name: .key, app: $app, app_name: $appname, scope: $scope, scope_label: $label,\n    kind: (if $url then (if ($v.type == \"sse\" or $v.transport == \"sse\") then \"sse\" else \"http\" end) else \"stdio\" end),\n    command: ($v.command // null), args: (($v.args // []) | if type == \"array\" then mask_args else [] end), url: ($url | mask_url),\n    env: (($v.env // {}) | if type == \"object\" then keys else [] end),\n    headers: (($v.headers // $v.http_headers // {}) | if type == \"object\" then keys else [] end),\n    on: ($v.disabled != true and $v.enabled != false)\n  } | .summary = (if .kind == \"stdio\" then ([.command // \"\"] + .args | join(\" \")) else .url end)\n  end;'\nfor a in $APPS; do\n  f=$(file_of \"$a\"); p=$(picked \"$a\"); n=$(name_of \"$a\")\n  err=\"\"\n  if [ ! -f \"$f\" ]; then found=false\n  elif [ \"$a\" = codex ]; then\n    found=true\n    [ \"$codex\" = null ] && grep -q '^[[:space:]]*\\[mcp_servers' \"$f\" && err=\"Its config.toml couldn't be read as TOML\"\n    printf '%s' \"$codex\" | jq -c --arg app \"$a\" --arg appname \"$n\" \"$NORM one(\\$app; \\$appname; \\\"user\\\"; \\\"User\\\")\" >> \"$out\" 2>/dev/null\n  else\n    found=true\n    if ! jq -c --arg app \"$a\" --arg appname \"$n\" \"$NORM\"'\n      if $app == \"claude_code\" then\n        ((.mcpServers // {}) | one($app; $appname; \"user\"; \"User\")),\n        ((.projects // {}) | to_entries[] | .key as $p | (.value.mcpServers // {}) | one($app; $appname; \"local:\" + $p; ($p | split(\"/\") | last)))\n      elif $app == \"vscode\" then (.servers // {}) | one($app; $appname; \"user\"; \"User\")\n      else (.mcpServers // {}) | one($app; $appname; \"user\"; \"User\") end' \"$f\" >> \"$out\" 2>/dev/null; then\n      err=\"Has comments or isn't plain JSON, so it's shown as empty and left alone\"\n    fi\n  fi\n  jq -cn --arg id \"$a\" --arg name \"$n\" --arg path \"$(printf '%s' \"$f\" | sed \"s|^$HOME|~|\")\" --argjson found \"$found\" \\\n    --argjson picked \"$([ -n \"$p\" ] && echo true || echo false)\" --arg error \"$err\" \\\n    '{ id: $id, name: $name, path: $path, found: $found, picked: $picked, error: (if $error == \"\" then null else $error end) }' >> \"$apps\"\ndone\n# Servers switched off here: kept in the card's own folder, shown with on: false.\njq -c '.[] | .info + { on: false, parked: true }' \"$PARKED\" >> \"$out\" 2>/dev/null\njq -n --slurpfile s \"$out\" --slurpfile a \"$apps\" '\n  ($s | sort_by(.name | ascii_downcase)) as $servers\n  | { servers: $servers,\n      apps: ($a | map(.id as $id | . + { count: ([$servers[] | select(.app == $id)] | length) })),\n      names: ($servers | group_by(.name | ascii_downcase) | map({\n        name: .[0].name, kind: .[0].kind, summary: .[0].summary,\n        apps: (map(.app_name) | unique), on: (map(select(.on)) | length), total: length })) }'\n",
            "codex.sh": "#!/bin/sh\n# Args 1-9: the files and folders picked in the card's settings (empty when not picked). A picked one may be changed;\n# otherwise the card reads where each AI app keeps it, and changes nothing there.\nP_claude_code=$1 P_claude_desktop=$2 P_cursor=$3 P_vscode=$4 P_windsurf=$5 P_gemini=$6 P_codex=$7 P_claude_skills=$8 P_codex_skills=$9\nshift 9\nAS=\"$HOME/Library/Application Support\"\nAPPS=\"claude_code claude_desktop cursor vscode windsurf gemini codex\"\npicked() {\n  case \"$1\" in\n    claude_code) printf '%s' \"$P_claude_code\" ;; claude_desktop) printf '%s' \"$P_claude_desktop\" ;; cursor) printf '%s' \"$P_cursor\" ;;\n    vscode) printf '%s' \"$P_vscode\" ;; windsurf) printf '%s' \"$P_windsurf\" ;; gemini) printf '%s' \"$P_gemini\" ;; codex) printf '%s' \"$P_codex\" ;;\n    claude_skills) printf '%s' \"$P_claude_skills\" ;; codex_skills) printf '%s' \"$P_codex_skills\" ;;\n  esac\n}\ndefault_of() {\n  case \"$1\" in\n    claude_code) printf '%s' \"$HOME/.claude.json\" ;;\n    claude_desktop) printf '%s' \"$AS/Claude/claude_desktop_config.json\" ;;\n    cursor) printf '%s' \"$HOME/.cursor/mcp.json\" ;;\n    vscode) printf '%s' \"$AS/Code/User/mcp.json\" ;;\n    windsurf) printf '%s' \"$HOME/.codeium/windsurf/mcp_config.json\" ;;\n    gemini) printf '%s' \"$HOME/.gemini/settings.json\" ;;\n    codex) printf '%s' \"$HOME/.codex/config.toml\" ;;\n    claude_skills) printf '%s' \"$HOME/.claude/skills\" ;;\n    codex_skills) printf '%s' \"$HOME/.codex/skills\" ;;\n  esac\n}\nfile_of() { p=$(picked \"$1\"); [ -n \"$p\" ] && printf '%s' \"$p\" || default_of \"$1\"; }\nname_of() {\n  case \"$1\" in\n    claude_code) echo \"Claude Code\" ;; claude_desktop) echo \"Claude Desktop\" ;; cursor) echo \"Cursor\" ;;\n    vscode) echo \"VS Code\" ;; windsurf) echo \"Windsurf\" ;; gemini) echo \"Gemini CLI\" ;; codex) echo \"Codex\" ;;\n  esac\n}\n# Where an app keeps its servers inside its JSON file, as a jq path.\nbase_of() {\n  case \"$1\" in\n    claude_code) case \"$2\" in local:*) jq -cn --arg p \"${2#local:}\" '[\"projects\", $p, \"mcpServers\"]' ;; *) echo '[\"mcpServers\"]' ;; esac ;;\n    vscode) echo '[\"servers\"]' ;;\n    *) echo '[\"mcpServers\"]' ;;\n  esac\n}\nfail() { printf '%s\\n' \"$*\" >&2; exit 1; }\n# The card's own folder (tmp/<card>/): switched-off servers and backups live here, never in the card's state.\nOWN=$(dirname \"${TMPDIR%/}\")\nPARKED=\"$OWN/parked.json\"\n[ -f \"$PARKED\" ] || { umask 077; echo '[]' > \"$PARKED\"; }\n# A file may only be changed when the person picked it in settings.\nwritable_of() {\n  p=$(picked \"$1\")\n  [ -n \"$p\" ] || fail \"To change $(name_of \"$1\")'s servers, choose its file in this card's settings (the gear): $(default_of \"$1\" | sed \"s|^$HOME|~|\")\"\n  [ -f \"$p\" ] || fail \"$(name_of \"$1\")'s file isn't there any more: $p\"\n  printf '%s' \"$p\"\n}\n# A copy of the file before each change, the newest 30 kept.\nbackup() {\n  mkdir -p \"$OWN/backups\" && chmod 700 \"$OWN/backups\"\n  b=\"$OWN/backups/$2-$(date +%Y%m%d-%H%M%S)-$$.bak\"\n  cp -p \"$1\" \"$b\" || fail \"Couldn't back up $1\"\n  ls -t \"$OWN/backups\"/*.bak 2>/dev/null | tail -n +31 | while IFS= read -r old; do rm -f \"$old\"; done\n}\n# The file's modification time and size, taken before reading it (seen) and checked again just before writing\n# (unchanged), so a change the AI app made meanwhile isn't written over.\nstamp_of() { stat -c '%.9Y %s' \"$1\" 2>/dev/null || stat -f '%Fm %z' \"$1\" 2>/dev/null; }\nseen() { SEEN=$(stamp_of \"$1\"); }\nunchanged() { [ -z \"$SEEN\" ] || [ \"$(stamp_of \"$1\")\" = \"$SEEN\" ]; }\n# Write new text over a file in place (keeps its permissions; the sandbox allows only the picked file itself).\nreplace() {\n  [ -s \"$2\" ] || fail \"Nothing to write\"\n  unchanged \"$1\" || fail \"$1 changed while this ran, so nothing was written. Try again\"\n  cat \"$2\" > \"$1\" || fail \"Couldn't write $1\"\n}\n\n# Codex's config.toml as text, for parse:'toml' (only inside the scan action, never kept in the card's state).\nf=$(file_of codex)\n[ -f \"$f\" ] && cat \"$f\"\nexit 0\n",
            "stamp.sh": "#!/bin/sh\n# Args 1-9: the files and folders picked in the card's settings (empty when not picked). A picked one may be changed;\n# otherwise the card reads where each AI app keeps it, and changes nothing there.\nP_claude_code=$1 P_claude_desktop=$2 P_cursor=$3 P_vscode=$4 P_windsurf=$5 P_gemini=$6 P_codex=$7 P_claude_skills=$8 P_codex_skills=$9\nshift 9\nAS=\"$HOME/Library/Application Support\"\nAPPS=\"claude_code claude_desktop cursor vscode windsurf gemini codex\"\npicked() {\n  case \"$1\" in\n    claude_code) printf '%s' \"$P_claude_code\" ;; claude_desktop) printf '%s' \"$P_claude_desktop\" ;; cursor) printf '%s' \"$P_cursor\" ;;\n    vscode) printf '%s' \"$P_vscode\" ;; windsurf) printf '%s' \"$P_windsurf\" ;; gemini) printf '%s' \"$P_gemini\" ;; codex) printf '%s' \"$P_codex\" ;;\n    claude_skills) printf '%s' \"$P_claude_skills\" ;; codex_skills) printf '%s' \"$P_codex_skills\" ;;\n  esac\n}\ndefault_of() {\n  case \"$1\" in\n    claude_code) printf '%s' \"$HOME/.claude.json\" ;;\n    claude_desktop) printf '%s' \"$AS/Claude/claude_desktop_config.json\" ;;\n    cursor) printf '%s' \"$HOME/.cursor/mcp.json\" ;;\n    vscode) printf '%s' \"$AS/Code/User/mcp.json\" ;;\n    windsurf) printf '%s' \"$HOME/.codeium/windsurf/mcp_config.json\" ;;\n    gemini) printf '%s' \"$HOME/.gemini/settings.json\" ;;\n    codex) printf '%s' \"$HOME/.codex/config.toml\" ;;\n    claude_skills) printf '%s' \"$HOME/.claude/skills\" ;;\n    codex_skills) printf '%s' \"$HOME/.codex/skills\" ;;\n  esac\n}\nfile_of() { p=$(picked \"$1\"); [ -n \"$p\" ] && printf '%s' \"$p\" || default_of \"$1\"; }\nname_of() {\n  case \"$1\" in\n    claude_code) echo \"Claude Code\" ;; claude_desktop) echo \"Claude Desktop\" ;; cursor) echo \"Cursor\" ;;\n    vscode) echo \"VS Code\" ;; windsurf) echo \"Windsurf\" ;; gemini) echo \"Gemini CLI\" ;; codex) echo \"Codex\" ;;\n  esac\n}\n# Where an app keeps its servers inside its JSON file, as a jq path.\nbase_of() {\n  case \"$1\" in\n    claude_code) case \"$2\" in local:*) jq -cn --arg p \"${2#local:}\" '[\"projects\", $p, \"mcpServers\"]' ;; *) echo '[\"mcpServers\"]' ;; esac ;;\n    vscode) echo '[\"servers\"]' ;;\n    *) echo '[\"mcpServers\"]' ;;\n  esac\n}\nfail() { printf '%s\\n' \"$*\" >&2; exit 1; }\n# The card's own folder (tmp/<card>/): switched-off servers and backups live here, never in the card's state.\nOWN=$(dirname \"${TMPDIR%/}\")\nPARKED=\"$OWN/parked.json\"\n[ -f \"$PARKED\" ] || { umask 077; echo '[]' > \"$PARKED\"; }\n# A file may only be changed when the person picked it in settings.\nwritable_of() {\n  p=$(picked \"$1\")\n  [ -n \"$p\" ] || fail \"To change $(name_of \"$1\")'s servers, choose its file in this card's settings (the gear): $(default_of \"$1\" | sed \"s|^$HOME|~|\")\"\n  [ -f \"$p\" ] || fail \"$(name_of \"$1\")'s file isn't there any more: $p\"\n  printf '%s' \"$p\"\n}\n# A copy of the file before each change, the newest 30 kept.\nbackup() {\n  mkdir -p \"$OWN/backups\" && chmod 700 \"$OWN/backups\"\n  b=\"$OWN/backups/$2-$(date +%Y%m%d-%H%M%S)-$$.bak\"\n  cp -p \"$1\" \"$b\" || fail \"Couldn't back up $1\"\n  ls -t \"$OWN/backups\"/*.bak 2>/dev/null | tail -n +31 | while IFS= read -r old; do rm -f \"$old\"; done\n}\n# The file's modification time and size, taken before reading it (seen) and checked again just before writing\n# (unchanged), so a change the AI app made meanwhile isn't written over.\nstamp_of() { stat -c '%.9Y %s' \"$1\" 2>/dev/null || stat -f '%Fm %z' \"$1\" 2>/dev/null; }\nseen() { SEEN=$(stamp_of \"$1\"); }\nunchanged() { [ -z \"$SEEN\" ] || [ \"$(stamp_of \"$1\")\" = \"$SEEN\" ]; }\n# Write new text over a file in place (keeps its permissions; the sandbox allows only the picked file itself).\nreplace() {\n  [ -s \"$2\" ] || fail \"Nothing to write\"\n  unchanged \"$1\" || fail \"$1 changed while this ran, so nothing was written. Try again\"\n  cat \"$2\" > \"$1\" || fail \"Couldn't write $1\"\n}\n\n# When each config file last changed (and the card's own switched-off list), so the card reads them again only then.\nfor a in $APPS; do f=$(file_of \"$a\"); [ -f \"$f\" ] && stat -f '%m' \"$f\" 2>/dev/null || echo 0; done | tr '\\n' '-'\nstat -f '%m' \"$PARKED\" 2>/dev/null || echo 0\n",
            "test.sh": "#!/bin/sh\n# Args 1-9: the files and folders picked in the card's settings (empty when not picked). A picked one may be changed;\n# otherwise the card reads where each AI app keeps it, and changes nothing there.\nP_claude_code=$1 P_claude_desktop=$2 P_cursor=$3 P_vscode=$4 P_windsurf=$5 P_gemini=$6 P_codex=$7 P_claude_skills=$8 P_codex_skills=$9\nshift 9\nAS=\"$HOME/Library/Application Support\"\nAPPS=\"claude_code claude_desktop cursor vscode windsurf gemini codex\"\npicked() {\n  case \"$1\" in\n    claude_code) printf '%s' \"$P_claude_code\" ;; claude_desktop) printf '%s' \"$P_claude_desktop\" ;; cursor) printf '%s' \"$P_cursor\" ;;\n    vscode) printf '%s' \"$P_vscode\" ;; windsurf) printf '%s' \"$P_windsurf\" ;; gemini) printf '%s' \"$P_gemini\" ;; codex) printf '%s' \"$P_codex\" ;;\n    claude_skills) printf '%s' \"$P_claude_skills\" ;; codex_skills) printf '%s' \"$P_codex_skills\" ;;\n  esac\n}\ndefault_of() {\n  case \"$1\" in\n    claude_code) printf '%s' \"$HOME/.claude.json\" ;;\n    claude_desktop) printf '%s' \"$AS/Claude/claude_desktop_config.json\" ;;\n    cursor) printf '%s' \"$HOME/.cursor/mcp.json\" ;;\n    vscode) printf '%s' \"$AS/Code/User/mcp.json\" ;;\n    windsurf) printf '%s' \"$HOME/.codeium/windsurf/mcp_config.json\" ;;\n    gemini) printf '%s' \"$HOME/.gemini/settings.json\" ;;\n    codex) printf '%s' \"$HOME/.codex/config.toml\" ;;\n    claude_skills) printf '%s' \"$HOME/.claude/skills\" ;;\n    codex_skills) printf '%s' \"$HOME/.codex/skills\" ;;\n  esac\n}\nfile_of() { p=$(picked \"$1\"); [ -n \"$p\" ] && printf '%s' \"$p\" || default_of \"$1\"; }\nname_of() {\n  case \"$1\" in\n    claude_code) echo \"Claude Code\" ;; claude_desktop) echo \"Claude Desktop\" ;; cursor) echo \"Cursor\" ;;\n    vscode) echo \"VS Code\" ;; windsurf) echo \"Windsurf\" ;; gemini) echo \"Gemini CLI\" ;; codex) echo \"Codex\" ;;\n  esac\n}\n# Where an app keeps its servers inside its JSON file, as a jq path.\nbase_of() {\n  case \"$1\" in\n    claude_code) case \"$2\" in local:*) jq -cn --arg p \"${2#local:}\" '[\"projects\", $p, \"mcpServers\"]' ;; *) echo '[\"mcpServers\"]' ;; esac ;;\n    vscode) echo '[\"servers\"]' ;;\n    *) echo '[\"mcpServers\"]' ;;\n  esac\n}\nfail() { printf '%s\\n' \"$*\" >&2; exit 1; }\n# The card's own folder (tmp/<card>/): switched-off servers and backups live here, never in the card's state.\nOWN=$(dirname \"${TMPDIR%/}\")\nPARKED=\"$OWN/parked.json\"\n[ -f \"$PARKED\" ] || { umask 077; echo '[]' > \"$PARKED\"; }\n# A file may only be changed when the person picked it in settings.\nwritable_of() {\n  p=$(picked \"$1\")\n  [ -n \"$p\" ] || fail \"To change $(name_of \"$1\")'s servers, choose its file in this card's settings (the gear): $(default_of \"$1\" | sed \"s|^$HOME|~|\")\"\n  [ -f \"$p\" ] || fail \"$(name_of \"$1\")'s file isn't there any more: $p\"\n  printf '%s' \"$p\"\n}\n# A copy of the file before each change, the newest 30 kept.\nbackup() {\n  mkdir -p \"$OWN/backups\" && chmod 700 \"$OWN/backups\"\n  b=\"$OWN/backups/$2-$(date +%Y%m%d-%H%M%S)-$$.bak\"\n  cp -p \"$1\" \"$b\" || fail \"Couldn't back up $1\"\n  ls -t \"$OWN/backups\"/*.bak 2>/dev/null | tail -n +31 | while IFS= read -r old; do rm -f \"$old\"; done\n}\n# The file's modification time and size, taken before reading it (seen) and checked again just before writing\n# (unchanged), so a change the AI app made meanwhile isn't written over.\nstamp_of() { stat -c '%.9Y %s' \"$1\" 2>/dev/null || stat -f '%Fm %z' \"$1\" 2>/dev/null; }\nseen() { SEEN=$(stamp_of \"$1\"); }\nunchanged() { [ -z \"$SEEN\" ] || [ \"$(stamp_of \"$1\")\" = \"$SEEN\" ]; }\n# Write new text over a file in place (keeps its permissions; the sandbox allows only the picked file itself).\nreplace() {\n  [ -s \"$2\" ] || fail \"Nothing to write\"\n  unchanged \"$1\" || fail \"$1 changed while this ran, so nothing was written. Try again\"\n  cat \"$2\" > \"$1\" || fail \"Couldn't write $1\"\n}\n\n# Connect to one server the way an AI app does (MCP's initialize, then tools/list) and print\n# { id, name, ok, took (seconds), server, tools: [{ name, description }], error }.\n# Args: id, then Codex's [mcp_servers] as JSON (from parse:'toml').\nid=$1 codex=${2:-null}\n[ \"$codex\" = \"\" ] && codex=null\na=${id%%:*}; rest=${id#*:}; name=${id##*:}; scope=${rest%:*}\nf=$(file_of \"$a\")\nstarted=$(date +%s)\nentry=null\nresult() { # ok error tools server\n  # A server's own error text may repeat a key it was given: the entry's env and header values never leave this script.\n  jq -cn --arg id \"$id\" --arg name \"$name\" --argjson ok \"$1\" --arg error \"$2\" --argjson tools \"${3:-[]}\" --argjson server \"${4:-null}\" \\\n    --argjson took \"$(( $(date +%s) - started ))\" --argjson entry \"${entry:-null}\" \\\n    '([($entry // {}) | (.env, .headers, .http_headers) | objects | .[] | tostring | select(length >= 4)]) as $secrets\n     | (reduce $secrets[] as $v ($error; split($v) | join(\"\u2022\u2022\u2022\"))) as $error\n     | { id: $id, name: $name, ok: $ok, took: $took, at: now, server: $server, tools: $tools, error: (if $error == \"\" then null else $error end) }'\n  exit 0\n}\nentry=$(jq -c --arg id \"$id\" 'map(select(.id == $id)) | .[0].entry // null' \"$PARKED\")\nif [ \"$entry\" = null ]; then\n  if [ \"$a\" = codex ]; then\n    entry=$(printf '%s' \"$codex\" | jq -c --arg n \"$name\" '.[$n] // null')\n  else\n    [ -f \"$f\" ] || result false \"$(name_of \"$a\")'s file isn't there\"\n    entry=$(jq -c --argjson b \"$(base_of \"$a\" \"$scope\")\" --arg n \"$name\" 'getpath($b + [$n])' \"$f\" 2>/dev/null)\n  fi\nfi\n[ -n \"$entry\" ] && [ \"$entry\" != null ] || result false \"Couldn't find $name's settings (a switched-off Codex server is tested once it's on)\"\nget() { printf '%s' \"$entry\" | jq -r \"$1\"; }\nurl=$(get '.url // .serverUrl // .httpUrl // empty')\nINIT='{\"jsonrpc\":\"2.0\",\"id\":1,\"method\":\"initialize\",\"params\":{\"protocolVersion\":\"2025-06-18\",\"capabilities\":{},\"clientInfo\":{\"name\":\"tailapps-mcp-check\",\"version\":\"1.0\"}}}'\nREADY='{\"jsonrpc\":\"2.0\",\"method\":\"notifications/initialized\"}'\nlist() { printf '{\"jsonrpc\":\"2.0\",\"id\":%s,\"method\":\"tools/list\"%s}' \"$1\" \"$([ -n \"$2\" ] && printf ',\"params\":{\"cursor\":%s}' \"$(jq -cn --arg c \"$2\" '$c')\")\"; }\n# The answer with this id among the lines a server wrote (partial lines are skipped).\nanswer() { jq -cR --argjson id \"$1\" 'fromjson? | select(type == \"object\" and .id == $id)' \"$2\" 2>/dev/null | head -n 1; }\ntools=\"$TMPDIR/tools.jsonl\"; : > \"$tools\"\n\nif [ -n \"$url\" ]; then\n  [ \"$(get '.type // .transport // empty')\" = sse ] && result false \"This server uses the older SSE kind, which the check doesn't speak yet\"\n  set --\n  for k in $(get '(.headers // .http_headers // {}) | keys[]' | tr '\\n' ' '); do\n    set -- \"$@\" -H \"$k: $(printf '%s' \"$entry\" | jq -r --arg k \"$k\" '(.headers // .http_headers)[$k] | tostring')\"\n  done\n  post() { # body -> response body in $TMPDIR/body, headers in $TMPDIR/h\n    code=$(curl -sS -m 30 -o \"$TMPDIR/body\" -D \"$TMPDIR/h\" -w '%{http_code}' -H 'Content-Type: application/json' \\\n      -H 'Accept: application/json, text/event-stream' -H 'MCP-Protocol-Version: 2025-06-18' \\\n      ${session:+-H \"Mcp-Session-Id: $session\"} \"$@\" --data-binary \"$body\" \"$url\" 2>\"$TMPDIR/err\") || result false \"Couldn't reach it: $(tail -n 1 \"$TMPDIR/err\")\"\n    case \"$code\" in 2*) ;; 401|403) result false \"It needs a sign-in (status $code). Sign in from your AI app; this check can't\" ;; *) result false \"It answered with status $code\" ;; esac\n    # Streamed answers come as `data:` lines.\n    sed -n 's/^data: *//p' \"$TMPDIR/body\" > \"$TMPDIR/events\"\n    [ -s \"$TMPDIR/events\" ] && cat \"$TMPDIR/events\" > \"$TMPDIR/body\"\n    tr -d '\\r' < \"$TMPDIR/body\" > \"$TMPDIR/b2\" && echo >> \"$TMPDIR/b2\"\n  }\n  session=\"\"\n  body=$INIT; post \"$@\"\n  init=$(answer 1 \"$TMPDIR/b2\")\n  session=$(tr -d '\\r' < \"$TMPDIR/h\" | awk 'tolower($1) == \"mcp-session-id:\" { print $2 }' | tail -n 1)\n  body=$READY; curl -sS -m 10 -o /dev/null -H 'Content-Type: application/json' -H 'Accept: application/json, text/event-stream' \\\n    ${session:+-H \"Mcp-Session-Id: $session\"} \"$@\" --data-binary \"$body\" \"$url\" 2>/dev/null\n  cursor=\"\"; i=2\n  while [ $i -le 6 ]; do\n    body=$(list $i \"$cursor\"); post \"$@\"\n    page=$(answer $i \"$TMPDIR/b2\")\n    [ -n \"$page\" ] || break\n    printf '%s' \"$page\" | jq -c '.result.tools[]? | { name, description: (.description // \"\" | .[0:300]) }' >> \"$tools\"\n    cursor=$(printf '%s' \"$page\" | jq -r '.result.nextCursor // empty')\n    [ -n \"$cursor\" ] || break\n    i=$((i + 1))\n  done\nelse\n  cmd=$(get '.command // empty')\n  [ -n \"$cmd\" ] || result false \"It has neither a command nor a URL\"\n  # The places people's tools live, which a Mac app's own PATH leaves out (nvm, Volta, Bun, uv, Cargo, \u2026).\n  for d in \"$HOME/.volta/bin\" \"$HOME/.bun/bin\" \"$HOME/.cargo/bin\" \"$HOME/.local/bin\" \"$HOME/.deno/bin\" \"$HOME/.nvm/versions/node\"/*/bin; do\n    [ -d \"$d\" ] && PATH=\"$PATH:$d\"\n  done\n  export PATH\n  # Arguments and env exactly as the app passes them, each one whole (no shell in between).\n  set --\n  count=$(get '(.env // {}) | length')\n  i=0; while [ \"$i\" -lt \"$count\" ]; do set -- \"$@\" \"$(printf '%s' \"$entry\" | jq -r --argjson i \"$i\" '.env | to_entries[$i] | \"\\(.key)=\\(.value)\"')\"; i=$((i + 1)); done\n  set -- \"$@\" \"$cmd\"\n  count=$(get '(.args // []) | length')\n  i=0; while [ \"$i\" -lt \"$count\" ]; do set -- \"$@\" \"$(printf '%s' \"$entry\" | jq -r --argjson i \"$i\" '.args[$i] | tostring')\"; i=$((i + 1)); done\n  cwd=$(get '.cwd // empty'); [ -n \"$cwd\" ] && [ -d \"$cwd\" ] && cd \"$cwd\"\n  rm -f \"$TMPDIR/in\"; mkfifo \"$TMPDIR/in\" || result false \"Couldn't start it\"\n  # Its own process group, so stopping it also stops what it started (npx runs node).\n  set -m 2>/dev/null\n  /usr/bin/env \"$@\" < \"$TMPDIR/in\" > \"$TMPDIR/out\" 2> \"$TMPDIR/err\" &\n  pid=$!\n  exec 3> \"$TMPDIR/in\"\n  stop() { exec 3>&-; sleep 0.3; kill -TERM -\"$pid\" 2>/dev/null || kill -TERM \"$pid\" 2>/dev/null; }\n  # Still running (an exited child stays a zombie until reaped, which kill -0 can't tell apart).\n  alive() { st=$(ps -o stat= -p \"$pid\" 2>/dev/null); case \"$st\" in ''|Z*) return 1 ;; esac; }\n  # Waits up to 90 s for an answer (the first run of npx or uvx downloads the server).\n  wait_for() {\n    w=0\n    while [ $w -lt 450 ]; do\n      got=$(answer \"$1\" \"$TMPDIR/out\"); [ -n \"$got\" ] && { printf '%s' \"$got\"; return 0; }\n      alive || return 1\n      sleep 0.2; w=$((w + 1))\n    done\n    return 1\n  }\n  printf '%s\\n' \"$INIT\" >&3\n  init=$(wait_for 1) || {\n    e=$(tail -n 3 \"$TMPDIR/err\" | tr '\\n' ' '); stop\n    # TailApps' sandbox stops a card's scripts from starting programs they downloaded (npx and uvx keep theirs in caches).\n    case \"$e\" in *\"Operation not permitted\"*|*EPERM*|*\"not permitted\"*|*EACCES*|*\"Sandbox\"*|*\"sandbox\"*)\n      result false \"TailApps' sandbox stopped it from starting. To test servers that run on this Mac, turn on Trusted (Full Access) in this card's \u22ef menu. Hosted servers test without it\" ;;\n    esac\n    result false \"It didn't answer${e:+: $e}\"\n  }\n  printf '%s\\n' \"$READY\" >&3\n  cursor=\"\"; i=2\n  while [ $i -le 6 ]; do\n    printf '%s\\n' \"$(list $i \"$cursor\")\" >&3\n    page=$(wait_for $i) || break\n    printf '%s' \"$page\" | jq -c '.result.tools[]? | { name, description: (.description // \"\" | .[0:300]) }' >> \"$tools\"\n    cursor=$(printf '%s' \"$page\" | jq -r '.result.nextCursor // empty')\n    [ -n \"$cursor\" ] || break\n    i=$((i + 1))\n  done\n  stop\nfi\n[ -n \"$init\" ] || result false \"It didn't answer the MCP handshake\"\nerr=$(printf '%s' \"$init\" | jq -r '.error.message // empty')\n[ -z \"$err\" ] || result false \"$err\"\nresult true \"\" \"$(jq -sc '.' \"$tools\")\" \"$(printf '%s' \"$init\" | jq -c '.result.serverInfo // null')\"\n",
            "toggle.sh": "#!/bin/sh\n# Args 1-9: the files and folders picked in the card's settings (empty when not picked). A picked one may be changed;\n# otherwise the card reads where each AI app keeps it, and changes nothing there.\nP_claude_code=$1 P_claude_desktop=$2 P_cursor=$3 P_vscode=$4 P_windsurf=$5 P_gemini=$6 P_codex=$7 P_claude_skills=$8 P_codex_skills=$9\nshift 9\nAS=\"$HOME/Library/Application Support\"\nAPPS=\"claude_code claude_desktop cursor vscode windsurf gemini codex\"\npicked() {\n  case \"$1\" in\n    claude_code) printf '%s' \"$P_claude_code\" ;; claude_desktop) printf '%s' \"$P_claude_desktop\" ;; cursor) printf '%s' \"$P_cursor\" ;;\n    vscode) printf '%s' \"$P_vscode\" ;; windsurf) printf '%s' \"$P_windsurf\" ;; gemini) printf '%s' \"$P_gemini\" ;; codex) printf '%s' \"$P_codex\" ;;\n    claude_skills) printf '%s' \"$P_claude_skills\" ;; codex_skills) printf '%s' \"$P_codex_skills\" ;;\n  esac\n}\ndefault_of() {\n  case \"$1\" in\n    claude_code) printf '%s' \"$HOME/.claude.json\" ;;\n    claude_desktop) printf '%s' \"$AS/Claude/claude_desktop_config.json\" ;;\n    cursor) printf '%s' \"$HOME/.cursor/mcp.json\" ;;\n    vscode) printf '%s' \"$AS/Code/User/mcp.json\" ;;\n    windsurf) printf '%s' \"$HOME/.codeium/windsurf/mcp_config.json\" ;;\n    gemini) printf '%s' \"$HOME/.gemini/settings.json\" ;;\n    codex) printf '%s' \"$HOME/.codex/config.toml\" ;;\n    claude_skills) printf '%s' \"$HOME/.claude/skills\" ;;\n    codex_skills) printf '%s' \"$HOME/.codex/skills\" ;;\n  esac\n}\nfile_of() { p=$(picked \"$1\"); [ -n \"$p\" ] && printf '%s' \"$p\" || default_of \"$1\"; }\nname_of() {\n  case \"$1\" in\n    claude_code) echo \"Claude Code\" ;; claude_desktop) echo \"Claude Desktop\" ;; cursor) echo \"Cursor\" ;;\n    vscode) echo \"VS Code\" ;; windsurf) echo \"Windsurf\" ;; gemini) echo \"Gemini CLI\" ;; codex) echo \"Codex\" ;;\n  esac\n}\n# Where an app keeps its servers inside its JSON file, as a jq path.\nbase_of() {\n  case \"$1\" in\n    claude_code) case \"$2\" in local:*) jq -cn --arg p \"${2#local:}\" '[\"projects\", $p, \"mcpServers\"]' ;; *) echo '[\"mcpServers\"]' ;; esac ;;\n    vscode) echo '[\"servers\"]' ;;\n    *) echo '[\"mcpServers\"]' ;;\n  esac\n}\nfail() { printf '%s\\n' \"$*\" >&2; exit 1; }\n# The card's own folder (tmp/<card>/): switched-off servers and backups live here, never in the card's state.\nOWN=$(dirname \"${TMPDIR%/}\")\nPARKED=\"$OWN/parked.json\"\n[ -f \"$PARKED\" ] || { umask 077; echo '[]' > \"$PARKED\"; }\n# A file may only be changed when the person picked it in settings.\nwritable_of() {\n  p=$(picked \"$1\")\n  [ -n \"$p\" ] || fail \"To change $(name_of \"$1\")'s servers, choose its file in this card's settings (the gear): $(default_of \"$1\" | sed \"s|^$HOME|~|\")\"\n  [ -f \"$p\" ] || fail \"$(name_of \"$1\")'s file isn't there any more: $p\"\n  printf '%s' \"$p\"\n}\n# A copy of the file before each change, the newest 30 kept.\nbackup() {\n  mkdir -p \"$OWN/backups\" && chmod 700 \"$OWN/backups\"\n  b=\"$OWN/backups/$2-$(date +%Y%m%d-%H%M%S)-$$.bak\"\n  cp -p \"$1\" \"$b\" || fail \"Couldn't back up $1\"\n  ls -t \"$OWN/backups\"/*.bak 2>/dev/null | tail -n +31 | while IFS= read -r old; do rm -f \"$old\"; done\n}\n# The file's modification time and size, taken before reading it (seen) and checked again just before writing\n# (unchanged), so a change the AI app made meanwhile isn't written over.\nstamp_of() { stat -c '%.9Y %s' \"$1\" 2>/dev/null || stat -f '%Fm %z' \"$1\" 2>/dev/null; }\nseen() { SEEN=$(stamp_of \"$1\"); }\nunchanged() { [ -z \"$SEEN\" ] || [ \"$(stamp_of \"$1\")\" = \"$SEEN\" ]; }\n# Write new text over a file in place (keeps its permissions; the sandbox allows only the picked file itself).\nreplace() {\n  [ -s \"$2\" ] || fail \"Nothing to write\"\n  unchanged \"$1\" || fail \"$1 changed while this ran, so nothing was written. Try again\"\n  cat \"$2\" > \"$1\" || fail \"Couldn't write $1\"\n}\n\n# Turn one server off (its exact entry moves to the card's own folder) or back on (put back as it was).\n# Args: id (\"<app>:<scope>:<name>\"), true|false, and the server as the card shows it (kept with the entry).\nid=$1 on=$2 info=${3:-\"{}\"}\na=${id%%:*}; rest=${id#*:}; name=${id##*:}; scope=${rest%:*}\nn=$(name_of \"$a\"); [ -n \"$n\" ] || fail \"Unknown app in $id\"\nf=$(writable_of \"$a\") || exit 1\nseen \"$f\"\nnew=\"$TMPDIR/new\"\n# The [mcp_servers.<name>] table of a config.toml, and its sub-tables (env), with or without quotes in the name.\ntoml_split() { # file name keep|block\n  awk -v n=\"$2\" -v want=\"$3\" '\n    /^[ \\t]*\\[/ { t = $0; sub(/^[ \\t]*\\[+[ \\t]*/, \"\", t); sub(/[ \\t]*\\]+.*$/, \"\", t); gsub(/\"/, \"\", t)\n                  inblk = (t == \"mcp_servers.\" n || index(t, \"mcp_servers.\" n \".\") == 1) }\n    { if ((want == \"block\") == (inblk == 1)) print }' \"$1\"\n}\nif [ \"$on\" = false ]; then\n  if [ \"$a\" = codex ]; then\n    block=$(toml_split \"$f\" \"$name\" block)\n    [ -n \"$block\" ] || fail \"Codex's config.toml has no [mcp_servers.$name] table to switch off\"\n    backup \"$f\" \"$a\"\n    toml_split \"$f\" \"$name\" keep > \"$new\"\n    jq --arg id \"$id\" --arg toml \"$block\" --argjson info \"$info\" '[.[] | select(.id != $id)] + [{ id: $id, toml: $toml, info: $info, at: now }]' \"$PARKED\" > \"$TMPDIR/parked\"\n  else\n    base=$(base_of \"$a\" \"$scope\")\n    entry=$(jq -c --argjson b \"$base\" --arg n \"$name\" 'getpath($b + [$n])' \"$f\") || fail \"Couldn't read $f\"\n    [ \"$entry\" != null ] || fail \"$n has no server named $name any more\"\n    backup \"$f\" \"$a\"\n    jq --argjson b \"$base\" --arg n \"$name\" 'delpaths([$b + [$n]])' \"$f\" > \"$new\" || fail \"Couldn't change $f\"\n    jq --arg id \"$id\" --argjson e \"$entry\" --argjson info \"$info\" '[.[] | select(.id != $id)] + [{ id: $id, entry: $e, info: $info, at: now }]' \"$PARKED\" > \"$TMPDIR/parked\"\n  fi\n  replace \"$f\" \"$new\"\n  cat \"$TMPDIR/parked\" > \"$PARKED\"\n  echo \"{\\\"ok\\\":true}\"\n  exit 0\nfi\nsaved=$(jq -c --arg id \"$id\" 'map(select(.id == $id)) | .[0]' \"$PARKED\")\n[ \"$saved\" != null ] || fail \"$name isn't switched off here\"\nif [ \"$a\" = codex ]; then\n  [ -z \"$(toml_split \"$f\" \"$name\" block)\" ] || fail \"Codex already has a server named $name\"\n  backup \"$f\" \"$a\"\n  { cat \"$f\"; [ -n \"$(tail -c 1 \"$f\")\" ] && echo; echo; printf '%s\\n' \"$saved\" | jq -r '.toml'; } > \"$new\"\nelse\n  base=$(base_of \"$a\" \"$scope\")\n  [ \"$(jq --argjson b \"$base\" --arg n \"$name\" 'getpath($b + [$n]) != null' \"$f\")\" = false ] || fail \"$n already has a server named $name\"\n  backup \"$f\" \"$a\"\n  jq --argjson b \"$base\" --arg n \"$name\" --argjson e \"$(printf '%s' \"$saved\" | jq -c '.entry')\" 'setpath($b + [$n]; $e)' \"$f\" > \"$new\" || fail \"Couldn't change $f\"\nfi\nreplace \"$f\" \"$new\"\njq --arg id \"$id\" 'map(select(.id != $id))' \"$PARKED\" > \"$TMPDIR/parked\" && cat \"$TMPDIR/parked\" > \"$PARKED\"\necho \"{\\\"ok\\\":true}\"\n",
            "install.sh": "#!/bin/sh\n# Args 1-9: the files and folders picked in the card's settings (empty when not picked). A picked one may be changed;\n# otherwise the card reads where each AI app keeps it, and changes nothing there.\nP_claude_code=$1 P_claude_desktop=$2 P_cursor=$3 P_vscode=$4 P_windsurf=$5 P_gemini=$6 P_codex=$7 P_claude_skills=$8 P_codex_skills=$9\nshift 9\nAS=\"$HOME/Library/Application Support\"\nAPPS=\"claude_code claude_desktop cursor vscode windsurf gemini codex\"\npicked() {\n  case \"$1\" in\n    claude_code) printf '%s' \"$P_claude_code\" ;; claude_desktop) printf '%s' \"$P_claude_desktop\" ;; cursor) printf '%s' \"$P_cursor\" ;;\n    vscode) printf '%s' \"$P_vscode\" ;; windsurf) printf '%s' \"$P_windsurf\" ;; gemini) printf '%s' \"$P_gemini\" ;; codex) printf '%s' \"$P_codex\" ;;\n    claude_skills) printf '%s' \"$P_claude_skills\" ;; codex_skills) printf '%s' \"$P_codex_skills\" ;;\n  esac\n}\ndefault_of() {\n  case \"$1\" in\n    claude_code) printf '%s' \"$HOME/.claude.json\" ;;\n    claude_desktop) printf '%s' \"$AS/Claude/claude_desktop_config.json\" ;;\n    cursor) printf '%s' \"$HOME/.cursor/mcp.json\" ;;\n    vscode) printf '%s' \"$AS/Code/User/mcp.json\" ;;\n    windsurf) printf '%s' \"$HOME/.codeium/windsurf/mcp_config.json\" ;;\n    gemini) printf '%s' \"$HOME/.gemini/settings.json\" ;;\n    codex) printf '%s' \"$HOME/.codex/config.toml\" ;;\n    claude_skills) printf '%s' \"$HOME/.claude/skills\" ;;\n    codex_skills) printf '%s' \"$HOME/.codex/skills\" ;;\n  esac\n}\nfile_of() { p=$(picked \"$1\"); [ -n \"$p\" ] && printf '%s' \"$p\" || default_of \"$1\"; }\nname_of() {\n  case \"$1\" in\n    claude_code) echo \"Claude Code\" ;; claude_desktop) echo \"Claude Desktop\" ;; cursor) echo \"Cursor\" ;;\n    vscode) echo \"VS Code\" ;; windsurf) echo \"Windsurf\" ;; gemini) echo \"Gemini CLI\" ;; codex) echo \"Codex\" ;;\n  esac\n}\n# Where an app keeps its servers inside its JSON file, as a jq path.\nbase_of() {\n  case \"$1\" in\n    claude_code) case \"$2\" in local:*) jq -cn --arg p \"${2#local:}\" '[\"projects\", $p, \"mcpServers\"]' ;; *) echo '[\"mcpServers\"]' ;; esac ;;\n    vscode) echo '[\"servers\"]' ;;\n    *) echo '[\"mcpServers\"]' ;;\n  esac\n}\nfail() { printf '%s\\n' \"$*\" >&2; exit 1; }\n# The card's own folder (tmp/<card>/): switched-off servers and backups live here, never in the card's state.\nOWN=$(dirname \"${TMPDIR%/}\")\nPARKED=\"$OWN/parked.json\"\n[ -f \"$PARKED\" ] || { umask 077; echo '[]' > \"$PARKED\"; }\n# A file may only be changed when the person picked it in settings.\nwritable_of() {\n  p=$(picked \"$1\")\n  [ -n \"$p\" ] || fail \"To change $(name_of \"$1\")'s servers, choose its file in this card's settings (the gear): $(default_of \"$1\" | sed \"s|^$HOME|~|\")\"\n  [ -f \"$p\" ] || fail \"$(name_of \"$1\")'s file isn't there any more: $p\"\n  printf '%s' \"$p\"\n}\n# A copy of the file before each change, the newest 30 kept.\nbackup() {\n  mkdir -p \"$OWN/backups\" && chmod 700 \"$OWN/backups\"\n  b=\"$OWN/backups/$2-$(date +%Y%m%d-%H%M%S)-$$.bak\"\n  cp -p \"$1\" \"$b\" || fail \"Couldn't back up $1\"\n  ls -t \"$OWN/backups\"/*.bak 2>/dev/null | tail -n +31 | while IFS= read -r old; do rm -f \"$old\"; done\n}\n# The file's modification time and size, taken before reading it (seen) and checked again just before writing\n# (unchanged), so a change the AI app made meanwhile isn't written over.\nstamp_of() { stat -c '%.9Y %s' \"$1\" 2>/dev/null || stat -f '%Fm %z' \"$1\" 2>/dev/null; }\nseen() { SEEN=$(stamp_of \"$1\"); }\nunchanged() { [ -z \"$SEEN\" ] || [ \"$(stamp_of \"$1\")\" = \"$SEEN\" ]; }\n# Write new text over a file in place (keeps its permissions; the sandbox allows only the picked file itself).\nreplace() {\n  [ -s \"$2\" ] || fail \"Nothing to write\"\n  unchanged \"$1\" || fail \"$1 changed while this ran, so nothing was written. Try again\"\n  cat \"$2\" > \"$1\" || fail \"Couldn't write $1\"\n}\n\n# Add a server from the MCP Registry to the chosen AI apps, each in its own format, after a backup of each file.\n# Args: the registry's server object, the app ids as a JSON list, and the keys the person typed when asked\n# (\"NAME=value\", separated by new lines or \"; \"; \"header NAME=value\" for a hosted server's headers). Prints { installed: [app names], skipped: [{ app, why }] }.\nserver=$1 targets=${2:-\"[]\"} typed=$3\n[ -n \"$server\" ] && [ \"$server\" != null ] || fail \"Pick a server first\"\n[ \"$(printf '%s' \"$targets\" | jq 'length')\" -gt 0 ] || fail \"Tick at least one app to add it to\"\nname=$(printf '%s' \"$server\" | jq -r '.name | split(\"/\") | last | gsub(\"[^A-Za-z0-9_-]\"; \"-\")')\n# What runs: the first package we know how to start, else the first hosted address.\nspec=$(printf '%s' \"$typed\" | jq -Rs --argjson s \"$server\" '\n  ([splits(\"\\n|;\\\\s*(?=(header\\\\s+)?[A-Za-z_][A-Za-z0-9_-]*\\\\s*=)\")] | map(sub(\"\\r$\"; \"\") | sub(\"^\\\\s+\"; \"\") | select(test(\"^(#|$)\") | not))) as $lines\n  | ([$lines[] | select(startswith(\"header \") | not) | capture(\"^\\\\s*(?<k>[A-Za-z_][A-Za-z0-9_]*)\\\\s*=(?<v>.*)$\")] | map({ (.k): (.v | sub(\"^\\\\s+\"; \"\")) }) | add // {} | with_entries(select(.value != \"\"))) as $env\n  | ([$lines[] | select(startswith(\"header \")) | sub(\"^header \"; \"\") | capture(\"^\\\\s*(?<k>[A-Za-z0-9-]+)\\\\s*=(?<v>.*)$\")] | map({ (.k): (.v | sub(\"^\\\\s+\"; \"\")) }) | add // {} | with_entries(select(.value != \"\"))) as $headers\n  | ([$s.packages[]? | select((.transport.type // \"stdio\") == \"stdio\" and (.registryType == \"npm\" or .registryType == \"pypi\" or .registryType == \"oci\"))] | .[0]) as $p\n  | ($s.remotes // [] | .[0]) as $r\n  | if $p then\n      ([$p.environmentVariables[]? | select(.isRequired == true and ($env[.name] // \"\") == \"\") | .name]) as $missing\n      | ([$p.packageArguments[]? | select(.value != null) | if .type == \"named\" then .name, .value else .value end | tostring]) as $extra\n      | (if ($p.version // \"\") == \"\" then $p.identifier elif $p.registryType == \"pypi\" then \"\\($p.identifier)==\\($p.version)\"\n         elif $p.registryType == \"npm\" then \"\\($p.identifier)@\\($p.version)\"\n         elif ($p.identifier | contains(\":\")) then $p.identifier else \"\\($p.identifier):\\($p.version)\" end) as $id\n      | { kind: \"stdio\", missing: $missing, env: $env,\n          command: ({ npm: \"npx\", pypi: \"uvx\", oci: \"docker\" }[$p.registryType]),\n          args: ((if $p.registryType == \"npm\" then [\"-y\", $id] elif $p.registryType == \"pypi\" then [$id]\n                  else [\"run\", \"-i\", \"--rm\"] + [$env | keys[] | \"-e\", .] + [$id] end) + $extra) }\n    elif $r then\n      ([$r.headers[]? | select(.isRequired == true and ($headers[.name] // \"\") == \"\") | .name]) as $missing\n      | { kind: (if $r.type == \"sse\" then \"sse\" else \"http\" end), url: $r.url, headers: $headers, missing: $missing }\n    else { error: \"It has nothing this card can install (no npm, PyPI or Docker package, and no hosted address)\" } end') || fail \"Couldn't read that server's details\"\n[ -n \"$spec\" ] || fail \"Couldn't read that server's details\"\ne=$(printf '%s' \"$spec\" | jq -r '.error // empty'); [ -z \"$e\" ] || fail \"$e\"\nmissing=$(printf '%s' \"$spec\" | jq -r '.missing | join(\", \")')\n[ -z \"$missing\" ] || fail \"Fill in $missing first\"\n# The entry each app expects.\nentry_for() {\n  printf '%s' \"$spec\" | jq -c --arg app \"$1\" '\n    def drop_empty: with_entries(select(.value != null and .value != {} and .value != []));\n    if .kind == \"stdio\" then\n      (if ($app == \"claude_code\" or $app == \"vscode\") then { type: \"stdio\" } else {} end) + { command, args, env } | drop_empty\n    elif $app == \"claude_desktop\" then\n      { command: \"npx\", args: ([\"-y\", \"mcp-remote\", .url] + ([.headers | to_entries[] | \"--header\", \"\\(.key):\\(.value)\"])) }\n    elif $app == \"windsurf\" then { serverUrl: .url, headers } | drop_empty\n    elif $app == \"gemini\" then (if .kind == \"sse\" then { url, headers } else { httpUrl: .url, headers } end) | drop_empty\n    elif $app == \"cursor\" then { url, headers } | drop_empty\n    else { type: .kind, url, headers } | drop_empty end'\n}\ntoml_for() {\n  printf '%s' \"$spec\" | jq -r --arg n \"$name\" '\n    def kv: to_entries | map(\"\\(.key | tojson) = \\(.value | tojson)\") | join(\", \");\n    \"[mcp_servers.\\($n)]\\n\" + (if .kind == \"stdio\"\n      then \"command = \\(.command | tojson)\\nargs = \\(.args | tojson)\\n\" + (if (.env | length) > 0 then \"env = { \\(.env | kv) }\\n\" else \"\" end)\n      else \"url = \\(.url | tojson)\\n\" + (if (.headers | length) > 0 then \"http_headers = { \\(.headers | kv) }\\n\" else \"\" end) end)'\n}\ndone_list=\"$TMPDIR/done\"; skip_list=\"$TMPDIR/skip\"; : > \"$done_list\"; : > \"$skip_list\"\nskip() { jq -cn --arg app \"$(name_of \"$1\")\" --arg why \"$2\" '{ app: $app, why: $why }' >> \"$skip_list\"; }\nfor a in $(printf '%s' \"$targets\" | jq -r '.[]'); do\n  n=$(name_of \"$a\"); [ -n \"$n\" ] || continue\n  f=$(picked \"$a\")\n  if [ -z \"$f\" ]; then skip \"$a\" \"Choose its file in this card's settings first\"; continue; fi\n  if [ ! -f \"$f\" ]; then skip \"$a\" \"Its file isn't there\"; continue; fi\n  seen \"$f\"\n  new=\"$TMPDIR/new-$a\"\n  if [ \"$a\" = codex ]; then\n    if [ \"$(printf '%s' \"$spec\" | jq -r .kind)\" = sse ]; then skip \"$a\" \"Codex doesn't take the older SSE kind\"; continue; fi\n    if grep -Eq \"^[[:space:]]*\\[mcp_servers\\.\\\"?$name\\\"?\\]\" \"$f\"; then skip \"$a\" \"It already has a server named $name\"; continue; fi\n    { cat \"$f\"; [ -n \"$(tail -c 1 \"$f\")\" ] && echo; echo; toml_for; } > \"$new\"\n  else\n    base=$(base_of \"$a\" user)\n    if ! jq -e . \"$f\" > /dev/null 2>&1; then skip \"$a\" \"Its file has comments or isn't plain JSON\"; continue; fi\n    if [ \"$(jq --argjson b \"$base\" --arg n \"$name\" 'getpath($b + [$n]) != null' \"$f\")\" = true ]; then skip \"$a\" \"It already has a server named $name\"; continue; fi\n    jq --argjson b \"$base\" --arg n \"$name\" --argjson e \"$(entry_for \"$a\")\" 'setpath($b + [$n]; $e)' \"$f\" > \"$new\" || { skip \"$a\" \"Couldn't change its file\"; continue; }\n  fi\n  unchanged \"$f\" || { skip \"$a\" \"Its file changed meanwhile. Try again\"; continue; }\n  backup \"$f\" \"$a\"\n  replace \"$f\" \"$new\"\n  printf '%s\\n' \"$n\" | jq -R . >> \"$done_list\"\ndone\njq -n --arg name \"$name\" --slurpfile d \"$done_list\" --slurpfile s \"$skip_list\" '{ name: $name, installed: $d, skipped: $s }'\n",
            "skills.sh": "#!/bin/sh\n# Args 1-9: the files and folders picked in the card's settings (empty when not picked). A picked one may be changed;\n# otherwise the card reads where each AI app keeps it, and changes nothing there.\nP_claude_code=$1 P_claude_desktop=$2 P_cursor=$3 P_vscode=$4 P_windsurf=$5 P_gemini=$6 P_codex=$7 P_claude_skills=$8 P_codex_skills=$9\nshift 9\nAS=\"$HOME/Library/Application Support\"\nAPPS=\"claude_code claude_desktop cursor vscode windsurf gemini codex\"\npicked() {\n  case \"$1\" in\n    claude_code) printf '%s' \"$P_claude_code\" ;; claude_desktop) printf '%s' \"$P_claude_desktop\" ;; cursor) printf '%s' \"$P_cursor\" ;;\n    vscode) printf '%s' \"$P_vscode\" ;; windsurf) printf '%s' \"$P_windsurf\" ;; gemini) printf '%s' \"$P_gemini\" ;; codex) printf '%s' \"$P_codex\" ;;\n    claude_skills) printf '%s' \"$P_claude_skills\" ;; codex_skills) printf '%s' \"$P_codex_skills\" ;;\n  esac\n}\ndefault_of() {\n  case \"$1\" in\n    claude_code) printf '%s' \"$HOME/.claude.json\" ;;\n    claude_desktop) printf '%s' \"$AS/Claude/claude_desktop_config.json\" ;;\n    cursor) printf '%s' \"$HOME/.cursor/mcp.json\" ;;\n    vscode) printf '%s' \"$AS/Code/User/mcp.json\" ;;\n    windsurf) printf '%s' \"$HOME/.codeium/windsurf/mcp_config.json\" ;;\n    gemini) printf '%s' \"$HOME/.gemini/settings.json\" ;;\n    codex) printf '%s' \"$HOME/.codex/config.toml\" ;;\n    claude_skills) printf '%s' \"$HOME/.claude/skills\" ;;\n    codex_skills) printf '%s' \"$HOME/.codex/skills\" ;;\n  esac\n}\nfile_of() { p=$(picked \"$1\"); [ -n \"$p\" ] && printf '%s' \"$p\" || default_of \"$1\"; }\nname_of() {\n  case \"$1\" in\n    claude_code) echo \"Claude Code\" ;; claude_desktop) echo \"Claude Desktop\" ;; cursor) echo \"Cursor\" ;;\n    vscode) echo \"VS Code\" ;; windsurf) echo \"Windsurf\" ;; gemini) echo \"Gemini CLI\" ;; codex) echo \"Codex\" ;;\n  esac\n}\n# Where an app keeps its servers inside its JSON file, as a jq path.\nbase_of() {\n  case \"$1\" in\n    claude_code) case \"$2\" in local:*) jq -cn --arg p \"${2#local:}\" '[\"projects\", $p, \"mcpServers\"]' ;; *) echo '[\"mcpServers\"]' ;; esac ;;\n    vscode) echo '[\"servers\"]' ;;\n    *) echo '[\"mcpServers\"]' ;;\n  esac\n}\nfail() { printf '%s\\n' \"$*\" >&2; exit 1; }\n# The card's own folder (tmp/<card>/): switched-off servers and backups live here, never in the card's state.\nOWN=$(dirname \"${TMPDIR%/}\")\nPARKED=\"$OWN/parked.json\"\n[ -f \"$PARKED\" ] || { umask 077; echo '[]' > \"$PARKED\"; }\n# A file may only be changed when the person picked it in settings.\nwritable_of() {\n  p=$(picked \"$1\")\n  [ -n \"$p\" ] || fail \"To change $(name_of \"$1\")'s servers, choose its file in this card's settings (the gear): $(default_of \"$1\" | sed \"s|^$HOME|~|\")\"\n  [ -f \"$p\" ] || fail \"$(name_of \"$1\")'s file isn't there any more: $p\"\n  printf '%s' \"$p\"\n}\n# A copy of the file before each change, the newest 30 kept.\nbackup() {\n  mkdir -p \"$OWN/backups\" && chmod 700 \"$OWN/backups\"\n  b=\"$OWN/backups/$2-$(date +%Y%m%d-%H%M%S)-$$.bak\"\n  cp -p \"$1\" \"$b\" || fail \"Couldn't back up $1\"\n  ls -t \"$OWN/backups\"/*.bak 2>/dev/null | tail -n +31 | while IFS= read -r old; do rm -f \"$old\"; done\n}\n# The file's modification time and size, taken before reading it (seen) and checked again just before writing\n# (unchanged), so a change the AI app made meanwhile isn't written over.\nstamp_of() { stat -c '%.9Y %s' \"$1\" 2>/dev/null || stat -f '%Fm %z' \"$1\" 2>/dev/null; }\nseen() { SEEN=$(stamp_of \"$1\"); }\nunchanged() { [ -z \"$SEEN\" ] || [ \"$(stamp_of \"$1\")\" = \"$SEEN\" ]; }\n# Write new text over a file in place (keeps its permissions; the sandbox allows only the picked file itself).\nreplace() {\n  [ -s \"$2\" ] || fail \"Nothing to write\"\n  unchanged \"$1\" || fail \"$1 changed while this ran, so nothing was written. Try again\"\n  cat \"$2\" > \"$1\" || fail \"Couldn't write $1\"\n}\n\n# Agent skills: Claude Code's and Codex's own (switch off = SKILL.md renamed SKILL.md.off, so no agent loads it) and\n# the ones that came with Claude Code plugins (shown, not switched). Prints [{ id, name, description, agent, path, on,\n# can_switch, body }].\nout=\"$TMPDIR/skills.jsonl\"; : > \"$out\"\nfront() { # file key: a value from the front matter between the first two --- lines\n  awk -v k=\"$2\" 'NR == 1 && $0 != \"---\" { exit } NR > 1 && $0 == \"---\" { exit }\n    NR > 1 { i = index($0, \":\"); if (i && substr($0, 1, i - 1) == k) { v = substr($0, i + 1); sub(/^[ \\t]+/, \"\", v); gsub(/^[\"'\\'']|[\"'\\'']$/, \"\", v); print v; exit } }' \"$1\"\n}\nadd() { # file agent on can_switch\n  dir=$(dirname \"$1\")\n  n=$(front \"$1\" name); [ -n \"$n\" ] || n=$(basename \"$dir\")\n  jq -cn --arg path \"$dir\" --arg name \"$n\" --arg description \"$(front \"$1\" description)\" --arg agent \"$2\" \\\n    --argjson on \"$3\" --argjson can \"$4\" --rawfile body \"$1\" \\\n    '{ id: $path, name: $name, description: $description, agent: $agent, path: $path, on: $on, can_switch: $can, body: ($body | .[0:6000]) }' >> \"$out\"\n}\nfor kind in claude_skills codex_skills; do\n  d=$(picked \"$kind\"); can=true\n  [ -n \"$d\" ] || { d=$(default_of \"$kind\"); can=false; }\n  agent=$([ \"$kind\" = claude_skills ] && echo \"Claude Code\" || echo \"Codex\")\n  [ -d \"$d\" ] || continue\n  for s in \"$d\"/*/; do\n    [ -f \"$s/SKILL.md\" ] && add \"$s/SKILL.md\" \"$agent\" true \"$can\"\n    [ -f \"$s/SKILL.md.off\" ] && add \"$s/SKILL.md.off\" \"$agent\" false \"$can\"\n  done\ndone\n# Plugins' skills: ~/.claude/plugins/cache/<marketplace>/<plugin>/<version>/skills/<skill>/SKILL.md\nfind \"$HOME/.claude/plugins/cache\" -maxdepth 6 -path '*/skills/*/SKILL.md' 2>/dev/null | sort | while IFS= read -r f; do\n  plugin=$(printf '%s' \"$f\" | sed -E 's|.*/plugins/cache/[^/]+/([^/]+)/.*|\\1|')\n  add \"$f\" \"Plugin $plugin\" true false\ndone\njq -s 'unique_by(.path) | sort_by(.name | ascii_downcase)' \"$out\"\n",
            "skill-switch.sh": "#!/bin/sh\n# Args 1-9: the files and folders picked in the card's settings (empty when not picked). A picked one may be changed;\n# otherwise the card reads where each AI app keeps it, and changes nothing there.\nP_claude_code=$1 P_claude_desktop=$2 P_cursor=$3 P_vscode=$4 P_windsurf=$5 P_gemini=$6 P_codex=$7 P_claude_skills=$8 P_codex_skills=$9\nshift 9\nAS=\"$HOME/Library/Application Support\"\nAPPS=\"claude_code claude_desktop cursor vscode windsurf gemini codex\"\npicked() {\n  case \"$1\" in\n    claude_code) printf '%s' \"$P_claude_code\" ;; claude_desktop) printf '%s' \"$P_claude_desktop\" ;; cursor) printf '%s' \"$P_cursor\" ;;\n    vscode) printf '%s' \"$P_vscode\" ;; windsurf) printf '%s' \"$P_windsurf\" ;; gemini) printf '%s' \"$P_gemini\" ;; codex) printf '%s' \"$P_codex\" ;;\n    claude_skills) printf '%s' \"$P_claude_skills\" ;; codex_skills) printf '%s' \"$P_codex_skills\" ;;\n  esac\n}\ndefault_of() {\n  case \"$1\" in\n    claude_code) printf '%s' \"$HOME/.claude.json\" ;;\n    claude_desktop) printf '%s' \"$AS/Claude/claude_desktop_config.json\" ;;\n    cursor) printf '%s' \"$HOME/.cursor/mcp.json\" ;;\n    vscode) printf '%s' \"$AS/Code/User/mcp.json\" ;;\n    windsurf) printf '%s' \"$HOME/.codeium/windsurf/mcp_config.json\" ;;\n    gemini) printf '%s' \"$HOME/.gemini/settings.json\" ;;\n    codex) printf '%s' \"$HOME/.codex/config.toml\" ;;\n    claude_skills) printf '%s' \"$HOME/.claude/skills\" ;;\n    codex_skills) printf '%s' \"$HOME/.codex/skills\" ;;\n  esac\n}\nfile_of() { p=$(picked \"$1\"); [ -n \"$p\" ] && printf '%s' \"$p\" || default_of \"$1\"; }\nname_of() {\n  case \"$1\" in\n    claude_code) echo \"Claude Code\" ;; claude_desktop) echo \"Claude Desktop\" ;; cursor) echo \"Cursor\" ;;\n    vscode) echo \"VS Code\" ;; windsurf) echo \"Windsurf\" ;; gemini) echo \"Gemini CLI\" ;; codex) echo \"Codex\" ;;\n  esac\n}\n# Where an app keeps its servers inside its JSON file, as a jq path.\nbase_of() {\n  case \"$1\" in\n    claude_code) case \"$2\" in local:*) jq -cn --arg p \"${2#local:}\" '[\"projects\", $p, \"mcpServers\"]' ;; *) echo '[\"mcpServers\"]' ;; esac ;;\n    vscode) echo '[\"servers\"]' ;;\n    *) echo '[\"mcpServers\"]' ;;\n  esac\n}\nfail() { printf '%s\\n' \"$*\" >&2; exit 1; }\n# The card's own folder (tmp/<card>/): switched-off servers and backups live here, never in the card's state.\nOWN=$(dirname \"${TMPDIR%/}\")\nPARKED=\"$OWN/parked.json\"\n[ -f \"$PARKED\" ] || { umask 077; echo '[]' > \"$PARKED\"; }\n# A file may only be changed when the person picked it in settings.\nwritable_of() {\n  p=$(picked \"$1\")\n  [ -n \"$p\" ] || fail \"To change $(name_of \"$1\")'s servers, choose its file in this card's settings (the gear): $(default_of \"$1\" | sed \"s|^$HOME|~|\")\"\n  [ -f \"$p\" ] || fail \"$(name_of \"$1\")'s file isn't there any more: $p\"\n  printf '%s' \"$p\"\n}\n# A copy of the file before each change, the newest 30 kept.\nbackup() {\n  mkdir -p \"$OWN/backups\" && chmod 700 \"$OWN/backups\"\n  b=\"$OWN/backups/$2-$(date +%Y%m%d-%H%M%S)-$$.bak\"\n  cp -p \"$1\" \"$b\" || fail \"Couldn't back up $1\"\n  ls -t \"$OWN/backups\"/*.bak 2>/dev/null | tail -n +31 | while IFS= read -r old; do rm -f \"$old\"; done\n}\n# The file's modification time and size, taken before reading it (seen) and checked again just before writing\n# (unchanged), so a change the AI app made meanwhile isn't written over.\nstamp_of() { stat -c '%.9Y %s' \"$1\" 2>/dev/null || stat -f '%Fm %z' \"$1\" 2>/dev/null; }\nseen() { SEEN=$(stamp_of \"$1\"); }\nunchanged() { [ -z \"$SEEN\" ] || [ \"$(stamp_of \"$1\")\" = \"$SEEN\" ]; }\n# Write new text over a file in place (keeps its permissions; the sandbox allows only the picked file itself).\nreplace() {\n  [ -s \"$2\" ] || fail \"Nothing to write\"\n  unchanged \"$1\" || fail \"$1 changed while this ran, so nothing was written. Try again\"\n  cat \"$2\" > \"$1\" || fail \"Couldn't write $1\"\n}\n\n# Switch a skill off (SKILL.md \u2192 SKILL.md.off, so no agent loads it) or back on. Only inside a skills folder picked\n# in the card's settings. Args: the skill's folder, true|false.\ndir=${1%/} on=$2\nok=false\nfor kind in claude_skills codex_skills; do\n  root=$(picked \"$kind\"); root=${root%/}\n  [ -n \"$root\" ] && [ \"$(dirname \"$dir\")\" = \"$root\" ] && ok=true\ndone\n[ \"$ok\" = true ] || fail \"To switch skills, choose the skills folder in this card's settings (the gear)\"\nif [ \"$on\" = false ]; then\n  [ -f \"$dir/SKILL.md\" ] || fail \"There's no SKILL.md in $dir\"\n  [ ! -e \"$dir/SKILL.md.off\" ] || fail \"$dir already has a SKILL.md.off\"\n  mv \"$dir/SKILL.md\" \"$dir/SKILL.md.off\" || fail \"Couldn't switch it off\"\nelse\n  [ -f \"$dir/SKILL.md.off\" ] || fail \"It isn't switched off\"\n  [ ! -e \"$dir/SKILL.md\" ] || fail \"$dir already has a SKILL.md\"\n  mv \"$dir/SKILL.md.off\" \"$dir/SKILL.md\" || fail \"Couldn't switch it on\"\nfi\necho '{\"ok\":true}'\n"
        },
        "style": {
            "accent": "#0f766e"
        }
    },
    "app_json": "{\n  \"schema\": \"tailapps/v0\",\n  \"app\": \"mcp-servers\",\n  \"name\": \"MCP Servers\",\n  \"description\": \"Every MCP server in your AI apps in one list: test one and see its tools, switch it off without deleting it, add from the MCP Registry, and see your skills. Mac only.\",\n  \"icon\": \"server.rack\",\n  \"version\": 1,\n  \"permissions\": [\n    \"script:scan.sh\",\n    \"script:codex.sh\",\n    \"script:stamp.sh\",\n    \"script:test.sh\",\n    \"script:toggle.sh\",\n    \"script:install.sh\",\n    \"script:skills.sh\",\n    \"script:skill-switch.sh\",\n    \"net:registry.modelcontextprotocol.io\",\n    \"files.write:claude_code\",\n    \"files.write:claude_desktop\",\n    \"files.write:cursor\",\n    \"files.write:vscode\",\n    \"files.write:windsurf\",\n    \"files.write:gemini\",\n    \"files.write:codex\",\n    \"files.write:claude_skills\",\n    \"files.write:codex_skills\"\n  ],\n  \"settings\": {\n    \"claude_code\": {\n      \"type\": \"file\",\n      \"label\": \"Claude Code (~/.claude.json)\",\n      \"default\": \"~/.claude.json\"\n    },\n    \"claude_desktop\": {\n      \"type\": \"file\",\n      \"label\": \"Claude Desktop\",\n      \"default\": \"~/Library/Application Support/Claude/claude_desktop_config.json\"\n    },\n    \"cursor\": {\n      \"type\": \"file\",\n      \"label\": \"Cursor (~/.cursor/mcp.json)\",\n      \"default\": \"~/.cursor/mcp.json\"\n    },\n    \"vscode\": {\n      \"type\": \"file\",\n      \"label\": \"VS Code (User/mcp.json)\",\n      \"default\": \"~/Library/Application Support/Code/User/mcp.json\"\n    },\n    \"windsurf\": {\n      \"type\": \"file\",\n      \"label\": \"Windsurf (mcp_config.json)\",\n      \"default\": \"~/.codeium/windsurf/mcp_config.json\"\n    },\n    \"gemini\": {\n      \"type\": \"file\",\n      \"label\": \"Gemini CLI (~/.gemini/settings.json)\",\n      \"default\": \"~/.gemini/settings.json\"\n    },\n    \"codex\": {\n      \"type\": \"file\",\n      \"label\": \"Codex (~/.codex/config.toml)\",\n      \"default\": \"~/.codex/config.toml\"\n    },\n    \"claude_skills\": {\n      \"type\": \"folder\",\n      \"label\": \"Claude Code skills folder\",\n      \"default\": \"~/.claude/skills\"\n    },\n    \"codex_skills\": {\n      \"type\": \"folder\",\n      \"label\": \"Codex skills folder\",\n      \"default\": \"~/.codex/skills\"\n    }\n  },\n  \"state\": {\n    \"servers\": {\n      \"type\": \"list\",\n      \"default\": []\n    },\n    \"names\": {\n      \"type\": \"list\",\n      \"default\": []\n    },\n    \"apps\": {\n      \"type\": \"list\",\n      \"default\": []\n    },\n    \"tested\": {\n      \"type\": \"list\",\n      \"default\": []\n    },\n    \"query\": {\n      \"type\": \"text\",\n      \"default\": \"\"\n    },\n    \"results\": {\n      \"type\": \"list\",\n      \"default\": []\n    },\n    \"install_to\": {\n      \"type\": \"list\",\n      \"default\": []\n    }\n  },\n  \"sources\": {\n    \"stamp\": {\n      \"script\": \"stamp.sh\",\n      \"args\": [\n        \"$settings.claude_code\",\n        \"$settings.claude_desktop\",\n        \"$settings.cursor\",\n        \"$settings.vscode\",\n        \"$settings.windsurf\",\n        \"$settings.gemini\",\n        \"$settings.codex\",\n        \"$settings.claude_skills\",\n        \"$settings.codex_skills\"\n      ],\n      \"parse\": \"text\",\n      \"every\": 20,\n      \"on\": \"open\",\n      \"on_change\": \"scan\"\n    },\n    \"skills\": {\n      \"script\": \"skills.sh\",\n      \"args\": [\n        \"$settings.claude_code\",\n        \"$settings.claude_desktop\",\n        \"$settings.cursor\",\n        \"$settings.vscode\",\n        \"$settings.windsurf\",\n        \"$settings.gemini\",\n        \"$settings.codex\",\n        \"$settings.claude_skills\",\n        \"$settings.codex_skills\"\n      ],\n      \"every\": 120,\n      \"on\": \"open\"\n    }\n  },\n  \"actions\": {\n    \"scan\": {\n      \"steps\": [\n        {\n          \"script\": \"codex.sh\",\n          \"args\": [\n            \"$settings.claude_code\",\n            \"$settings.claude_desktop\",\n            \"$settings.cursor\",\n            \"$settings.vscode\",\n            \"$settings.windsurf\",\n            \"$settings.gemini\",\n            \"$settings.codex\",\n            \"$settings.claude_skills\",\n            \"$settings.codex_skills\"\n          ],\n          \"as\": \"codex\",\n          \"parse\": \"text\"\n        },\n        {\n          \"script\": \"scan.sh\",\n          \"args\": [\n            \"$settings.claude_code\",\n            \"$settings.claude_desktop\",\n            \"$settings.cursor\",\n            \"$settings.vscode\",\n            \"$settings.windsurf\",\n            \"$settings.gemini\",\n            \"$settings.codex\",\n            \"$settings.claude_skills\",\n            \"$settings.codex_skills\",\n            \"$codex | parse:'toml' | pick:'mcp_servers'\"\n          ],\n          \"as\": \"out\"\n        },\n        {\n          \"set\": {\n            \"servers\": \"$out.servers\",\n            \"apps\": \"$out.apps\",\n            \"names\": \"$out.names\"\n          }\n        }\n      ]\n    },\n    \"open_server\": {\n      \"args\": {\n        \"name\": \"text\"\n      },\n      \"steps\": [\n        {\n          \"open_card\": \"server\",\n          \"args\": {\n            \"name\": \"$args.name\"\n          }\n        }\n      ]\n    },\n    \"test\": {\n      \"args\": {\n        \"id\": \"text\"\n      },\n      \"steps\": [\n        {\n          \"script\": \"codex.sh\",\n          \"args\": [\n            \"$settings.claude_code\",\n            \"$settings.claude_desktop\",\n            \"$settings.cursor\",\n            \"$settings.vscode\",\n            \"$settings.windsurf\",\n            \"$settings.gemini\",\n            \"$settings.codex\",\n            \"$settings.claude_skills\",\n            \"$settings.codex_skills\"\n          ],\n          \"as\": \"codex\",\n          \"parse\": \"text\"\n        },\n        {\n          \"script\": \"test.sh\",\n          \"args\": [\n            \"$settings.claude_code\",\n            \"$settings.claude_desktop\",\n            \"$settings.cursor\",\n            \"$settings.vscode\",\n            \"$settings.windsurf\",\n            \"$settings.gemini\",\n            \"$settings.codex\",\n            \"$settings.claude_skills\",\n            \"$settings.codex_skills\",\n            \"$args.id\",\n            \"$codex | parse:'toml' | pick:'mcp_servers'\"\n          ],\n          \"as\": \"result\",\n          \"timeout\": 150\n        },\n        {\n          \"push\": {\n            \"tested\": \"$result\"\n          },\n          \"max\": 30\n        },\n        {\n          \"if\": \"$result.ok\",\n          \"then\": [\n            {\n              \"toast\": \"{$result.tools | count} tools\"\n            }\n          ],\n          \"else\": [\n            {\n              \"toast\": \"Didn't connect\"\n            }\n          ]\n        }\n      ],\n      \"timeout\": 160\n    },\n    \"switch\": {\n      \"args\": {\n        \"id\": \"text\",\n        \"on\": \"bool\"\n      },\n      \"steps\": [\n        {\n          \"script\": \"toggle.sh\",\n          \"args\": [\n            \"$settings.claude_code\",\n            \"$settings.claude_desktop\",\n            \"$settings.cursor\",\n            \"$settings.vscode\",\n            \"$settings.windsurf\",\n            \"$settings.gemini\",\n            \"$settings.codex\",\n            \"$settings.claude_skills\",\n            \"$settings.codex_skills\",\n            \"$args.id\",\n            \"$args.on\",\n            \"$servers | where:'id':$args.id | pick:0\"\n          ]\n        },\n        {\n          \"refresh\": \"stamp\"\n        },\n        {\n          \"toast\": {\n            \"text\": \"{$args.on | map:{true:'Switched on', else:'Switched off'}} in {$servers | where:'id':$args.id | pick:0 | pick:'app_name'}\",\n            \"undo\": \"switch\",\n            \"args\": {\n              \"id\": \"$args.id\",\n              \"on\": \"$args.on | map:{true:false, else:true}\"\n            }\n          }\n        }\n      ]\n    },\n    \"search\": {\n      \"steps\": [\n        {\n          \"fetch\": \"https://registry.modelcontextprotocol.io/v0.1/servers?search={$query | url}&limit=40&version=latest\",\n          \"as\": \"res\"\n        },\n        {\n          \"set\": {\n            \"results\": \"$res.servers | pluck:'server'\"\n          }\n        }\n      ]\n    },\n    \"open_install\": {\n      \"args\": {\n        \"name\": \"text\"\n      },\n      \"steps\": [\n        {\n          \"set\": {\n            \"install_to\": \"$apps | where:'picked' | pluck:'id'\"\n          }\n        },\n        {\n          \"open_card\": \"install\",\n          \"args\": {\n            \"name\": \"$args.name\"\n          }\n        }\n      ]\n    },\n    \"install\": {\n      \"args\": {\n        \"name\": \"text\"\n      },\n      \"steps\": [\n        {\n          \"if\": \"$results | where:'name':$args.name | pick:0 | pick:'packages' | pick:0 | pick:'environmentVariables' | pluck:'name'\",\n          \"then\": [\n            {\n              \"ask\": {\n                \"title\": \"Keys for {$args.name}\",\n                \"message\": \"NAME=value, separated by ; (header NAME=value for a hosted server's headers). They go only into the AI apps' own files.\",\n                \"input\": \"text\",\n                \"default\": \"{$results | where:'name':$args.name | pick:0 | pick:'packages' | pick:0 | pick:'environmentVariables' | pluck:'name' | wrap:'':'=' | join:'; '}\"\n              },\n              \"as\": \"keys\"\n            },\n            {\n              \"script\": \"install.sh\",\n              \"args\": [\n                \"$settings.claude_code\",\n                \"$settings.claude_desktop\",\n                \"$settings.cursor\",\n                \"$settings.vscode\",\n                \"$settings.windsurf\",\n                \"$settings.gemini\",\n                \"$settings.codex\",\n                \"$settings.claude_skills\",\n                \"$settings.codex_skills\",\n                \"$results | where:'name':$args.name | pick:0\",\n                \"$install_to\",\n                \"$keys\"\n              ],\n              \"as\": \"done\"\n            },\n            {\n              \"refresh\": \"stamp\"\n            },\n            {\n              \"if\": \"$done.installed | count\",\n              \"then\": [\n                {\n                  \"toast\": \"Added {$done.name} to {$done.installed | join}\"\n                },\n                {\n                  \"close_card\": true\n                }\n              ],\n              \"else\": [\n                {\n                  \"toast\": \"Not added: {$done.skipped | pick:0 | pick:'why'}\"\n                }\n              ]\n            }\n          ],\n          \"else\": [\n            {\n              \"if\": \"$results | where:'name':$args.name | pick:0 | pick:'remotes' | pick:0 | pick:'headers' | pluck:'name'\",\n              \"then\": [\n                {\n                  \"ask\": {\n                    \"title\": \"Keys for {$args.name}\",\n                    \"message\": \"NAME=value, separated by ; (header NAME=value for a hosted server's headers). They go only into the AI apps' own files.\",\n                    \"input\": \"text\",\n                    \"default\": \"{$results | where:'name':$args.name | pick:0 | pick:'remotes' | pick:0 | pick:'headers' | pluck:'name' | wrap:'header ':'=' | join:'; '}\"\n                  },\n                  \"as\": \"keys\"\n                },\n                {\n                  \"script\": \"install.sh\",\n                  \"args\": [\n                    \"$settings.claude_code\",\n                    \"$settings.claude_desktop\",\n                    \"$settings.cursor\",\n                    \"$settings.vscode\",\n                    \"$settings.windsurf\",\n                    \"$settings.gemini\",\n                    \"$settings.codex\",\n                    \"$settings.claude_skills\",\n                    \"$settings.codex_skills\",\n                    \"$results | where:'name':$args.name | pick:0\",\n                    \"$install_to\",\n                    \"$keys\"\n                  ],\n                  \"as\": \"done\"\n                },\n                {\n                  \"refresh\": \"stamp\"\n                },\n                {\n                  \"if\": \"$done.installed | count\",\n                  \"then\": [\n                    {\n                      \"toast\": \"Added {$done.name} to {$done.installed | join}\"\n                    },\n                    {\n                      \"close_card\": true\n                    }\n                  ],\n                  \"else\": [\n                    {\n                      \"toast\": \"Not added: {$done.skipped | pick:0 | pick:'why'}\"\n                    }\n                  ]\n                }\n              ],\n              \"else\": [\n                {\n                  \"script\": \"install.sh\",\n                  \"args\": [\n                    \"$settings.claude_code\",\n                    \"$settings.claude_desktop\",\n                    \"$settings.cursor\",\n                    \"$settings.vscode\",\n                    \"$settings.windsurf\",\n                    \"$settings.gemini\",\n                    \"$settings.codex\",\n                    \"$settings.claude_skills\",\n                    \"$settings.codex_skills\",\n                    \"$results | where:'name':$args.name | pick:0\",\n                    \"$install_to\",\n                    \"\"\n                  ],\n                  \"as\": \"done\"\n                },\n                {\n                  \"refresh\": \"stamp\"\n                },\n                {\n                  \"if\": \"$done.installed | count\",\n                  \"then\": [\n                    {\n                      \"toast\": \"Added {$done.name} to {$done.installed | join}\"\n                    },\n                    {\n                      \"close_card\": true\n                    }\n                  ],\n                  \"else\": [\n                    {\n                      \"toast\": \"Not added: {$done.skipped | pick:0 | pick:'why'}\"\n                    }\n                  ]\n                }\n              ]\n            }\n          ]\n        }\n      ]\n    },\n    \"open_skill\": {\n      \"args\": {\n        \"id\": \"text\"\n      },\n      \"steps\": [\n        {\n          \"open_card\": \"skill\",\n          \"args\": {\n            \"id\": \"$args.id\"\n          }\n        }\n      ]\n    },\n    \"switch_skill\": {\n      \"args\": {\n        \"id\": \"text\",\n        \"on\": \"bool\"\n      },\n      \"steps\": [\n        {\n          \"script\": \"skill-switch.sh\",\n          \"args\": [\n            \"$settings.claude_code\",\n            \"$settings.claude_desktop\",\n            \"$settings.cursor\",\n            \"$settings.vscode\",\n            \"$settings.windsurf\",\n            \"$settings.gemini\",\n            \"$settings.codex\",\n            \"$settings.claude_skills\",\n            \"$settings.codex_skills\",\n            \"$args.id\",\n            \"$args.on\"\n          ]\n        },\n        {\n          \"refresh\": \"skills\"\n        },\n        {\n          \"toast\": {\n            \"text\": \"{$args.on | map:{true:'Skill switched on', else:'Skill switched off'}}\",\n            \"undo\": \"switch_skill\",\n            \"args\": {\n              \"id\": \"$args.id\",\n              \"on\": \"$args.on | map:{true:false, else:true}\"\n            }\n          }\n        }\n      ]\n    }\n  },\n  \"cards\": [\n    {\n      \"id\": \"main\",\n      \"layout\": {\n        \"tabs\": [\n          {\n            \"label\": \"Servers\",\n            \"icon\": \"server.rack\",\n            \"count\": \"$names | count\",\n            \"children\": [\n              {\n                \"list\": \"$names\",\n                \"empty\": \"No MCP servers found in your AI apps yet. Add one from the Registry tab.\",\n                \"item\": {\n                  \"cell\": \"$item.name\",\n                  \"subtitle\": \"{$item.apps | join}{$item.on | map:{0:' \u00b7 off', else:''}}\",\n                  \"leading\": {\n                    \"icon\": \"$item.kind | map:{stdio:'terminal', else:'globe'}\",\n                    \"hue\": \"$item.kind | map:{stdio:'blue', else:'teal'}\"\n                  },\n                  \"status\": \"$item.on | tone:{good:'>0', else:'neutral'}\",\n                  \"count\": \"$item.total\",\n                  \"accessory\": \"chevron\",\n                  \"on\": \"open_server\",\n                  \"args\": {\n                    \"name\": \"$item.name\"\n                  }\n                }\n              },\n              {\n                \"section\": \"AI apps\",\n                \"collapsible\": true,\n                \"collapsed\": true,\n                \"children\": [\n                  {\n                    \"list\": \"$apps\",\n                    \"item\": {\n                      \"cell\": \"$item.name\",\n                      \"subtitle\": \"{$item.path}{$item.found | map:{true:'', else:' \u00b7 not found'}}{$item.picked | map:{true:'', else:' \u00b7 read only'}}{$item.error | map:{null:'', else:' \u00b7 read only: not plain JSON'}}\",\n                      \"status\": \"$item.found | map:{true:'good', else:'neutral'}\",\n                      \"count\": \"$item.count\"\n                    }\n                  },\n                  {\n                    \"text\": \"To switch servers off or add them, choose each app's file with the gear. Until then the card only reads it.\",\n                    \"size\": \"s\",\n                    \"emphasis\": \"subtle\"\n                  }\n                ]\n              }\n            ]\n          },\n          {\n            \"label\": \"Skills\",\n            \"icon\": \"sparkles\",\n            \"count\": \"$skills | count\",\n            \"children\": [\n              {\n                \"list\": \"$skills\",\n                \"empty\": \"No skills found in ~/.claude/skills, ~/.codex/skills or your Claude Code plugins.\",\n                \"item\": {\n                  \"cell\": \"$item.name\",\n                  \"subtitle\": \"{$item.agent}{$item.on | map:{true:'', else:' \u00b7 off'}} \u00b7 {$item.description | truncate:90}\",\n                  \"leading\": {\n                    \"icon\": \"sparkles\",\n                    \"hue\": \"$item.agent | hue\"\n                  },\n                  \"status\": \"$item.on | map:{true:'good', else:'neutral'}\",\n                  \"accessory\": \"chevron\",\n                  \"on\": \"open_skill\",\n                  \"args\": {\n                    \"id\": \"$item.id\"\n                  }\n                }\n              }\n            ]\n          },\n          {\n            \"label\": \"Add\",\n            \"icon\": \"plus\",\n            \"children\": [\n              {\n                \"field\": \"Search the MCP Registry\",\n                \"type\": \"search\",\n                \"bind\": \"$query\",\n                \"placeholder\": \"github, postgres, figma\u2026\",\n                \"on_submit\": \"search\"\n              },\n              {\n                \"list\": \"$results\",\n                \"empty\": \"Type a name and press Return to search the public MCP Registry.\",\n                \"item\": {\n                  \"cell\": \"{$item.title | default:$item.name}\",\n                  \"subtitle\": \"$item.description | truncate:110\",\n                  \"leading\": {\n                    \"icon\": \"$item.remotes | count | map:{0:'shippingbox', else:'globe'}\",\n                    \"hue\": \"$item.remotes | count | map:{0:'blue', else:'teal'}\"\n                  },\n                  \"accessory\": \"chevron\",\n                  \"on\": \"open_install\",\n                  \"args\": {\n                    \"name\": \"$item.name\"\n                  }\n                }\n              }\n            ]\n          }\n        ]\n      },\n      \"footer\": {\n        \"row\": [\n          {\n            \"text\": \"{$servers | where:'on' | count} on \u00b7 {$servers | count} in {$apps | where:'found' | count} apps\",\n            \"size\": \"s\",\n            \"emphasis\": \"subtle\",\n            \"grow\": true\n          },\n          {\n            \"button\": \"Read again\",\n            \"icon\": \"arrow.clockwise\",\n            \"icon_only\": true,\n            \"style\": \"plain\",\n            \"on\": \"scan\",\n            \"disabled\": \"$running.scan\"\n          }\n        ],\n        \"align\": \"center\"\n      }\n    },\n    {\n      \"id\": \"server\",\n      \"params\": {\n        \"name\": \"text\"\n      },\n      \"layout\": {\n        \"column\": [\n          {\n            \"text\": \"$params.name\",\n            \"size\": \"l\",\n            \"emphasis\": \"strong\"\n          },\n          {\n            \"text\": \"{$servers | where:'name':$params.name | pick:0 | pick:'summary'}\",\n            \"mono\": true,\n            \"size\": \"s\",\n            \"lines\": 2\n          },\n          {\n            \"list\": \"$servers | where:'name':$params.name\",\n            \"item\": {\n              \"cell\": \"$item.app_name\",\n              \"subtitle\": \"{$item.scope_label}{$item.on | map:{true:'', else:' \u00b7 switched off'}}{$item.env | count | map:{0:'', else:' \u00b7 env '}}{$item.env | join}\",\n              \"status\": \"$item.on | map:{true:'good', else:'neutral'}\",\n              \"trailing\": {\n                \"button\": \"$item.on | map:{true:'Switch off', else:'Switch on'}\",\n                \"style\": \"plain\",\n                \"on\": \"switch\",\n                \"args\": {\n                  \"id\": \"$item.id\",\n                  \"on\": \"$item.on | map:{true:false, else:true}\"\n                },\n                \"disabled\": \"$running.switch\"\n              }\n            }\n          },\n          {\n            \"row\": [\n              {\n                \"button\": \"Test\",\n                \"icon\": \"bolt.horizontal\",\n                \"style\": \"primary\",\n                \"on\": \"test\",\n                \"args\": {\n                  \"id\": \"{$servers | where:'name':$params.name | where:'on' | pick:0 | pick:'id' | default:'none'}\"\n                },\n                \"disabled\": \"$running.test\"\n              },\n              {\n                \"badge\": \"{$tested | where:'name':$params.name | pick:0 | pick:'ok' | map:{true:'Connected', false:'Failed', else:'Not tested'}}\",\n                \"tone\": \"$tested | where:'name':$params.name | pick:0 | pick:'ok' | map:{true:'good', false:'bad', else:'neutral'}\",\n                \"busy\": \"$running.test\"\n              },\n              {\n                \"spacer\": true\n              }\n            ],\n            \"align\": \"center\"\n          },\n          {\n            \"text\": \"{$tested | where:'name':$params.name | pick:0 | pick:'error'}\",\n            \"tone\": \"bad\",\n            \"size\": \"s\",\n            \"when\": \"$tested | where:'name':$params.name | pick:0 | pick:'error'\"\n          },\n          {\n            \"section\": \"Tools\",\n            \"trailing\": {\n              \"badge\": \"{$tested | where:'name':$params.name | pick:0 | pick:'tools' | count}\"\n            },\n            \"when\": \"$tested | where:'name':$params.name | pick:0 | pick:'ok'\",\n            \"children\": [\n              {\n                \"list\": \"$tested | where:'name':$params.name | pick:0 | pick:'tools'\",\n                \"empty\": \"It has no tools\",\n                \"item\": {\n                  \"cell\": \"$item.name\",\n                  \"subtitle\": \"$item.description | truncate:140\"\n                }\n              }\n            ]\n          }\n        ],\n        \"gap\": \"m\"\n      }\n    },\n    {\n      \"id\": \"install\",\n      \"params\": {\n        \"name\": \"text\"\n      },\n      \"layout\": {\n        \"column\": [\n          {\n            \"text\": \"{$results | where:'name':$params.name | pick:0 | pick:'title' | default:$params.name}\",\n            \"size\": \"l\",\n            \"emphasis\": \"strong\"\n          },\n          {\n            \"text\": \"{$results | where:'name':$params.name | pick:0 | pick:'description'}\",\n            \"size\": \"s\",\n            \"emphasis\": \"subtle\"\n          },\n          {\n            \"text\": \"$params.name\",\n            \"mono\": true,\n            \"size\": \"s\"\n          },\n          {\n            \"list\": \"$results | where:'name':$params.name | pick:0 | pick:'packages' | pick:0 | pick:'environmentVariables'\",\n            \"item\": {\n              \"cell\": \"$item.name\",\n              \"subtitle\": \"$item.description | default:''\",\n              \"status\": \"$item.isRequired | map:{true:'warn', else:'neutral'}\"\n            }\n          },\n          {\n            \"text\": \"Add it to\",\n            \"size\": \"s\",\n            \"emphasis\": \"strong\"\n          },\n          {\n            \"checklist\": \"$apps | where:'found'\",\n            \"label\": \"{$item.name}{$item.picked | map:{true:'', else:' (choose its file first)'}}\",\n            \"value\": \"$item.id\",\n            \"bind\": \"$install_to\"\n          },\n          {\n            \"row\": [\n              {\n                \"button\": \"Add\",\n                \"icon\": \"plus\",\n                \"style\": \"primary\",\n                \"on\": \"install\",\n                \"args\": {\n                  \"name\": \"$params.name\"\n                },\n                \"disabled\": \"$running.install\"\n              },\n              {\n                \"spacer\": true\n              }\n            ],\n            \"align\": \"center\"\n          },\n          {\n            \"text\": \"Add asks for its keys, which go only into the AI apps' own files. A backup of each file is kept first.\",\n            \"size\": \"s\",\n            \"emphasis\": \"subtle\"\n          }\n        ],\n        \"gap\": \"m\"\n      }\n    },\n    {\n      \"id\": \"skill\",\n      \"params\": {\n        \"id\": \"text\"\n      },\n      \"layout\": {\n        \"column\": [\n          {\n            \"text\": \"{$skills | where:'id':$params.id | pick:0 | pick:'name'}\",\n            \"size\": \"l\",\n            \"emphasis\": \"strong\"\n          },\n          {\n            \"text\": \"{$skills | where:'id':$params.id | pick:0 | pick:'agent'} \u00b7 {$skills | where:'id':$params.id | pick:0 | pick:'on' | map:{true:'on', else:'off'}}\",\n            \"size\": \"s\",\n            \"emphasis\": \"subtle\"\n          },\n          {\n            \"text\": \"{$skills | where:'id':$params.id | pick:0 | pick:'description'}\"\n          },\n          {\n            \"button\": \"{$skills | where:'id':$params.id | pick:0 | pick:'on' | map:{true:'Switch off', else:'Switch on'}}\",\n            \"on\": \"switch_skill\",\n            \"args\": {\n              \"id\": \"$params.id\",\n              \"on\": \"$skills | where:'id':$params.id | pick:0 | pick:'on' | map:{true:false, else:true}\"\n            },\n            \"when\": \"$skills | where:'id':$params.id | pick:0 | pick:'can_switch'\",\n            \"disabled\": \"$running.switch_skill\"\n          },\n          {\n            \"text\": \"To switch skills, choose the skills folder with the gear.\",\n            \"size\": \"s\",\n            \"emphasis\": \"subtle\",\n            \"when\": \"$skills | where:'id':$params.id | pick:0 | pick:'can_switch' | map:{true:false, else:true}\"\n          },\n          {\n            \"code\": \"$skills | where:'id':$params.id | pick:0 | pick:'body'\",\n            \"wrap\": true,\n            \"lines\": 18\n          },\n          {\n            \"text\": \"$skills | where:'id':$params.id | pick:0 | pick:'path'\",\n            \"mono\": true,\n            \"size\": \"s\",\n            \"emphasis\": \"subtle\"\n          }\n        ],\n        \"gap\": \"m\"\n      }\n    }\n  ],\n  \"views\": {\n    \"menubar\": {\n      \"icon\": \"server.rack\",\n      \"label\": \"{$servers | where:'on' | count}\",\n      \"card\": \"main\"\n    },\n    \"floating\": {\n      \"card\": \"main\",\n      \"width\": \"wide\"\n    }\n  },\n  \"scripts\": {\n    \"scan.sh\": \"#!/bin/sh\\n# Args 1-9: the files and folders picked in the card's settings (empty when not picked). A picked one may be changed;\\n# otherwise the card reads where each AI app keeps it, and changes nothing there.\\nP_claude_code=$1 P_claude_desktop=$2 P_cursor=$3 P_vscode=$4 P_windsurf=$5 P_gemini=$6 P_codex=$7 P_claude_skills=$8 P_codex_skills=$9\\nshift 9\\nAS=\\\"$HOME/Library/Application Support\\\"\\nAPPS=\\\"claude_code claude_desktop cursor vscode windsurf gemini codex\\\"\\npicked() {\\n  case \\\"$1\\\" in\\n    claude_code) printf '%s' \\\"$P_claude_code\\\" ;; claude_desktop) printf '%s' \\\"$P_claude_desktop\\\" ;; cursor) printf '%s' \\\"$P_cursor\\\" ;;\\n    vscode) printf '%s' \\\"$P_vscode\\\" ;; windsurf) printf '%s' \\\"$P_windsurf\\\" ;; gemini) printf '%s' \\\"$P_gemini\\\" ;; codex) printf '%s' \\\"$P_codex\\\" ;;\\n    claude_skills) printf '%s' \\\"$P_claude_skills\\\" ;; codex_skills) printf '%s' \\\"$P_codex_skills\\\" ;;\\n  esac\\n}\\ndefault_of() {\\n  case \\\"$1\\\" in\\n    claude_code) printf '%s' \\\"$HOME/.claude.json\\\" ;;\\n    claude_desktop) printf '%s' \\\"$AS/Claude/claude_desktop_config.json\\\" ;;\\n    cursor) printf '%s' \\\"$HOME/.cursor/mcp.json\\\" ;;\\n    vscode) printf '%s' \\\"$AS/Code/User/mcp.json\\\" ;;\\n    windsurf) printf '%s' \\\"$HOME/.codeium/windsurf/mcp_config.json\\\" ;;\\n    gemini) printf '%s' \\\"$HOME/.gemini/settings.json\\\" ;;\\n    codex) printf '%s' \\\"$HOME/.codex/config.toml\\\" ;;\\n    claude_skills) printf '%s' \\\"$HOME/.claude/skills\\\" ;;\\n    codex_skills) printf '%s' \\\"$HOME/.codex/skills\\\" ;;\\n  esac\\n}\\nfile_of() { p=$(picked \\\"$1\\\"); [ -n \\\"$p\\\" ] && printf '%s' \\\"$p\\\" || default_of \\\"$1\\\"; }\\nname_of() {\\n  case \\\"$1\\\" in\\n    claude_code) echo \\\"Claude Code\\\" ;; claude_desktop) echo \\\"Claude Desktop\\\" ;; cursor) echo \\\"Cursor\\\" ;;\\n    vscode) echo \\\"VS Code\\\" ;; windsurf) echo \\\"Windsurf\\\" ;; gemini) echo \\\"Gemini CLI\\\" ;; codex) echo \\\"Codex\\\" ;;\\n  esac\\n}\\n# Where an app keeps its servers inside its JSON file, as a jq path.\\nbase_of() {\\n  case \\\"$1\\\" in\\n    claude_code) case \\\"$2\\\" in local:*) jq -cn --arg p \\\"${2#local:}\\\" '[\\\"projects\\\", $p, \\\"mcpServers\\\"]' ;; *) echo '[\\\"mcpServers\\\"]' ;; esac ;;\\n    vscode) echo '[\\\"servers\\\"]' ;;\\n    *) echo '[\\\"mcpServers\\\"]' ;;\\n  esac\\n}\\nfail() { printf '%s\\\\n' \\\"$*\\\" >&2; exit 1; }\\n# The card's own folder (tmp/<card>/): switched-off servers and backups live here, never in the card's state.\\nOWN=$(dirname \\\"${TMPDIR%/}\\\")\\nPARKED=\\\"$OWN/parked.json\\\"\\n[ -f \\\"$PARKED\\\" ] || { umask 077; echo '[]' > \\\"$PARKED\\\"; }\\n# A file may only be changed when the person picked it in settings.\\nwritable_of() {\\n  p=$(picked \\\"$1\\\")\\n  [ -n \\\"$p\\\" ] || fail \\\"To change $(name_of \\\"$1\\\")'s servers, choose its file in this card's settings (the gear): $(default_of \\\"$1\\\" | sed \\\"s|^$HOME|~|\\\")\\\"\\n  [ -f \\\"$p\\\" ] || fail \\\"$(name_of \\\"$1\\\")'s file isn't there any more: $p\\\"\\n  printf '%s' \\\"$p\\\"\\n}\\n# A copy of the file before each change, the newest 30 kept.\\nbackup() {\\n  mkdir -p \\\"$OWN/backups\\\" && chmod 700 \\\"$OWN/backups\\\"\\n  b=\\\"$OWN/backups/$2-$(date +%Y%m%d-%H%M%S)-$$.bak\\\"\\n  cp -p \\\"$1\\\" \\\"$b\\\" || fail \\\"Couldn't back up $1\\\"\\n  ls -t \\\"$OWN/backups\\\"/*.bak 2>/dev/null | tail -n +31 | while IFS= read -r old; do rm -f \\\"$old\\\"; done\\n}\\n# The file's modification time and size, taken before reading it (seen) and checked again just before writing\\n# (unchanged), so a change the AI app made meanwhile isn't written over.\\nstamp_of() { stat -c '%.9Y %s' \\\"$1\\\" 2>/dev/null || stat -f '%Fm %z' \\\"$1\\\" 2>/dev/null; }\\nseen() { SEEN=$(stamp_of \\\"$1\\\"); }\\nunchanged() { [ -z \\\"$SEEN\\\" ] || [ \\\"$(stamp_of \\\"$1\\\")\\\" = \\\"$SEEN\\\" ]; }\\n# Write new text over a file in place (keeps its permissions; the sandbox allows only the picked file itself).\\nreplace() {\\n  [ -s \\\"$2\\\" ] || fail \\\"Nothing to write\\\"\\n  unchanged \\\"$1\\\" || fail \\\"$1 changed while this ran, so nothing was written. Try again\\\"\\n  cat \\\"$2\\\" > \\\"$1\\\" || fail \\\"Couldn't write $1\\\"\\n}\\n\\n# Every MCP server in the AI apps' config files, as { apps, servers, names }. Values of env vars and headers never\\n# leave this script (only their names), and arguments or URLs that look like keys are masked.\\n# Arg 1: Codex's [mcp_servers] tables, as JSON (the card reads config.toml with parse:'toml').\\ncodex=${1:-null}\\n[ \\\"$codex\\\" = \\\"\\\" ] && codex=null\\nout=\\\"$TMPDIR/servers.jsonl\\\"\\napps=\\\"$TMPDIR/apps.jsonl\\\"\\n: > \\\"$out\\\"; : > \\\"$apps\\\"\\nNORM='\\ndef mask_url: if . == null then null else\\n  sub(\\\"://[^/@\\\\\\\\s]+@\\\"; \\\"://\u2022\u2022\u2022@\\\") | sub(\\\"(?<p>[?&][^=&]*(key|token|secret|auth)[^=&]*=)[^&]*\\\"; \\\"\\\\(.p)\u2022\u2022\u2022\\\"; \\\"gi\\\") end;\\ndef mask_args: . as $a | [range(length) as $i | ($a[$i] | tostring) as $x | ($i > 0 and true | if . then ($a[$i-1] | tostring) else \\\"\\\" end) as $prev\\n  | if ($prev | test(\\\"^(-H|--header|--headers)$\\\")) then (if ($x | test(\\\":\\\")) then ($x | sub(\\\":.*$\\\"; \\\": \u2022\u2022\u2022\\\")) else \\\"\u2022\u2022\u2022\\\" end)\\n    elif ($prev | test(\\\"(?i)^-{1,2}[a-z_-]*(key|token|secret|password|auth)\\\")) then \\\"\u2022\u2022\u2022\\\"\\n    elif ($x | test(\\\"^[A-Za-z][A-Za-z0-9+.-]*://\\\")) then ($x | mask_url)\\n    elif ($x | test(\\\"(?i)bearer\\\\\\\\s\\\")) then ($x | sub(\\\"(?i)(?<b>bearer)\\\\\\\\s.*$\\\"; \\\"\\\\(.b) \u2022\u2022\u2022\\\"))\\n    elif ($x | test(\\\"(?i)(key|token|secret|password)[^=]*=\\\")) then ($x | sub(\\\"=.*$\\\"; \\\"=\u2022\u2022\u2022\\\"))\\n    elif ($x | test(\\\"^(sk|ghp|gho|ghs|github_pat|xox[a-z]|pk|rk)[-_][A-Za-z0-9_-]{12,}\\\")) then \\\"\u2022\u2022\u2022\\\"\\n    else ($x | mask_url) end];\\ndef one($app; $appname; $scope; $label):\\n  if type != \\\"object\\\" then empty else to_entries[] | select(.value | type == \\\"object\\\") | .value as $v | ($v.url // $v.serverUrl // $v.httpUrl) as $url | {\\n    id: ($app + \\\":\\\" + $scope + \\\":\\\" + .key), name: .key, app: $app, app_name: $appname, scope: $scope, scope_label: $label,\\n    kind: (if $url then (if ($v.type == \\\"sse\\\" or $v.transport == \\\"sse\\\") then \\\"sse\\\" else \\\"http\\\" end) else \\\"stdio\\\" end),\\n    command: ($v.command // null), args: (($v.args // []) | if type == \\\"array\\\" then mask_args else [] end), url: ($url | mask_url),\\n    env: (($v.env // {}) | if type == \\\"object\\\" then keys else [] end),\\n    headers: (($v.headers // $v.http_headers // {}) | if type == \\\"object\\\" then keys else [] end),\\n    on: ($v.disabled != true and $v.enabled != false)\\n  } | .summary = (if .kind == \\\"stdio\\\" then ([.command // \\\"\\\"] + .args | join(\\\" \\\")) else .url end)\\n  end;'\\nfor a in $APPS; do\\n  f=$(file_of \\\"$a\\\"); p=$(picked \\\"$a\\\"); n=$(name_of \\\"$a\\\")\\n  err=\\\"\\\"\\n  if [ ! -f \\\"$f\\\" ]; then found=false\\n  elif [ \\\"$a\\\" = codex ]; then\\n    found=true\\n    [ \\\"$codex\\\" = null ] && grep -q '^[[:space:]]*\\\\[mcp_servers' \\\"$f\\\" && err=\\\"Its config.toml couldn't be read as TOML\\\"\\n    printf '%s' \\\"$codex\\\" | jq -c --arg app \\\"$a\\\" --arg appname \\\"$n\\\" \\\"$NORM one(\\\\$app; \\\\$appname; \\\\\\\"user\\\\\\\"; \\\\\\\"User\\\\\\\")\\\" >> \\\"$out\\\" 2>/dev/null\\n  else\\n    found=true\\n    if ! jq -c --arg app \\\"$a\\\" --arg appname \\\"$n\\\" \\\"$NORM\\\"'\\n      if $app == \\\"claude_code\\\" then\\n        ((.mcpServers // {}) | one($app; $appname; \\\"user\\\"; \\\"User\\\")),\\n        ((.projects // {}) | to_entries[] | .key as $p | (.value.mcpServers // {}) | one($app; $appname; \\\"local:\\\" + $p; ($p | split(\\\"/\\\") | last)))\\n      elif $app == \\\"vscode\\\" then (.servers // {}) | one($app; $appname; \\\"user\\\"; \\\"User\\\")\\n      else (.mcpServers // {}) | one($app; $appname; \\\"user\\\"; \\\"User\\\") end' \\\"$f\\\" >> \\\"$out\\\" 2>/dev/null; then\\n      err=\\\"Has comments or isn't plain JSON, so it's shown as empty and left alone\\\"\\n    fi\\n  fi\\n  jq -cn --arg id \\\"$a\\\" --arg name \\\"$n\\\" --arg path \\\"$(printf '%s' \\\"$f\\\" | sed \\\"s|^$HOME|~|\\\")\\\" --argjson found \\\"$found\\\" \\\\\\n    --argjson picked \\\"$([ -n \\\"$p\\\" ] && echo true || echo false)\\\" --arg error \\\"$err\\\" \\\\\\n    '{ id: $id, name: $name, path: $path, found: $found, picked: $picked, error: (if $error == \\\"\\\" then null else $error end) }' >> \\\"$apps\\\"\\ndone\\n# Servers switched off here: kept in the card's own folder, shown with on: false.\\njq -c '.[] | .info + { on: false, parked: true }' \\\"$PARKED\\\" >> \\\"$out\\\" 2>/dev/null\\njq -n --slurpfile s \\\"$out\\\" --slurpfile a \\\"$apps\\\" '\\n  ($s | sort_by(.name | ascii_downcase)) as $servers\\n  | { servers: $servers,\\n      apps: ($a | map(.id as $id | . + { count: ([$servers[] | select(.app == $id)] | length) })),\\n      names: ($servers | group_by(.name | ascii_downcase) | map({\\n        name: .[0].name, kind: .[0].kind, summary: .[0].summary,\\n        apps: (map(.app_name) | unique), on: (map(select(.on)) | length), total: length })) }'\\n\",\n    \"codex.sh\": \"#!/bin/sh\\n# Args 1-9: the files and folders picked in the card's settings (empty when not picked). A picked one may be changed;\\n# otherwise the card reads where each AI app keeps it, and changes nothing there.\\nP_claude_code=$1 P_claude_desktop=$2 P_cursor=$3 P_vscode=$4 P_windsurf=$5 P_gemini=$6 P_codex=$7 P_claude_skills=$8 P_codex_skills=$9\\nshift 9\\nAS=\\\"$HOME/Library/Application Support\\\"\\nAPPS=\\\"claude_code claude_desktop cursor vscode windsurf gemini codex\\\"\\npicked() {\\n  case \\\"$1\\\" in\\n    claude_code) printf '%s' \\\"$P_claude_code\\\" ;; claude_desktop) printf '%s' \\\"$P_claude_desktop\\\" ;; cursor) printf '%s' \\\"$P_cursor\\\" ;;\\n    vscode) printf '%s' \\\"$P_vscode\\\" ;; windsurf) printf '%s' \\\"$P_windsurf\\\" ;; gemini) printf '%s' \\\"$P_gemini\\\" ;; codex) printf '%s' \\\"$P_codex\\\" ;;\\n    claude_skills) printf '%s' \\\"$P_claude_skills\\\" ;; codex_skills) printf '%s' \\\"$P_codex_skills\\\" ;;\\n  esac\\n}\\ndefault_of() {\\n  case \\\"$1\\\" in\\n    claude_code) printf '%s' \\\"$HOME/.claude.json\\\" ;;\\n    claude_desktop) printf '%s' \\\"$AS/Claude/claude_desktop_config.json\\\" ;;\\n    cursor) printf '%s' \\\"$HOME/.cursor/mcp.json\\\" ;;\\n    vscode) printf '%s' \\\"$AS/Code/User/mcp.json\\\" ;;\\n    windsurf) printf '%s' \\\"$HOME/.codeium/windsurf/mcp_config.json\\\" ;;\\n    gemini) printf '%s' \\\"$HOME/.gemini/settings.json\\\" ;;\\n    codex) printf '%s' \\\"$HOME/.codex/config.toml\\\" ;;\\n    claude_skills) printf '%s' \\\"$HOME/.claude/skills\\\" ;;\\n    codex_skills) printf '%s' \\\"$HOME/.codex/skills\\\" ;;\\n  esac\\n}\\nfile_of() { p=$(picked \\\"$1\\\"); [ -n \\\"$p\\\" ] && printf '%s' \\\"$p\\\" || default_of \\\"$1\\\"; }\\nname_of() {\\n  case \\\"$1\\\" in\\n    claude_code) echo \\\"Claude Code\\\" ;; claude_desktop) echo \\\"Claude Desktop\\\" ;; cursor) echo \\\"Cursor\\\" ;;\\n    vscode) echo \\\"VS Code\\\" ;; windsurf) echo \\\"Windsurf\\\" ;; gemini) echo \\\"Gemini CLI\\\" ;; codex) echo \\\"Codex\\\" ;;\\n  esac\\n}\\n# Where an app keeps its servers inside its JSON file, as a jq path.\\nbase_of() {\\n  case \\\"$1\\\" in\\n    claude_code) case \\\"$2\\\" in local:*) jq -cn --arg p \\\"${2#local:}\\\" '[\\\"projects\\\", $p, \\\"mcpServers\\\"]' ;; *) echo '[\\\"mcpServers\\\"]' ;; esac ;;\\n    vscode) echo '[\\\"servers\\\"]' ;;\\n    *) echo '[\\\"mcpServers\\\"]' ;;\\n  esac\\n}\\nfail() { printf '%s\\\\n' \\\"$*\\\" >&2; exit 1; }\\n# The card's own folder (tmp/<card>/): switched-off servers and backups live here, never in the card's state.\\nOWN=$(dirname \\\"${TMPDIR%/}\\\")\\nPARKED=\\\"$OWN/parked.json\\\"\\n[ -f \\\"$PARKED\\\" ] || { umask 077; echo '[]' > \\\"$PARKED\\\"; }\\n# A file may only be changed when the person picked it in settings.\\nwritable_of() {\\n  p=$(picked \\\"$1\\\")\\n  [ -n \\\"$p\\\" ] || fail \\\"To change $(name_of \\\"$1\\\")'s servers, choose its file in this card's settings (the gear): $(default_of \\\"$1\\\" | sed \\\"s|^$HOME|~|\\\")\\\"\\n  [ -f \\\"$p\\\" ] || fail \\\"$(name_of \\\"$1\\\")'s file isn't there any more: $p\\\"\\n  printf '%s' \\\"$p\\\"\\n}\\n# A copy of the file before each change, the newest 30 kept.\\nbackup() {\\n  mkdir -p \\\"$OWN/backups\\\" && chmod 700 \\\"$OWN/backups\\\"\\n  b=\\\"$OWN/backups/$2-$(date +%Y%m%d-%H%M%S)-$$.bak\\\"\\n  cp -p \\\"$1\\\" \\\"$b\\\" || fail \\\"Couldn't back up $1\\\"\\n  ls -t \\\"$OWN/backups\\\"/*.bak 2>/dev/null | tail -n +31 | while IFS= read -r old; do rm -f \\\"$old\\\"; done\\n}\\n# The file's modification time and size, taken before reading it (seen) and checked again just before writing\\n# (unchanged), so a change the AI app made meanwhile isn't written over.\\nstamp_of() { stat -c '%.9Y %s' \\\"$1\\\" 2>/dev/null || stat -f '%Fm %z' \\\"$1\\\" 2>/dev/null; }\\nseen() { SEEN=$(stamp_of \\\"$1\\\"); }\\nunchanged() { [ -z \\\"$SEEN\\\" ] || [ \\\"$(stamp_of \\\"$1\\\")\\\" = \\\"$SEEN\\\" ]; }\\n# Write new text over a file in place (keeps its permissions; the sandbox allows only the picked file itself).\\nreplace() {\\n  [ -s \\\"$2\\\" ] || fail \\\"Nothing to write\\\"\\n  unchanged \\\"$1\\\" || fail \\\"$1 changed while this ran, so nothing was written. Try again\\\"\\n  cat \\\"$2\\\" > \\\"$1\\\" || fail \\\"Couldn't write $1\\\"\\n}\\n\\n# Codex's config.toml as text, for parse:'toml' (only inside the scan action, never kept in the card's state).\\nf=$(file_of codex)\\n[ -f \\\"$f\\\" ] && cat \\\"$f\\\"\\nexit 0\\n\",\n    \"stamp.sh\": \"#!/bin/sh\\n# Args 1-9: the files and folders picked in the card's settings (empty when not picked). A picked one may be changed;\\n# otherwise the card reads where each AI app keeps it, and changes nothing there.\\nP_claude_code=$1 P_claude_desktop=$2 P_cursor=$3 P_vscode=$4 P_windsurf=$5 P_gemini=$6 P_codex=$7 P_claude_skills=$8 P_codex_skills=$9\\nshift 9\\nAS=\\\"$HOME/Library/Application Support\\\"\\nAPPS=\\\"claude_code claude_desktop cursor vscode windsurf gemini codex\\\"\\npicked() {\\n  case \\\"$1\\\" in\\n    claude_code) printf '%s' \\\"$P_claude_code\\\" ;; claude_desktop) printf '%s' \\\"$P_claude_desktop\\\" ;; cursor) printf '%s' \\\"$P_cursor\\\" ;;\\n    vscode) printf '%s' \\\"$P_vscode\\\" ;; windsurf) printf '%s' \\\"$P_windsurf\\\" ;; gemini) printf '%s' \\\"$P_gemini\\\" ;; codex) printf '%s' \\\"$P_codex\\\" ;;\\n    claude_skills) printf '%s' \\\"$P_claude_skills\\\" ;; codex_skills) printf '%s' \\\"$P_codex_skills\\\" ;;\\n  esac\\n}\\ndefault_of() {\\n  case \\\"$1\\\" in\\n    claude_code) printf '%s' \\\"$HOME/.claude.json\\\" ;;\\n    claude_desktop) printf '%s' \\\"$AS/Claude/claude_desktop_config.json\\\" ;;\\n    cursor) printf '%s' \\\"$HOME/.cursor/mcp.json\\\" ;;\\n    vscode) printf '%s' \\\"$AS/Code/User/mcp.json\\\" ;;\\n    windsurf) printf '%s' \\\"$HOME/.codeium/windsurf/mcp_config.json\\\" ;;\\n    gemini) printf '%s' \\\"$HOME/.gemini/settings.json\\\" ;;\\n    codex) printf '%s' \\\"$HOME/.codex/config.toml\\\" ;;\\n    claude_skills) printf '%s' \\\"$HOME/.claude/skills\\\" ;;\\n    codex_skills) printf '%s' \\\"$HOME/.codex/skills\\\" ;;\\n  esac\\n}\\nfile_of() { p=$(picked \\\"$1\\\"); [ -n \\\"$p\\\" ] && printf '%s' \\\"$p\\\" || default_of \\\"$1\\\"; }\\nname_of() {\\n  case \\\"$1\\\" in\\n    claude_code) echo \\\"Claude Code\\\" ;; claude_desktop) echo \\\"Claude Desktop\\\" ;; cursor) echo \\\"Cursor\\\" ;;\\n    vscode) echo \\\"VS Code\\\" ;; windsurf) echo \\\"Windsurf\\\" ;; gemini) echo \\\"Gemini CLI\\\" ;; codex) echo \\\"Codex\\\" ;;\\n  esac\\n}\\n# Where an app keeps its servers inside its JSON file, as a jq path.\\nbase_of() {\\n  case \\\"$1\\\" in\\n    claude_code) case \\\"$2\\\" in local:*) jq -cn --arg p \\\"${2#local:}\\\" '[\\\"projects\\\", $p, \\\"mcpServers\\\"]' ;; *) echo '[\\\"mcpServers\\\"]' ;; esac ;;\\n    vscode) echo '[\\\"servers\\\"]' ;;\\n    *) echo '[\\\"mcpServers\\\"]' ;;\\n  esac\\n}\\nfail() { printf '%s\\\\n' \\\"$*\\\" >&2; exit 1; }\\n# The card's own folder (tmp/<card>/): switched-off servers and backups live here, never in the card's state.\\nOWN=$(dirname \\\"${TMPDIR%/}\\\")\\nPARKED=\\\"$OWN/parked.json\\\"\\n[ -f \\\"$PARKED\\\" ] || { umask 077; echo '[]' > \\\"$PARKED\\\"; }\\n# A file may only be changed when the person picked it in settings.\\nwritable_of() {\\n  p=$(picked \\\"$1\\\")\\n  [ -n \\\"$p\\\" ] || fail \\\"To change $(name_of \\\"$1\\\")'s servers, choose its file in this card's settings (the gear): $(default_of \\\"$1\\\" | sed \\\"s|^$HOME|~|\\\")\\\"\\n  [ -f \\\"$p\\\" ] || fail \\\"$(name_of \\\"$1\\\")'s file isn't there any more: $p\\\"\\n  printf '%s' \\\"$p\\\"\\n}\\n# A copy of the file before each change, the newest 30 kept.\\nbackup() {\\n  mkdir -p \\\"$OWN/backups\\\" && chmod 700 \\\"$OWN/backups\\\"\\n  b=\\\"$OWN/backups/$2-$(date +%Y%m%d-%H%M%S)-$$.bak\\\"\\n  cp -p \\\"$1\\\" \\\"$b\\\" || fail \\\"Couldn't back up $1\\\"\\n  ls -t \\\"$OWN/backups\\\"/*.bak 2>/dev/null | tail -n +31 | while IFS= read -r old; do rm -f \\\"$old\\\"; done\\n}\\n# The file's modification time and size, taken before reading it (seen) and checked again just before writing\\n# (unchanged), so a change the AI app made meanwhile isn't written over.\\nstamp_of() { stat -c '%.9Y %s' \\\"$1\\\" 2>/dev/null || stat -f '%Fm %z' \\\"$1\\\" 2>/dev/null; }\\nseen() { SEEN=$(stamp_of \\\"$1\\\"); }\\nunchanged() { [ -z \\\"$SEEN\\\" ] || [ \\\"$(stamp_of \\\"$1\\\")\\\" = \\\"$SEEN\\\" ]; }\\n# Write new text over a file in place (keeps its permissions; the sandbox allows only the picked file itself).\\nreplace() {\\n  [ -s \\\"$2\\\" ] || fail \\\"Nothing to write\\\"\\n  unchanged \\\"$1\\\" || fail \\\"$1 changed while this ran, so nothing was written. Try again\\\"\\n  cat \\\"$2\\\" > \\\"$1\\\" || fail \\\"Couldn't write $1\\\"\\n}\\n\\n# When each config file last changed (and the card's own switched-off list), so the card reads them again only then.\\nfor a in $APPS; do f=$(file_of \\\"$a\\\"); [ -f \\\"$f\\\" ] && stat -f '%m' \\\"$f\\\" 2>/dev/null || echo 0; done | tr '\\\\n' '-'\\nstat -f '%m' \\\"$PARKED\\\" 2>/dev/null || echo 0\\n\",\n    \"test.sh\": \"#!/bin/sh\\n# Args 1-9: the files and folders picked in the card's settings (empty when not picked). A picked one may be changed;\\n# otherwise the card reads where each AI app keeps it, and changes nothing there.\\nP_claude_code=$1 P_claude_desktop=$2 P_cursor=$3 P_vscode=$4 P_windsurf=$5 P_gemini=$6 P_codex=$7 P_claude_skills=$8 P_codex_skills=$9\\nshift 9\\nAS=\\\"$HOME/Library/Application Support\\\"\\nAPPS=\\\"claude_code claude_desktop cursor vscode windsurf gemini codex\\\"\\npicked() {\\n  case \\\"$1\\\" in\\n    claude_code) printf '%s' \\\"$P_claude_code\\\" ;; claude_desktop) printf '%s' \\\"$P_claude_desktop\\\" ;; cursor) printf '%s' \\\"$P_cursor\\\" ;;\\n    vscode) printf '%s' \\\"$P_vscode\\\" ;; windsurf) printf '%s' \\\"$P_windsurf\\\" ;; gemini) printf '%s' \\\"$P_gemini\\\" ;; codex) printf '%s' \\\"$P_codex\\\" ;;\\n    claude_skills) printf '%s' \\\"$P_claude_skills\\\" ;; codex_skills) printf '%s' \\\"$P_codex_skills\\\" ;;\\n  esac\\n}\\ndefault_of() {\\n  case \\\"$1\\\" in\\n    claude_code) printf '%s' \\\"$HOME/.claude.json\\\" ;;\\n    claude_desktop) printf '%s' \\\"$AS/Claude/claude_desktop_config.json\\\" ;;\\n    cursor) printf '%s' \\\"$HOME/.cursor/mcp.json\\\" ;;\\n    vscode) printf '%s' \\\"$AS/Code/User/mcp.json\\\" ;;\\n    windsurf) printf '%s' \\\"$HOME/.codeium/windsurf/mcp_config.json\\\" ;;\\n    gemini) printf '%s' \\\"$HOME/.gemini/settings.json\\\" ;;\\n    codex) printf '%s' \\\"$HOME/.codex/config.toml\\\" ;;\\n    claude_skills) printf '%s' \\\"$HOME/.claude/skills\\\" ;;\\n    codex_skills) printf '%s' \\\"$HOME/.codex/skills\\\" ;;\\n  esac\\n}\\nfile_of() { p=$(picked \\\"$1\\\"); [ -n \\\"$p\\\" ] && printf '%s' \\\"$p\\\" || default_of \\\"$1\\\"; }\\nname_of() {\\n  case \\\"$1\\\" in\\n    claude_code) echo \\\"Claude Code\\\" ;; claude_desktop) echo \\\"Claude Desktop\\\" ;; cursor) echo \\\"Cursor\\\" ;;\\n    vscode) echo \\\"VS Code\\\" ;; windsurf) echo \\\"Windsurf\\\" ;; gemini) echo \\\"Gemini CLI\\\" ;; codex) echo \\\"Codex\\\" ;;\\n  esac\\n}\\n# Where an app keeps its servers inside its JSON file, as a jq path.\\nbase_of() {\\n  case \\\"$1\\\" in\\n    claude_code) case \\\"$2\\\" in local:*) jq -cn --arg p \\\"${2#local:}\\\" '[\\\"projects\\\", $p, \\\"mcpServers\\\"]' ;; *) echo '[\\\"mcpServers\\\"]' ;; esac ;;\\n    vscode) echo '[\\\"servers\\\"]' ;;\\n    *) echo '[\\\"mcpServers\\\"]' ;;\\n  esac\\n}\\nfail() { printf '%s\\\\n' \\\"$*\\\" >&2; exit 1; }\\n# The card's own folder (tmp/<card>/): switched-off servers and backups live here, never in the card's state.\\nOWN=$(dirname \\\"${TMPDIR%/}\\\")\\nPARKED=\\\"$OWN/parked.json\\\"\\n[ -f \\\"$PARKED\\\" ] || { umask 077; echo '[]' > \\\"$PARKED\\\"; }\\n# A file may only be changed when the person picked it in settings.\\nwritable_of() {\\n  p=$(picked \\\"$1\\\")\\n  [ -n \\\"$p\\\" ] || fail \\\"To change $(name_of \\\"$1\\\")'s servers, choose its file in this card's settings (the gear): $(default_of \\\"$1\\\" | sed \\\"s|^$HOME|~|\\\")\\\"\\n  [ -f \\\"$p\\\" ] || fail \\\"$(name_of \\\"$1\\\")'s file isn't there any more: $p\\\"\\n  printf '%s' \\\"$p\\\"\\n}\\n# A copy of the file before each change, the newest 30 kept.\\nbackup() {\\n  mkdir -p \\\"$OWN/backups\\\" && chmod 700 \\\"$OWN/backups\\\"\\n  b=\\\"$OWN/backups/$2-$(date +%Y%m%d-%H%M%S)-$$.bak\\\"\\n  cp -p \\\"$1\\\" \\\"$b\\\" || fail \\\"Couldn't back up $1\\\"\\n  ls -t \\\"$OWN/backups\\\"/*.bak 2>/dev/null | tail -n +31 | while IFS= read -r old; do rm -f \\\"$old\\\"; done\\n}\\n# The file's modification time and size, taken before reading it (seen) and checked again just before writing\\n# (unchanged), so a change the AI app made meanwhile isn't written over.\\nstamp_of() { stat -c '%.9Y %s' \\\"$1\\\" 2>/dev/null || stat -f '%Fm %z' \\\"$1\\\" 2>/dev/null; }\\nseen() { SEEN=$(stamp_of \\\"$1\\\"); }\\nunchanged() { [ -z \\\"$SEEN\\\" ] || [ \\\"$(stamp_of \\\"$1\\\")\\\" = \\\"$SEEN\\\" ]; }\\n# Write new text over a file in place (keeps its permissions; the sandbox allows only the picked file itself).\\nreplace() {\\n  [ -s \\\"$2\\\" ] || fail \\\"Nothing to write\\\"\\n  unchanged \\\"$1\\\" || fail \\\"$1 changed while this ran, so nothing was written. Try again\\\"\\n  cat \\\"$2\\\" > \\\"$1\\\" || fail \\\"Couldn't write $1\\\"\\n}\\n\\n# Connect to one server the way an AI app does (MCP's initialize, then tools/list) and print\\n# { id, name, ok, took (seconds), server, tools: [{ name, description }], error }.\\n# Args: id, then Codex's [mcp_servers] as JSON (from parse:'toml').\\nid=$1 codex=${2:-null}\\n[ \\\"$codex\\\" = \\\"\\\" ] && codex=null\\na=${id%%:*}; rest=${id#*:}; name=${id##*:}; scope=${rest%:*}\\nf=$(file_of \\\"$a\\\")\\nstarted=$(date +%s)\\nentry=null\\nresult() { # ok error tools server\\n  # A server's own error text may repeat a key it was given: the entry's env and header values never leave this script.\\n  jq -cn --arg id \\\"$id\\\" --arg name \\\"$name\\\" --argjson ok \\\"$1\\\" --arg error \\\"$2\\\" --argjson tools \\\"${3:-[]}\\\" --argjson server \\\"${4:-null}\\\" \\\\\\n    --argjson took \\\"$(( $(date +%s) - started ))\\\" --argjson entry \\\"${entry:-null}\\\" \\\\\\n    '([($entry // {}) | (.env, .headers, .http_headers) | objects | .[] | tostring | select(length >= 4)]) as $secrets\\n     | (reduce $secrets[] as $v ($error; split($v) | join(\\\"\u2022\u2022\u2022\\\"))) as $error\\n     | { id: $id, name: $name, ok: $ok, took: $took, at: now, server: $server, tools: $tools, error: (if $error == \\\"\\\" then null else $error end) }'\\n  exit 0\\n}\\nentry=$(jq -c --arg id \\\"$id\\\" 'map(select(.id == $id)) | .[0].entry // null' \\\"$PARKED\\\")\\nif [ \\\"$entry\\\" = null ]; then\\n  if [ \\\"$a\\\" = codex ]; then\\n    entry=$(printf '%s' \\\"$codex\\\" | jq -c --arg n \\\"$name\\\" '.[$n] // null')\\n  else\\n    [ -f \\\"$f\\\" ] || result false \\\"$(name_of \\\"$a\\\")'s file isn't there\\\"\\n    entry=$(jq -c --argjson b \\\"$(base_of \\\"$a\\\" \\\"$scope\\\")\\\" --arg n \\\"$name\\\" 'getpath($b + [$n])' \\\"$f\\\" 2>/dev/null)\\n  fi\\nfi\\n[ -n \\\"$entry\\\" ] && [ \\\"$entry\\\" != null ] || result false \\\"Couldn't find $name's settings (a switched-off Codex server is tested once it's on)\\\"\\nget() { printf '%s' \\\"$entry\\\" | jq -r \\\"$1\\\"; }\\nurl=$(get '.url // .serverUrl // .httpUrl // empty')\\nINIT='{\\\"jsonrpc\\\":\\\"2.0\\\",\\\"id\\\":1,\\\"method\\\":\\\"initialize\\\",\\\"params\\\":{\\\"protocolVersion\\\":\\\"2025-06-18\\\",\\\"capabilities\\\":{},\\\"clientInfo\\\":{\\\"name\\\":\\\"tailapps-mcp-check\\\",\\\"version\\\":\\\"1.0\\\"}}}'\\nREADY='{\\\"jsonrpc\\\":\\\"2.0\\\",\\\"method\\\":\\\"notifications/initialized\\\"}'\\nlist() { printf '{\\\"jsonrpc\\\":\\\"2.0\\\",\\\"id\\\":%s,\\\"method\\\":\\\"tools/list\\\"%s}' \\\"$1\\\" \\\"$([ -n \\\"$2\\\" ] && printf ',\\\"params\\\":{\\\"cursor\\\":%s}' \\\"$(jq -cn --arg c \\\"$2\\\" '$c')\\\")\\\"; }\\n# The answer with this id among the lines a server wrote (partial lines are skipped).\\nanswer() { jq -cR --argjson id \\\"$1\\\" 'fromjson? | select(type == \\\"object\\\" and .id == $id)' \\\"$2\\\" 2>/dev/null | head -n 1; }\\ntools=\\\"$TMPDIR/tools.jsonl\\\"; : > \\\"$tools\\\"\\n\\nif [ -n \\\"$url\\\" ]; then\\n  [ \\\"$(get '.type // .transport // empty')\\\" = sse ] && result false \\\"This server uses the older SSE kind, which the check doesn't speak yet\\\"\\n  set --\\n  for k in $(get '(.headers // .http_headers // {}) | keys[]' | tr '\\\\n' ' '); do\\n    set -- \\\"$@\\\" -H \\\"$k: $(printf '%s' \\\"$entry\\\" | jq -r --arg k \\\"$k\\\" '(.headers // .http_headers)[$k] | tostring')\\\"\\n  done\\n  post() { # body -> response body in $TMPDIR/body, headers in $TMPDIR/h\\n    code=$(curl -sS -m 30 -o \\\"$TMPDIR/body\\\" -D \\\"$TMPDIR/h\\\" -w '%{http_code}' -H 'Content-Type: application/json' \\\\\\n      -H 'Accept: application/json, text/event-stream' -H 'MCP-Protocol-Version: 2025-06-18' \\\\\\n      ${session:+-H \\\"Mcp-Session-Id: $session\\\"} \\\"$@\\\" --data-binary \\\"$body\\\" \\\"$url\\\" 2>\\\"$TMPDIR/err\\\") || result false \\\"Couldn't reach it: $(tail -n 1 \\\"$TMPDIR/err\\\")\\\"\\n    case \\\"$code\\\" in 2*) ;; 401|403) result false \\\"It needs a sign-in (status $code). Sign in from your AI app; this check can't\\\" ;; *) result false \\\"It answered with status $code\\\" ;; esac\\n    # Streamed answers come as `data:` lines.\\n    sed -n 's/^data: *//p' \\\"$TMPDIR/body\\\" > \\\"$TMPDIR/events\\\"\\n    [ -s \\\"$TMPDIR/events\\\" ] && cat \\\"$TMPDIR/events\\\" > \\\"$TMPDIR/body\\\"\\n    tr -d '\\\\r' < \\\"$TMPDIR/body\\\" > \\\"$TMPDIR/b2\\\" && echo >> \\\"$TMPDIR/b2\\\"\\n  }\\n  session=\\\"\\\"\\n  body=$INIT; post \\\"$@\\\"\\n  init=$(answer 1 \\\"$TMPDIR/b2\\\")\\n  session=$(tr -d '\\\\r' < \\\"$TMPDIR/h\\\" | awk 'tolower($1) == \\\"mcp-session-id:\\\" { print $2 }' | tail -n 1)\\n  body=$READY; curl -sS -m 10 -o /dev/null -H 'Content-Type: application/json' -H 'Accept: application/json, text/event-stream' \\\\\\n    ${session:+-H \\\"Mcp-Session-Id: $session\\\"} \\\"$@\\\" --data-binary \\\"$body\\\" \\\"$url\\\" 2>/dev/null\\n  cursor=\\\"\\\"; i=2\\n  while [ $i -le 6 ]; do\\n    body=$(list $i \\\"$cursor\\\"); post \\\"$@\\\"\\n    page=$(answer $i \\\"$TMPDIR/b2\\\")\\n    [ -n \\\"$page\\\" ] || break\\n    printf '%s' \\\"$page\\\" | jq -c '.result.tools[]? | { name, description: (.description // \\\"\\\" | .[0:300]) }' >> \\\"$tools\\\"\\n    cursor=$(printf '%s' \\\"$page\\\" | jq -r '.result.nextCursor // empty')\\n    [ -n \\\"$cursor\\\" ] || break\\n    i=$((i + 1))\\n  done\\nelse\\n  cmd=$(get '.command // empty')\\n  [ -n \\\"$cmd\\\" ] || result false \\\"It has neither a command nor a URL\\\"\\n  # The places people's tools live, which a Mac app's own PATH leaves out (nvm, Volta, Bun, uv, Cargo, \u2026).\\n  for d in \\\"$HOME/.volta/bin\\\" \\\"$HOME/.bun/bin\\\" \\\"$HOME/.cargo/bin\\\" \\\"$HOME/.local/bin\\\" \\\"$HOME/.deno/bin\\\" \\\"$HOME/.nvm/versions/node\\\"/*/bin; do\\n    [ -d \\\"$d\\\" ] && PATH=\\\"$PATH:$d\\\"\\n  done\\n  export PATH\\n  # Arguments and env exactly as the app passes them, each one whole (no shell in between).\\n  set --\\n  count=$(get '(.env // {}) | length')\\n  i=0; while [ \\\"$i\\\" -lt \\\"$count\\\" ]; do set -- \\\"$@\\\" \\\"$(printf '%s' \\\"$entry\\\" | jq -r --argjson i \\\"$i\\\" '.env | to_entries[$i] | \\\"\\\\(.key)=\\\\(.value)\\\"')\\\"; i=$((i + 1)); done\\n  set -- \\\"$@\\\" \\\"$cmd\\\"\\n  count=$(get '(.args // []) | length')\\n  i=0; while [ \\\"$i\\\" -lt \\\"$count\\\" ]; do set -- \\\"$@\\\" \\\"$(printf '%s' \\\"$entry\\\" | jq -r --argjson i \\\"$i\\\" '.args[$i] | tostring')\\\"; i=$((i + 1)); done\\n  cwd=$(get '.cwd // empty'); [ -n \\\"$cwd\\\" ] && [ -d \\\"$cwd\\\" ] && cd \\\"$cwd\\\"\\n  rm -f \\\"$TMPDIR/in\\\"; mkfifo \\\"$TMPDIR/in\\\" || result false \\\"Couldn't start it\\\"\\n  # Its own process group, so stopping it also stops what it started (npx runs node).\\n  set -m 2>/dev/null\\n  /usr/bin/env \\\"$@\\\" < \\\"$TMPDIR/in\\\" > \\\"$TMPDIR/out\\\" 2> \\\"$TMPDIR/err\\\" &\\n  pid=$!\\n  exec 3> \\\"$TMPDIR/in\\\"\\n  stop() { exec 3>&-; sleep 0.3; kill -TERM -\\\"$pid\\\" 2>/dev/null || kill -TERM \\\"$pid\\\" 2>/dev/null; }\\n  # Still running (an exited child stays a zombie until reaped, which kill -0 can't tell apart).\\n  alive() { st=$(ps -o stat= -p \\\"$pid\\\" 2>/dev/null); case \\\"$st\\\" in ''|Z*) return 1 ;; esac; }\\n  # Waits up to 90 s for an answer (the first run of npx or uvx downloads the server).\\n  wait_for() {\\n    w=0\\n    while [ $w -lt 450 ]; do\\n      got=$(answer \\\"$1\\\" \\\"$TMPDIR/out\\\"); [ -n \\\"$got\\\" ] && { printf '%s' \\\"$got\\\"; return 0; }\\n      alive || return 1\\n      sleep 0.2; w=$((w + 1))\\n    done\\n    return 1\\n  }\\n  printf '%s\\\\n' \\\"$INIT\\\" >&3\\n  init=$(wait_for 1) || {\\n    e=$(tail -n 3 \\\"$TMPDIR/err\\\" | tr '\\\\n' ' '); stop\\n    # TailApps' sandbox stops a card's scripts from starting programs they downloaded (npx and uvx keep theirs in caches).\\n    case \\\"$e\\\" in *\\\"Operation not permitted\\\"*|*EPERM*|*\\\"not permitted\\\"*|*EACCES*|*\\\"Sandbox\\\"*|*\\\"sandbox\\\"*)\\n      result false \\\"TailApps' sandbox stopped it from starting. To test servers that run on this Mac, turn on Trusted (Full Access) in this card's \u22ef menu. Hosted servers test without it\\\" ;;\\n    esac\\n    result false \\\"It didn't answer${e:+: $e}\\\"\\n  }\\n  printf '%s\\\\n' \\\"$READY\\\" >&3\\n  cursor=\\\"\\\"; i=2\\n  while [ $i -le 6 ]; do\\n    printf '%s\\\\n' \\\"$(list $i \\\"$cursor\\\")\\\" >&3\\n    page=$(wait_for $i) || break\\n    printf '%s' \\\"$page\\\" | jq -c '.result.tools[]? | { name, description: (.description // \\\"\\\" | .[0:300]) }' >> \\\"$tools\\\"\\n    cursor=$(printf '%s' \\\"$page\\\" | jq -r '.result.nextCursor // empty')\\n    [ -n \\\"$cursor\\\" ] || break\\n    i=$((i + 1))\\n  done\\n  stop\\nfi\\n[ -n \\\"$init\\\" ] || result false \\\"It didn't answer the MCP handshake\\\"\\nerr=$(printf '%s' \\\"$init\\\" | jq -r '.error.message // empty')\\n[ -z \\\"$err\\\" ] || result false \\\"$err\\\"\\nresult true \\\"\\\" \\\"$(jq -sc '.' \\\"$tools\\\")\\\" \\\"$(printf '%s' \\\"$init\\\" | jq -c '.result.serverInfo // null')\\\"\\n\",\n    \"toggle.sh\": \"#!/bin/sh\\n# Args 1-9: the files and folders picked in the card's settings (empty when not picked). A picked one may be changed;\\n# otherwise the card reads where each AI app keeps it, and changes nothing there.\\nP_claude_code=$1 P_claude_desktop=$2 P_cursor=$3 P_vscode=$4 P_windsurf=$5 P_gemini=$6 P_codex=$7 P_claude_skills=$8 P_codex_skills=$9\\nshift 9\\nAS=\\\"$HOME/Library/Application Support\\\"\\nAPPS=\\\"claude_code claude_desktop cursor vscode windsurf gemini codex\\\"\\npicked() {\\n  case \\\"$1\\\" in\\n    claude_code) printf '%s' \\\"$P_claude_code\\\" ;; claude_desktop) printf '%s' \\\"$P_claude_desktop\\\" ;; cursor) printf '%s' \\\"$P_cursor\\\" ;;\\n    vscode) printf '%s' \\\"$P_vscode\\\" ;; windsurf) printf '%s' \\\"$P_windsurf\\\" ;; gemini) printf '%s' \\\"$P_gemini\\\" ;; codex) printf '%s' \\\"$P_codex\\\" ;;\\n    claude_skills) printf '%s' \\\"$P_claude_skills\\\" ;; codex_skills) printf '%s' \\\"$P_codex_skills\\\" ;;\\n  esac\\n}\\ndefault_of() {\\n  case \\\"$1\\\" in\\n    claude_code) printf '%s' \\\"$HOME/.claude.json\\\" ;;\\n    claude_desktop) printf '%s' \\\"$AS/Claude/claude_desktop_config.json\\\" ;;\\n    cursor) printf '%s' \\\"$HOME/.cursor/mcp.json\\\" ;;\\n    vscode) printf '%s' \\\"$AS/Code/User/mcp.json\\\" ;;\\n    windsurf) printf '%s' \\\"$HOME/.codeium/windsurf/mcp_config.json\\\" ;;\\n    gemini) printf '%s' \\\"$HOME/.gemini/settings.json\\\" ;;\\n    codex) printf '%s' \\\"$HOME/.codex/config.toml\\\" ;;\\n    claude_skills) printf '%s' \\\"$HOME/.claude/skills\\\" ;;\\n    codex_skills) printf '%s' \\\"$HOME/.codex/skills\\\" ;;\\n  esac\\n}\\nfile_of() { p=$(picked \\\"$1\\\"); [ -n \\\"$p\\\" ] && printf '%s' \\\"$p\\\" || default_of \\\"$1\\\"; }\\nname_of() {\\n  case \\\"$1\\\" in\\n    claude_code) echo \\\"Claude Code\\\" ;; claude_desktop) echo \\\"Claude Desktop\\\" ;; cursor) echo \\\"Cursor\\\" ;;\\n    vscode) echo \\\"VS Code\\\" ;; windsurf) echo \\\"Windsurf\\\" ;; gemini) echo \\\"Gemini CLI\\\" ;; codex) echo \\\"Codex\\\" ;;\\n  esac\\n}\\n# Where an app keeps its servers inside its JSON file, as a jq path.\\nbase_of() {\\n  case \\\"$1\\\" in\\n    claude_code) case \\\"$2\\\" in local:*) jq -cn --arg p \\\"${2#local:}\\\" '[\\\"projects\\\", $p, \\\"mcpServers\\\"]' ;; *) echo '[\\\"mcpServers\\\"]' ;; esac ;;\\n    vscode) echo '[\\\"servers\\\"]' ;;\\n    *) echo '[\\\"mcpServers\\\"]' ;;\\n  esac\\n}\\nfail() { printf '%s\\\\n' \\\"$*\\\" >&2; exit 1; }\\n# The card's own folder (tmp/<card>/): switched-off servers and backups live here, never in the card's state.\\nOWN=$(dirname \\\"${TMPDIR%/}\\\")\\nPARKED=\\\"$OWN/parked.json\\\"\\n[ -f \\\"$PARKED\\\" ] || { umask 077; echo '[]' > \\\"$PARKED\\\"; }\\n# A file may only be changed when the person picked it in settings.\\nwritable_of() {\\n  p=$(picked \\\"$1\\\")\\n  [ -n \\\"$p\\\" ] || fail \\\"To change $(name_of \\\"$1\\\")'s servers, choose its file in this card's settings (the gear): $(default_of \\\"$1\\\" | sed \\\"s|^$HOME|~|\\\")\\\"\\n  [ -f \\\"$p\\\" ] || fail \\\"$(name_of \\\"$1\\\")'s file isn't there any more: $p\\\"\\n  printf '%s' \\\"$p\\\"\\n}\\n# A copy of the file before each change, the newest 30 kept.\\nbackup() {\\n  mkdir -p \\\"$OWN/backups\\\" && chmod 700 \\\"$OWN/backups\\\"\\n  b=\\\"$OWN/backups/$2-$(date +%Y%m%d-%H%M%S)-$$.bak\\\"\\n  cp -p \\\"$1\\\" \\\"$b\\\" || fail \\\"Couldn't back up $1\\\"\\n  ls -t \\\"$OWN/backups\\\"/*.bak 2>/dev/null | tail -n +31 | while IFS= read -r old; do rm -f \\\"$old\\\"; done\\n}\\n# The file's modification time and size, taken before reading it (seen) and checked again just before writing\\n# (unchanged), so a change the AI app made meanwhile isn't written over.\\nstamp_of() { stat -c '%.9Y %s' \\\"$1\\\" 2>/dev/null || stat -f '%Fm %z' \\\"$1\\\" 2>/dev/null; }\\nseen() { SEEN=$(stamp_of \\\"$1\\\"); }\\nunchanged() { [ -z \\\"$SEEN\\\" ] || [ \\\"$(stamp_of \\\"$1\\\")\\\" = \\\"$SEEN\\\" ]; }\\n# Write new text over a file in place (keeps its permissions; the sandbox allows only the picked file itself).\\nreplace() {\\n  [ -s \\\"$2\\\" ] || fail \\\"Nothing to write\\\"\\n  unchanged \\\"$1\\\" || fail \\\"$1 changed while this ran, so nothing was written. Try again\\\"\\n  cat \\\"$2\\\" > \\\"$1\\\" || fail \\\"Couldn't write $1\\\"\\n}\\n\\n# Turn one server off (its exact entry moves to the card's own folder) or back on (put back as it was).\\n# Args: id (\\\"<app>:<scope>:<name>\\\"), true|false, and the server as the card shows it (kept with the entry).\\nid=$1 on=$2 info=${3:-\\\"{}\\\"}\\na=${id%%:*}; rest=${id#*:}; name=${id##*:}; scope=${rest%:*}\\nn=$(name_of \\\"$a\\\"); [ -n \\\"$n\\\" ] || fail \\\"Unknown app in $id\\\"\\nf=$(writable_of \\\"$a\\\") || exit 1\\nseen \\\"$f\\\"\\nnew=\\\"$TMPDIR/new\\\"\\n# The [mcp_servers.<name>] table of a config.toml, and its sub-tables (env), with or without quotes in the name.\\ntoml_split() { # file name keep|block\\n  awk -v n=\\\"$2\\\" -v want=\\\"$3\\\" '\\n    /^[ \\\\t]*\\\\[/ { t = $0; sub(/^[ \\\\t]*\\\\[+[ \\\\t]*/, \\\"\\\", t); sub(/[ \\\\t]*\\\\]+.*$/, \\\"\\\", t); gsub(/\\\"/, \\\"\\\", t)\\n                  inblk = (t == \\\"mcp_servers.\\\" n || index(t, \\\"mcp_servers.\\\" n \\\".\\\") == 1) }\\n    { if ((want == \\\"block\\\") == (inblk == 1)) print }' \\\"$1\\\"\\n}\\nif [ \\\"$on\\\" = false ]; then\\n  if [ \\\"$a\\\" = codex ]; then\\n    block=$(toml_split \\\"$f\\\" \\\"$name\\\" block)\\n    [ -n \\\"$block\\\" ] || fail \\\"Codex's config.toml has no [mcp_servers.$name] table to switch off\\\"\\n    backup \\\"$f\\\" \\\"$a\\\"\\n    toml_split \\\"$f\\\" \\\"$name\\\" keep > \\\"$new\\\"\\n    jq --arg id \\\"$id\\\" --arg toml \\\"$block\\\" --argjson info \\\"$info\\\" '[.[] | select(.id != $id)] + [{ id: $id, toml: $toml, info: $info, at: now }]' \\\"$PARKED\\\" > \\\"$TMPDIR/parked\\\"\\n  else\\n    base=$(base_of \\\"$a\\\" \\\"$scope\\\")\\n    entry=$(jq -c --argjson b \\\"$base\\\" --arg n \\\"$name\\\" 'getpath($b + [$n])' \\\"$f\\\") || fail \\\"Couldn't read $f\\\"\\n    [ \\\"$entry\\\" != null ] || fail \\\"$n has no server named $name any more\\\"\\n    backup \\\"$f\\\" \\\"$a\\\"\\n    jq --argjson b \\\"$base\\\" --arg n \\\"$name\\\" 'delpaths([$b + [$n]])' \\\"$f\\\" > \\\"$new\\\" || fail \\\"Couldn't change $f\\\"\\n    jq --arg id \\\"$id\\\" --argjson e \\\"$entry\\\" --argjson info \\\"$info\\\" '[.[] | select(.id != $id)] + [{ id: $id, entry: $e, info: $info, at: now }]' \\\"$PARKED\\\" > \\\"$TMPDIR/parked\\\"\\n  fi\\n  replace \\\"$f\\\" \\\"$new\\\"\\n  cat \\\"$TMPDIR/parked\\\" > \\\"$PARKED\\\"\\n  echo \\\"{\\\\\\\"ok\\\\\\\":true}\\\"\\n  exit 0\\nfi\\nsaved=$(jq -c --arg id \\\"$id\\\" 'map(select(.id == $id)) | .[0]' \\\"$PARKED\\\")\\n[ \\\"$saved\\\" != null ] || fail \\\"$name isn't switched off here\\\"\\nif [ \\\"$a\\\" = codex ]; then\\n  [ -z \\\"$(toml_split \\\"$f\\\" \\\"$name\\\" block)\\\" ] || fail \\\"Codex already has a server named $name\\\"\\n  backup \\\"$f\\\" \\\"$a\\\"\\n  { cat \\\"$f\\\"; [ -n \\\"$(tail -c 1 \\\"$f\\\")\\\" ] && echo; echo; printf '%s\\\\n' \\\"$saved\\\" | jq -r '.toml'; } > \\\"$new\\\"\\nelse\\n  base=$(base_of \\\"$a\\\" \\\"$scope\\\")\\n  [ \\\"$(jq --argjson b \\\"$base\\\" --arg n \\\"$name\\\" 'getpath($b + [$n]) != null' \\\"$f\\\")\\\" = false ] || fail \\\"$n already has a server named $name\\\"\\n  backup \\\"$f\\\" \\\"$a\\\"\\n  jq --argjson b \\\"$base\\\" --arg n \\\"$name\\\" --argjson e \\\"$(printf '%s' \\\"$saved\\\" | jq -c '.entry')\\\" 'setpath($b + [$n]; $e)' \\\"$f\\\" > \\\"$new\\\" || fail \\\"Couldn't change $f\\\"\\nfi\\nreplace \\\"$f\\\" \\\"$new\\\"\\njq --arg id \\\"$id\\\" 'map(select(.id != $id))' \\\"$PARKED\\\" > \\\"$TMPDIR/parked\\\" && cat \\\"$TMPDIR/parked\\\" > \\\"$PARKED\\\"\\necho \\\"{\\\\\\\"ok\\\\\\\":true}\\\"\\n\",\n    \"install.sh\": \"#!/bin/sh\\n# Args 1-9: the files and folders picked in the card's settings (empty when not picked). A picked one may be changed;\\n# otherwise the card reads where each AI app keeps it, and changes nothing there.\\nP_claude_code=$1 P_claude_desktop=$2 P_cursor=$3 P_vscode=$4 P_windsurf=$5 P_gemini=$6 P_codex=$7 P_claude_skills=$8 P_codex_skills=$9\\nshift 9\\nAS=\\\"$HOME/Library/Application Support\\\"\\nAPPS=\\\"claude_code claude_desktop cursor vscode windsurf gemini codex\\\"\\npicked() {\\n  case \\\"$1\\\" in\\n    claude_code) printf '%s' \\\"$P_claude_code\\\" ;; claude_desktop) printf '%s' \\\"$P_claude_desktop\\\" ;; cursor) printf '%s' \\\"$P_cursor\\\" ;;\\n    vscode) printf '%s' \\\"$P_vscode\\\" ;; windsurf) printf '%s' \\\"$P_windsurf\\\" ;; gemini) printf '%s' \\\"$P_gemini\\\" ;; codex) printf '%s' \\\"$P_codex\\\" ;;\\n    claude_skills) printf '%s' \\\"$P_claude_skills\\\" ;; codex_skills) printf '%s' \\\"$P_codex_skills\\\" ;;\\n  esac\\n}\\ndefault_of() {\\n  case \\\"$1\\\" in\\n    claude_code) printf '%s' \\\"$HOME/.claude.json\\\" ;;\\n    claude_desktop) printf '%s' \\\"$AS/Claude/claude_desktop_config.json\\\" ;;\\n    cursor) printf '%s' \\\"$HOME/.cursor/mcp.json\\\" ;;\\n    vscode) printf '%s' \\\"$AS/Code/User/mcp.json\\\" ;;\\n    windsurf) printf '%s' \\\"$HOME/.codeium/windsurf/mcp_config.json\\\" ;;\\n    gemini) printf '%s' \\\"$HOME/.gemini/settings.json\\\" ;;\\n    codex) printf '%s' \\\"$HOME/.codex/config.toml\\\" ;;\\n    claude_skills) printf '%s' \\\"$HOME/.claude/skills\\\" ;;\\n    codex_skills) printf '%s' \\\"$HOME/.codex/skills\\\" ;;\\n  esac\\n}\\nfile_of() { p=$(picked \\\"$1\\\"); [ -n \\\"$p\\\" ] && printf '%s' \\\"$p\\\" || default_of \\\"$1\\\"; }\\nname_of() {\\n  case \\\"$1\\\" in\\n    claude_code) echo \\\"Claude Code\\\" ;; claude_desktop) echo \\\"Claude Desktop\\\" ;; cursor) echo \\\"Cursor\\\" ;;\\n    vscode) echo \\\"VS Code\\\" ;; windsurf) echo \\\"Windsurf\\\" ;; gemini) echo \\\"Gemini CLI\\\" ;; codex) echo \\\"Codex\\\" ;;\\n  esac\\n}\\n# Where an app keeps its servers inside its JSON file, as a jq path.\\nbase_of() {\\n  case \\\"$1\\\" in\\n    claude_code) case \\\"$2\\\" in local:*) jq -cn --arg p \\\"${2#local:}\\\" '[\\\"projects\\\", $p, \\\"mcpServers\\\"]' ;; *) echo '[\\\"mcpServers\\\"]' ;; esac ;;\\n    vscode) echo '[\\\"servers\\\"]' ;;\\n    *) echo '[\\\"mcpServers\\\"]' ;;\\n  esac\\n}\\nfail() { printf '%s\\\\n' \\\"$*\\\" >&2; exit 1; }\\n# The card's own folder (tmp/<card>/): switched-off servers and backups live here, never in the card's state.\\nOWN=$(dirname \\\"${TMPDIR%/}\\\")\\nPARKED=\\\"$OWN/parked.json\\\"\\n[ -f \\\"$PARKED\\\" ] || { umask 077; echo '[]' > \\\"$PARKED\\\"; }\\n# A file may only be changed when the person picked it in settings.\\nwritable_of() {\\n  p=$(picked \\\"$1\\\")\\n  [ -n \\\"$p\\\" ] || fail \\\"To change $(name_of \\\"$1\\\")'s servers, choose its file in this card's settings (the gear): $(default_of \\\"$1\\\" | sed \\\"s|^$HOME|~|\\\")\\\"\\n  [ -f \\\"$p\\\" ] || fail \\\"$(name_of \\\"$1\\\")'s file isn't there any more: $p\\\"\\n  printf '%s' \\\"$p\\\"\\n}\\n# A copy of the file before each change, the newest 30 kept.\\nbackup() {\\n  mkdir -p \\\"$OWN/backups\\\" && chmod 700 \\\"$OWN/backups\\\"\\n  b=\\\"$OWN/backups/$2-$(date +%Y%m%d-%H%M%S)-$$.bak\\\"\\n  cp -p \\\"$1\\\" \\\"$b\\\" || fail \\\"Couldn't back up $1\\\"\\n  ls -t \\\"$OWN/backups\\\"/*.bak 2>/dev/null | tail -n +31 | while IFS= read -r old; do rm -f \\\"$old\\\"; done\\n}\\n# The file's modification time and size, taken before reading it (seen) and checked again just before writing\\n# (unchanged), so a change the AI app made meanwhile isn't written over.\\nstamp_of() { stat -c '%.9Y %s' \\\"$1\\\" 2>/dev/null || stat -f '%Fm %z' \\\"$1\\\" 2>/dev/null; }\\nseen() { SEEN=$(stamp_of \\\"$1\\\"); }\\nunchanged() { [ -z \\\"$SEEN\\\" ] || [ \\\"$(stamp_of \\\"$1\\\")\\\" = \\\"$SEEN\\\" ]; }\\n# Write new text over a file in place (keeps its permissions; the sandbox allows only the picked file itself).\\nreplace() {\\n  [ -s \\\"$2\\\" ] || fail \\\"Nothing to write\\\"\\n  unchanged \\\"$1\\\" || fail \\\"$1 changed while this ran, so nothing was written. Try again\\\"\\n  cat \\\"$2\\\" > \\\"$1\\\" || fail \\\"Couldn't write $1\\\"\\n}\\n\\n# Add a server from the MCP Registry to the chosen AI apps, each in its own format, after a backup of each file.\\n# Args: the registry's server object, the app ids as a JSON list, and the keys the person typed when asked\\n# (\\\"NAME=value\\\", separated by new lines or \\\"; \\\"; \\\"header NAME=value\\\" for a hosted server's headers). Prints { installed: [app names], skipped: [{ app, why }] }.\\nserver=$1 targets=${2:-\\\"[]\\\"} typed=$3\\n[ -n \\\"$server\\\" ] && [ \\\"$server\\\" != null ] || fail \\\"Pick a server first\\\"\\n[ \\\"$(printf '%s' \\\"$targets\\\" | jq 'length')\\\" -gt 0 ] || fail \\\"Tick at least one app to add it to\\\"\\nname=$(printf '%s' \\\"$server\\\" | jq -r '.name | split(\\\"/\\\") | last | gsub(\\\"[^A-Za-z0-9_-]\\\"; \\\"-\\\")')\\n# What runs: the first package we know how to start, else the first hosted address.\\nspec=$(printf '%s' \\\"$typed\\\" | jq -Rs --argjson s \\\"$server\\\" '\\n  ([splits(\\\"\\\\n|;\\\\\\\\s*(?=(header\\\\\\\\s+)?[A-Za-z_][A-Za-z0-9_-]*\\\\\\\\s*=)\\\")] | map(sub(\\\"\\\\r$\\\"; \\\"\\\") | sub(\\\"^\\\\\\\\s+\\\"; \\\"\\\") | select(test(\\\"^(#|$)\\\") | not))) as $lines\\n  | ([$lines[] | select(startswith(\\\"header \\\") | not) | capture(\\\"^\\\\\\\\s*(?<k>[A-Za-z_][A-Za-z0-9_]*)\\\\\\\\s*=(?<v>.*)$\\\")] | map({ (.k): (.v | sub(\\\"^\\\\\\\\s+\\\"; \\\"\\\")) }) | add // {} | with_entries(select(.value != \\\"\\\"))) as $env\\n  | ([$lines[] | select(startswith(\\\"header \\\")) | sub(\\\"^header \\\"; \\\"\\\") | capture(\\\"^\\\\\\\\s*(?<k>[A-Za-z0-9-]+)\\\\\\\\s*=(?<v>.*)$\\\")] | map({ (.k): (.v | sub(\\\"^\\\\\\\\s+\\\"; \\\"\\\")) }) | add // {} | with_entries(select(.value != \\\"\\\"))) as $headers\\n  | ([$s.packages[]? | select((.transport.type // \\\"stdio\\\") == \\\"stdio\\\" and (.registryType == \\\"npm\\\" or .registryType == \\\"pypi\\\" or .registryType == \\\"oci\\\"))] | .[0]) as $p\\n  | ($s.remotes // [] | .[0]) as $r\\n  | if $p then\\n      ([$p.environmentVariables[]? | select(.isRequired == true and ($env[.name] // \\\"\\\") == \\\"\\\") | .name]) as $missing\\n      | ([$p.packageArguments[]? | select(.value != null) | if .type == \\\"named\\\" then .name, .value else .value end | tostring]) as $extra\\n      | (if ($p.version // \\\"\\\") == \\\"\\\" then $p.identifier elif $p.registryType == \\\"pypi\\\" then \\\"\\\\($p.identifier)==\\\\($p.version)\\\"\\n         elif $p.registryType == \\\"npm\\\" then \\\"\\\\($p.identifier)@\\\\($p.version)\\\"\\n         elif ($p.identifier | contains(\\\":\\\")) then $p.identifier else \\\"\\\\($p.identifier):\\\\($p.version)\\\" end) as $id\\n      | { kind: \\\"stdio\\\", missing: $missing, env: $env,\\n          command: ({ npm: \\\"npx\\\", pypi: \\\"uvx\\\", oci: \\\"docker\\\" }[$p.registryType]),\\n          args: ((if $p.registryType == \\\"npm\\\" then [\\\"-y\\\", $id] elif $p.registryType == \\\"pypi\\\" then [$id]\\n                  else [\\\"run\\\", \\\"-i\\\", \\\"--rm\\\"] + [$env | keys[] | \\\"-e\\\", .] + [$id] end) + $extra) }\\n    elif $r then\\n      ([$r.headers[]? | select(.isRequired == true and ($headers[.name] // \\\"\\\") == \\\"\\\") | .name]) as $missing\\n      | { kind: (if $r.type == \\\"sse\\\" then \\\"sse\\\" else \\\"http\\\" end), url: $r.url, headers: $headers, missing: $missing }\\n    else { error: \\\"It has nothing this card can install (no npm, PyPI or Docker package, and no hosted address)\\\" } end') || fail \\\"Couldn't read that server's details\\\"\\n[ -n \\\"$spec\\\" ] || fail \\\"Couldn't read that server's details\\\"\\ne=$(printf '%s' \\\"$spec\\\" | jq -r '.error // empty'); [ -z \\\"$e\\\" ] || fail \\\"$e\\\"\\nmissing=$(printf '%s' \\\"$spec\\\" | jq -r '.missing | join(\\\", \\\")')\\n[ -z \\\"$missing\\\" ] || fail \\\"Fill in $missing first\\\"\\n# The entry each app expects.\\nentry_for() {\\n  printf '%s' \\\"$spec\\\" | jq -c --arg app \\\"$1\\\" '\\n    def drop_empty: with_entries(select(.value != null and .value != {} and .value != []));\\n    if .kind == \\\"stdio\\\" then\\n      (if ($app == \\\"claude_code\\\" or $app == \\\"vscode\\\") then { type: \\\"stdio\\\" } else {} end) + { command, args, env } | drop_empty\\n    elif $app == \\\"claude_desktop\\\" then\\n      { command: \\\"npx\\\", args: ([\\\"-y\\\", \\\"mcp-remote\\\", .url] + ([.headers | to_entries[] | \\\"--header\\\", \\\"\\\\(.key):\\\\(.value)\\\"])) }\\n    elif $app == \\\"windsurf\\\" then { serverUrl: .url, headers } | drop_empty\\n    elif $app == \\\"gemini\\\" then (if .kind == \\\"sse\\\" then { url, headers } else { httpUrl: .url, headers } end) | drop_empty\\n    elif $app == \\\"cursor\\\" then { url, headers } | drop_empty\\n    else { type: .kind, url, headers } | drop_empty end'\\n}\\ntoml_for() {\\n  printf '%s' \\\"$spec\\\" | jq -r --arg n \\\"$name\\\" '\\n    def kv: to_entries | map(\\\"\\\\(.key | tojson) = \\\\(.value | tojson)\\\") | join(\\\", \\\");\\n    \\\"[mcp_servers.\\\\($n)]\\\\n\\\" + (if .kind == \\\"stdio\\\"\\n      then \\\"command = \\\\(.command | tojson)\\\\nargs = \\\\(.args | tojson)\\\\n\\\" + (if (.env | length) > 0 then \\\"env = { \\\\(.env | kv) }\\\\n\\\" else \\\"\\\" end)\\n      else \\\"url = \\\\(.url | tojson)\\\\n\\\" + (if (.headers | length) > 0 then \\\"http_headers = { \\\\(.headers | kv) }\\\\n\\\" else \\\"\\\" end) end)'\\n}\\ndone_list=\\\"$TMPDIR/done\\\"; skip_list=\\\"$TMPDIR/skip\\\"; : > \\\"$done_list\\\"; : > \\\"$skip_list\\\"\\nskip() { jq -cn --arg app \\\"$(name_of \\\"$1\\\")\\\" --arg why \\\"$2\\\" '{ app: $app, why: $why }' >> \\\"$skip_list\\\"; }\\nfor a in $(printf '%s' \\\"$targets\\\" | jq -r '.[]'); do\\n  n=$(name_of \\\"$a\\\"); [ -n \\\"$n\\\" ] || continue\\n  f=$(picked \\\"$a\\\")\\n  if [ -z \\\"$f\\\" ]; then skip \\\"$a\\\" \\\"Choose its file in this card's settings first\\\"; continue; fi\\n  if [ ! -f \\\"$f\\\" ]; then skip \\\"$a\\\" \\\"Its file isn't there\\\"; continue; fi\\n  seen \\\"$f\\\"\\n  new=\\\"$TMPDIR/new-$a\\\"\\n  if [ \\\"$a\\\" = codex ]; then\\n    if [ \\\"$(printf '%s' \\\"$spec\\\" | jq -r .kind)\\\" = sse ]; then skip \\\"$a\\\" \\\"Codex doesn't take the older SSE kind\\\"; continue; fi\\n    if grep -Eq \\\"^[[:space:]]*\\\\[mcp_servers\\\\.\\\\\\\"?$name\\\\\\\"?\\\\]\\\" \\\"$f\\\"; then skip \\\"$a\\\" \\\"It already has a server named $name\\\"; continue; fi\\n    { cat \\\"$f\\\"; [ -n \\\"$(tail -c 1 \\\"$f\\\")\\\" ] && echo; echo; toml_for; } > \\\"$new\\\"\\n  else\\n    base=$(base_of \\\"$a\\\" user)\\n    if ! jq -e . \\\"$f\\\" > /dev/null 2>&1; then skip \\\"$a\\\" \\\"Its file has comments or isn't plain JSON\\\"; continue; fi\\n    if [ \\\"$(jq --argjson b \\\"$base\\\" --arg n \\\"$name\\\" 'getpath($b + [$n]) != null' \\\"$f\\\")\\\" = true ]; then skip \\\"$a\\\" \\\"It already has a server named $name\\\"; continue; fi\\n    jq --argjson b \\\"$base\\\" --arg n \\\"$name\\\" --argjson e \\\"$(entry_for \\\"$a\\\")\\\" 'setpath($b + [$n]; $e)' \\\"$f\\\" > \\\"$new\\\" || { skip \\\"$a\\\" \\\"Couldn't change its file\\\"; continue; }\\n  fi\\n  unchanged \\\"$f\\\" || { skip \\\"$a\\\" \\\"Its file changed meanwhile. Try again\\\"; continue; }\\n  backup \\\"$f\\\" \\\"$a\\\"\\n  replace \\\"$f\\\" \\\"$new\\\"\\n  printf '%s\\\\n' \\\"$n\\\" | jq -R . >> \\\"$done_list\\\"\\ndone\\njq -n --arg name \\\"$name\\\" --slurpfile d \\\"$done_list\\\" --slurpfile s \\\"$skip_list\\\" '{ name: $name, installed: $d, skipped: $s }'\\n\",\n    \"skills.sh\": \"#!/bin/sh\\n# Args 1-9: the files and folders picked in the card's settings (empty when not picked). A picked one may be changed;\\n# otherwise the card reads where each AI app keeps it, and changes nothing there.\\nP_claude_code=$1 P_claude_desktop=$2 P_cursor=$3 P_vscode=$4 P_windsurf=$5 P_gemini=$6 P_codex=$7 P_claude_skills=$8 P_codex_skills=$9\\nshift 9\\nAS=\\\"$HOME/Library/Application Support\\\"\\nAPPS=\\\"claude_code claude_desktop cursor vscode windsurf gemini codex\\\"\\npicked() {\\n  case \\\"$1\\\" in\\n    claude_code) printf '%s' \\\"$P_claude_code\\\" ;; claude_desktop) printf '%s' \\\"$P_claude_desktop\\\" ;; cursor) printf '%s' \\\"$P_cursor\\\" ;;\\n    vscode) printf '%s' \\\"$P_vscode\\\" ;; windsurf) printf '%s' \\\"$P_windsurf\\\" ;; gemini) printf '%s' \\\"$P_gemini\\\" ;; codex) printf '%s' \\\"$P_codex\\\" ;;\\n    claude_skills) printf '%s' \\\"$P_claude_skills\\\" ;; codex_skills) printf '%s' \\\"$P_codex_skills\\\" ;;\\n  esac\\n}\\ndefault_of() {\\n  case \\\"$1\\\" in\\n    claude_code) printf '%s' \\\"$HOME/.claude.json\\\" ;;\\n    claude_desktop) printf '%s' \\\"$AS/Claude/claude_desktop_config.json\\\" ;;\\n    cursor) printf '%s' \\\"$HOME/.cursor/mcp.json\\\" ;;\\n    vscode) printf '%s' \\\"$AS/Code/User/mcp.json\\\" ;;\\n    windsurf) printf '%s' \\\"$HOME/.codeium/windsurf/mcp_config.json\\\" ;;\\n    gemini) printf '%s' \\\"$HOME/.gemini/settings.json\\\" ;;\\n    codex) printf '%s' \\\"$HOME/.codex/config.toml\\\" ;;\\n    claude_skills) printf '%s' \\\"$HOME/.claude/skills\\\" ;;\\n    codex_skills) printf '%s' \\\"$HOME/.codex/skills\\\" ;;\\n  esac\\n}\\nfile_of() { p=$(picked \\\"$1\\\"); [ -n \\\"$p\\\" ] && printf '%s' \\\"$p\\\" || default_of \\\"$1\\\"; }\\nname_of() {\\n  case \\\"$1\\\" in\\n    claude_code) echo \\\"Claude Code\\\" ;; claude_desktop) echo \\\"Claude Desktop\\\" ;; cursor) echo \\\"Cursor\\\" ;;\\n    vscode) echo \\\"VS Code\\\" ;; windsurf) echo \\\"Windsurf\\\" ;; gemini) echo \\\"Gemini CLI\\\" ;; codex) echo \\\"Codex\\\" ;;\\n  esac\\n}\\n# Where an app keeps its servers inside its JSON file, as a jq path.\\nbase_of() {\\n  case \\\"$1\\\" in\\n    claude_code) case \\\"$2\\\" in local:*) jq -cn --arg p \\\"${2#local:}\\\" '[\\\"projects\\\", $p, \\\"mcpServers\\\"]' ;; *) echo '[\\\"mcpServers\\\"]' ;; esac ;;\\n    vscode) echo '[\\\"servers\\\"]' ;;\\n    *) echo '[\\\"mcpServers\\\"]' ;;\\n  esac\\n}\\nfail() { printf '%s\\\\n' \\\"$*\\\" >&2; exit 1; }\\n# The card's own folder (tmp/<card>/): switched-off servers and backups live here, never in the card's state.\\nOWN=$(dirname \\\"${TMPDIR%/}\\\")\\nPARKED=\\\"$OWN/parked.json\\\"\\n[ -f \\\"$PARKED\\\" ] || { umask 077; echo '[]' > \\\"$PARKED\\\"; }\\n# A file may only be changed when the person picked it in settings.\\nwritable_of() {\\n  p=$(picked \\\"$1\\\")\\n  [ -n \\\"$p\\\" ] || fail \\\"To change $(name_of \\\"$1\\\")'s servers, choose its file in this card's settings (the gear): $(default_of \\\"$1\\\" | sed \\\"s|^$HOME|~|\\\")\\\"\\n  [ -f \\\"$p\\\" ] || fail \\\"$(name_of \\\"$1\\\")'s file isn't there any more: $p\\\"\\n  printf '%s' \\\"$p\\\"\\n}\\n# A copy of the file before each change, the newest 30 kept.\\nbackup() {\\n  mkdir -p \\\"$OWN/backups\\\" && chmod 700 \\\"$OWN/backups\\\"\\n  b=\\\"$OWN/backups/$2-$(date +%Y%m%d-%H%M%S)-$$.bak\\\"\\n  cp -p \\\"$1\\\" \\\"$b\\\" || fail \\\"Couldn't back up $1\\\"\\n  ls -t \\\"$OWN/backups\\\"/*.bak 2>/dev/null | tail -n +31 | while IFS= read -r old; do rm -f \\\"$old\\\"; done\\n}\\n# The file's modification time and size, taken before reading it (seen) and checked again just before writing\\n# (unchanged), so a change the AI app made meanwhile isn't written over.\\nstamp_of() { stat -c '%.9Y %s' \\\"$1\\\" 2>/dev/null || stat -f '%Fm %z' \\\"$1\\\" 2>/dev/null; }\\nseen() { SEEN=$(stamp_of \\\"$1\\\"); }\\nunchanged() { [ -z \\\"$SEEN\\\" ] || [ \\\"$(stamp_of \\\"$1\\\")\\\" = \\\"$SEEN\\\" ]; }\\n# Write new text over a file in place (keeps its permissions; the sandbox allows only the picked file itself).\\nreplace() {\\n  [ -s \\\"$2\\\" ] || fail \\\"Nothing to write\\\"\\n  unchanged \\\"$1\\\" || fail \\\"$1 changed while this ran, so nothing was written. Try again\\\"\\n  cat \\\"$2\\\" > \\\"$1\\\" || fail \\\"Couldn't write $1\\\"\\n}\\n\\n# Agent skills: Claude Code's and Codex's own (switch off = SKILL.md renamed SKILL.md.off, so no agent loads it) and\\n# the ones that came with Claude Code plugins (shown, not switched). Prints [{ id, name, description, agent, path, on,\\n# can_switch, body }].\\nout=\\\"$TMPDIR/skills.jsonl\\\"; : > \\\"$out\\\"\\nfront() { # file key: a value from the front matter between the first two --- lines\\n  awk -v k=\\\"$2\\\" 'NR == 1 && $0 != \\\"---\\\" { exit } NR > 1 && $0 == \\\"---\\\" { exit }\\n    NR > 1 { i = index($0, \\\":\\\"); if (i && substr($0, 1, i - 1) == k) { v = substr($0, i + 1); sub(/^[ \\\\t]+/, \\\"\\\", v); gsub(/^[\\\"'\\\\'']|[\\\"'\\\\'']$/, \\\"\\\", v); print v; exit } }' \\\"$1\\\"\\n}\\nadd() { # file agent on can_switch\\n  dir=$(dirname \\\"$1\\\")\\n  n=$(front \\\"$1\\\" name); [ -n \\\"$n\\\" ] || n=$(basename \\\"$dir\\\")\\n  jq -cn --arg path \\\"$dir\\\" --arg name \\\"$n\\\" --arg description \\\"$(front \\\"$1\\\" description)\\\" --arg agent \\\"$2\\\" \\\\\\n    --argjson on \\\"$3\\\" --argjson can \\\"$4\\\" --rawfile body \\\"$1\\\" \\\\\\n    '{ id: $path, name: $name, description: $description, agent: $agent, path: $path, on: $on, can_switch: $can, body: ($body | .[0:6000]) }' >> \\\"$out\\\"\\n}\\nfor kind in claude_skills codex_skills; do\\n  d=$(picked \\\"$kind\\\"); can=true\\n  [ -n \\\"$d\\\" ] || { d=$(default_of \\\"$kind\\\"); can=false; }\\n  agent=$([ \\\"$kind\\\" = claude_skills ] && echo \\\"Claude Code\\\" || echo \\\"Codex\\\")\\n  [ -d \\\"$d\\\" ] || continue\\n  for s in \\\"$d\\\"/*/; do\\n    [ -f \\\"$s/SKILL.md\\\" ] && add \\\"$s/SKILL.md\\\" \\\"$agent\\\" true \\\"$can\\\"\\n    [ -f \\\"$s/SKILL.md.off\\\" ] && add \\\"$s/SKILL.md.off\\\" \\\"$agent\\\" false \\\"$can\\\"\\n  done\\ndone\\n# Plugins' skills: ~/.claude/plugins/cache/<marketplace>/<plugin>/<version>/skills/<skill>/SKILL.md\\nfind \\\"$HOME/.claude/plugins/cache\\\" -maxdepth 6 -path '*/skills/*/SKILL.md' 2>/dev/null | sort | while IFS= read -r f; do\\n  plugin=$(printf '%s' \\\"$f\\\" | sed -E 's|.*/plugins/cache/[^/]+/([^/]+)/.*|\\\\1|')\\n  add \\\"$f\\\" \\\"Plugin $plugin\\\" true false\\ndone\\njq -s 'unique_by(.path) | sort_by(.name | ascii_downcase)' \\\"$out\\\"\\n\",\n    \"skill-switch.sh\": \"#!/bin/sh\\n# Args 1-9: the files and folders picked in the card's settings (empty when not picked). A picked one may be changed;\\n# otherwise the card reads where each AI app keeps it, and changes nothing there.\\nP_claude_code=$1 P_claude_desktop=$2 P_cursor=$3 P_vscode=$4 P_windsurf=$5 P_gemini=$6 P_codex=$7 P_claude_skills=$8 P_codex_skills=$9\\nshift 9\\nAS=\\\"$HOME/Library/Application Support\\\"\\nAPPS=\\\"claude_code claude_desktop cursor vscode windsurf gemini codex\\\"\\npicked() {\\n  case \\\"$1\\\" in\\n    claude_code) printf '%s' \\\"$P_claude_code\\\" ;; claude_desktop) printf '%s' \\\"$P_claude_desktop\\\" ;; cursor) printf '%s' \\\"$P_cursor\\\" ;;\\n    vscode) printf '%s' \\\"$P_vscode\\\" ;; windsurf) printf '%s' \\\"$P_windsurf\\\" ;; gemini) printf '%s' \\\"$P_gemini\\\" ;; codex) printf '%s' \\\"$P_codex\\\" ;;\\n    claude_skills) printf '%s' \\\"$P_claude_skills\\\" ;; codex_skills) printf '%s' \\\"$P_codex_skills\\\" ;;\\n  esac\\n}\\ndefault_of() {\\n  case \\\"$1\\\" in\\n    claude_code) printf '%s' \\\"$HOME/.claude.json\\\" ;;\\n    claude_desktop) printf '%s' \\\"$AS/Claude/claude_desktop_config.json\\\" ;;\\n    cursor) printf '%s' \\\"$HOME/.cursor/mcp.json\\\" ;;\\n    vscode) printf '%s' \\\"$AS/Code/User/mcp.json\\\" ;;\\n    windsurf) printf '%s' \\\"$HOME/.codeium/windsurf/mcp_config.json\\\" ;;\\n    gemini) printf '%s' \\\"$HOME/.gemini/settings.json\\\" ;;\\n    codex) printf '%s' \\\"$HOME/.codex/config.toml\\\" ;;\\n    claude_skills) printf '%s' \\\"$HOME/.claude/skills\\\" ;;\\n    codex_skills) printf '%s' \\\"$HOME/.codex/skills\\\" ;;\\n  esac\\n}\\nfile_of() { p=$(picked \\\"$1\\\"); [ -n \\\"$p\\\" ] && printf '%s' \\\"$p\\\" || default_of \\\"$1\\\"; }\\nname_of() {\\n  case \\\"$1\\\" in\\n    claude_code) echo \\\"Claude Code\\\" ;; claude_desktop) echo \\\"Claude Desktop\\\" ;; cursor) echo \\\"Cursor\\\" ;;\\n    vscode) echo \\\"VS Code\\\" ;; windsurf) echo \\\"Windsurf\\\" ;; gemini) echo \\\"Gemini CLI\\\" ;; codex) echo \\\"Codex\\\" ;;\\n  esac\\n}\\n# Where an app keeps its servers inside its JSON file, as a jq path.\\nbase_of() {\\n  case \\\"$1\\\" in\\n    claude_code) case \\\"$2\\\" in local:*) jq -cn --arg p \\\"${2#local:}\\\" '[\\\"projects\\\", $p, \\\"mcpServers\\\"]' ;; *) echo '[\\\"mcpServers\\\"]' ;; esac ;;\\n    vscode) echo '[\\\"servers\\\"]' ;;\\n    *) echo '[\\\"mcpServers\\\"]' ;;\\n  esac\\n}\\nfail() { printf '%s\\\\n' \\\"$*\\\" >&2; exit 1; }\\n# The card's own folder (tmp/<card>/): switched-off servers and backups live here, never in the card's state.\\nOWN=$(dirname \\\"${TMPDIR%/}\\\")\\nPARKED=\\\"$OWN/parked.json\\\"\\n[ -f \\\"$PARKED\\\" ] || { umask 077; echo '[]' > \\\"$PARKED\\\"; }\\n# A file may only be changed when the person picked it in settings.\\nwritable_of() {\\n  p=$(picked \\\"$1\\\")\\n  [ -n \\\"$p\\\" ] || fail \\\"To change $(name_of \\\"$1\\\")'s servers, choose its file in this card's settings (the gear): $(default_of \\\"$1\\\" | sed \\\"s|^$HOME|~|\\\")\\\"\\n  [ -f \\\"$p\\\" ] || fail \\\"$(name_of \\\"$1\\\")'s file isn't there any more: $p\\\"\\n  printf '%s' \\\"$p\\\"\\n}\\n# A copy of the file before each change, the newest 30 kept.\\nbackup() {\\n  mkdir -p \\\"$OWN/backups\\\" && chmod 700 \\\"$OWN/backups\\\"\\n  b=\\\"$OWN/backups/$2-$(date +%Y%m%d-%H%M%S)-$$.bak\\\"\\n  cp -p \\\"$1\\\" \\\"$b\\\" || fail \\\"Couldn't back up $1\\\"\\n  ls -t \\\"$OWN/backups\\\"/*.bak 2>/dev/null | tail -n +31 | while IFS= read -r old; do rm -f \\\"$old\\\"; done\\n}\\n# The file's modification time and size, taken before reading it (seen) and checked again just before writing\\n# (unchanged), so a change the AI app made meanwhile isn't written over.\\nstamp_of() { stat -c '%.9Y %s' \\\"$1\\\" 2>/dev/null || stat -f '%Fm %z' \\\"$1\\\" 2>/dev/null; }\\nseen() { SEEN=$(stamp_of \\\"$1\\\"); }\\nunchanged() { [ -z \\\"$SEEN\\\" ] || [ \\\"$(stamp_of \\\"$1\\\")\\\" = \\\"$SEEN\\\" ]; }\\n# Write new text over a file in place (keeps its permissions; the sandbox allows only the picked file itself).\\nreplace() {\\n  [ -s \\\"$2\\\" ] || fail \\\"Nothing to write\\\"\\n  unchanged \\\"$1\\\" || fail \\\"$1 changed while this ran, so nothing was written. Try again\\\"\\n  cat \\\"$2\\\" > \\\"$1\\\" || fail \\\"Couldn't write $1\\\"\\n}\\n\\n# Switch a skill off (SKILL.md \u2192 SKILL.md.off, so no agent loads it) or back on. Only inside a skills folder picked\\n# in the card's settings. Args: the skill's folder, true|false.\\ndir=${1%/} on=$2\\nok=false\\nfor kind in claude_skills codex_skills; do\\n  root=$(picked \\\"$kind\\\"); root=${root%/}\\n  [ -n \\\"$root\\\" ] && [ \\\"$(dirname \\\"$dir\\\")\\\" = \\\"$root\\\" ] && ok=true\\ndone\\n[ \\\"$ok\\\" = true ] || fail \\\"To switch skills, choose the skills folder in this card's settings (the gear)\\\"\\nif [ \\\"$on\\\" = false ]; then\\n  [ -f \\\"$dir/SKILL.md\\\" ] || fail \\\"There's no SKILL.md in $dir\\\"\\n  [ ! -e \\\"$dir/SKILL.md.off\\\" ] || fail \\\"$dir already has a SKILL.md.off\\\"\\n  mv \\\"$dir/SKILL.md\\\" \\\"$dir/SKILL.md.off\\\" || fail \\\"Couldn't switch it off\\\"\\nelse\\n  [ -f \\\"$dir/SKILL.md.off\\\" ] || fail \\\"It isn't switched off\\\"\\n  [ ! -e \\\"$dir/SKILL.md\\\" ] || fail \\\"$dir already has a SKILL.md\\\"\\n  mv \\\"$dir/SKILL.md.off\\\" \\\"$dir/SKILL.md\\\" || fail \\\"Couldn't switch it on\\\"\\nfi\\necho '{\\\"ok\\\":true}'\\n\"\n  },\n  \"style\": {\n    \"accent\": \"#0f766e\"\n  }\n}\n",
    "files": []
}