MCPClientInstall

0.3.1

Safe, non-destructive MCP client configuration editing in Swift
adamtheturtle/MCPClientInstall

What's New

MCPClientInstall 0.3.1

2026-08-05T13:30:57Z

Restores the public prepareServerUpdate API accidentally made internal in 0.3.0. Host apps can again preview whether an MCP server entry exists before asking for confirmation; the actual installation still re-prepares under the transaction lock.\n\nAll macOS/Linux tests, SwiftLint, and automated review pass.

MCPClientInstall

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

Documentation | Swift Package Index

MCPClientInstall adds or updates a local MCP server in:

  • Claude Desktop, Claude Code, and Cursor JSON configuration
  • Codex TOML configuration

It preserves unrelated settings, refuses ambiguous configuration shapes, handles quoted TOML keys and multiline values, retains existing line endings, and can replace files while preserving metadata and leaving a backup.

Installation

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

Add the MCPClientInstall product to your target.

Usage

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:

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

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

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.

Description

  • Swift Tools 6.2.0
View More Packages from this Author

Dependencies

Last updated: Thu Aug 20 2026 04:15:11 GMT-0900 (Hawaii-Aleutian Daylight Time)