---
title: adamtheturtle/mcpclientinstall
framework: Swift Package Catalog
role: article
path: packages/adamtheturtle/mcpclientinstall
---

# adamtheturtle/mcpclientinstall

Safe, non-destructive editing of MCP desktop-client configuration files in Swift.

## Installation

```swift .package(     url: "https://github.com/adamtheturtle/MCPClientInstall.git",     from: "0.1.0" ) ```

Add the `MCPClientInstall` product to your target.

## Usage

```swift import MCPClientInstall

let server = MCPServerSpec(     name: "my-server",     command: "/usr/local/bin/my-server",     arguments: ["--mcp"] )

let location = MCPDesktopClient.codex.configurationLocation let directory = location.directory(relativeTo: homeDirectory) let configURL = directory.appendingPathComponent(location.fileName)

// JSON: Claude Desktop, Claude Code, or Cursor let root = try MCPClientInstall.existingJSON(at: configURL) let merged = try addingMCPServer(server, toJSON: root) let data = try MCPClientInstall.prettyJSONData(from: merged.root)

// TOML: Codex let existing = try String(contentsOf: configURL, encoding: .utf8) let updated = try addingMCPServer(server, toCodexTOML: existing) ```

Writing is deliberately separate from merging, so an application can show a diff or ask for confirmation first:

```swift try MCPClientInstall.writeConfig(     data,     to: configURL,     backupSuffix: server.backupSuffix ) ```

For a complete prepare, safe replacement, read-back verification, and recoverable backup in one operation:

```swift let result = try MCPClientInstall.installServer(     server,     format: location.format,     at: configURL )

let restored = try MCPClientInstall.restoreBackup(     for: server,     at: configURL,     displacedSuffix: ".my-server-before-restore" ) ```

## Safety

MCPClientInstall does not silently replace malformed or structurally incompatible configuration. Its file helper refuses symlinks and special files, retains metadata when replacing an existing file, and keeps the previous contents beside the target.

Applications remain responsible for obtaining user consent and filesystem access. The package has no UI and never searches for or modifies configuration on import.

## Requirements

- Swift 6.2+ - macOS 14+ - Linux with a Swift 6.2 toolchain

## Documentation

The package includes a DocC catalog and is configured for hosted documentation on Swift Package Index.

## License

MIT. See [LICENSE](LICENSE).

## Package Metadata

Repository: adamtheturtle/mcpclientinstall

Default branch: main

README: README.md
