Skip to content

Instantly share code, notes, and snippets.

@DawnBreather
Created January 21, 2026 12:39
Show Gist options
  • Select an option

  • Save DawnBreather/be77a4fef893eec41c249fa2a6283322 to your computer and use it in GitHub Desktop.

Select an option

Save DawnBreather/be77a4fef893eec41c249fa2a6283322 to your computer and use it in GitHub Desktop.
MCP Global Configuration Installer for Claude Code
#!/usr/bin/env bun
/**
* MCP Global Configuration Installer
*
* Fetches MCP server configuration from 1Password and merges it into ~/.claude.json
*
* Prerequisites:
* - 1Password CLI (op) installed and signed in
* - bun runtime
*
* Installation:
* 1. Save this script to ~/.local/bin/install-mcp-config.ts
* 2. chmod +x ~/.local/bin/install-mcp-config.ts
* 3. Run: install-mcp-config.ts
*
* Or run directly with:
* bun run ~/.local/bin/install-mcp-config.ts
*/
import { $ } from "bun";
import { homedir } from "os";
import { join } from "path";
const CLAUDE_CONFIG_PATH = join(homedir(), ".claude.json");
const OP_REFERENCE = "op://Config/mcp.global-configuration/notesPlain";
async function main() {
console.log("Fetching MCP configuration from 1Password...");
// Fetch config from 1Password
const result = await $`op read ${OP_REFERENCE}`.text();
const mcpServers = JSON.parse(result.trim());
console.log(`Found ${Object.keys(mcpServers).length} MCP servers:`, Object.keys(mcpServers).join(", "));
// Read existing claude.json
const claudeConfigFile = Bun.file(CLAUDE_CONFIG_PATH);
if (!(await claudeConfigFile.exists())) {
console.error(`Error: ${CLAUDE_CONFIG_PATH} not found`);
process.exit(1);
}
const claudeConfig = await claudeConfigFile.json();
// Merge MCP servers
const existingServers = claudeConfig.mcpServers || {};
const mergedServers = { ...existingServers, ...mcpServers };
const added = Object.keys(mcpServers).filter((k) => !existingServers[k]);
const updated = Object.keys(mcpServers).filter((k) => existingServers[k]);
claudeConfig.mcpServers = mergedServers;
// Write back
await Bun.write(CLAUDE_CONFIG_PATH, JSON.stringify(claudeConfig, null, 2));
console.log("\nMCP configuration installed successfully!");
if (added.length) console.log(` Added: ${added.join(", ")}`);
if (updated.length) console.log(` Updated: ${updated.join(", ")}`);
console.log(`\nRestart Claude Code to apply changes.`);
}
main().catch((err) => {
console.error("Error:", err.message);
process.exit(1);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment