Making an MCP Server Install Itself: Three Hosts, Three Mechanisms, Gotchas

MCP server setup still often means hand-editing a JSON file — and every host uses a different file and format. That friction keeps developers from running servers they'd otherwise use. This post breaks down three hosts, their installation mechanisms, and the gotchas that trip you up.
Three Hosts, Three Mechanisms
- VS Code: Has a real API —
registerMcpServerDefinitionProvider. Declare a provider inpackage.jsonand return the server definition at runtime. VS Code shows a consent prompt. No config file editing. Cleanest, but requires shipping a VS Code extension. - Cursor: No native API. Write
.cursor/mcp.jsondirectly with root keymcpServers. - Claude Code: Use the CLI. Do not hand-write the file. Run e.g.:
claude mcp add --transport stdio --scope <user|local> --env … <name> -- node <path>
Six Gotchas to Guard Against
- That JSON file isn't yours. Cursor's
mcp.jsonholds the user's other servers. Read, merge your entry, preserve unrelated keys — don't overwrite. - Survive a malformed file. If the file exists but is invalid JSON, do not treat it as empty and overwrite. Same for read/permission errors — rethrow. Treating “couldn't read it” as “nothing there” will corrupt configurations.
- Back up + write atomically. Copy the existing file before touching it, write to a temp file, then rename over the target. A half-written
mcp.jsonbreaks the editor. - Installing twice must be a no-op, not an error. The Claude CLI errors if the entry already exists — so
removethenadd. For file hosts, key by server name and replace in place. Re-running should converge, not duplicate. - Scope changes everything. User-level vs project-level install changes where the config lands and what the server needs (e.g., explicit data dir vs. upward-discovery). Pick deliberately.
- You own staying current. The version registered drifts from what you ship. Add a check: “is what's installed still the version I bundle?” and a clean re-install path. One button shows state: install, update, or up to date.
The meta-lesson: hand-setup fails because a human pasting a snippet doesn't know the absolute path, the right scope, env vars, or how to merge safely. The install code does.
📖 Read the full source: r/ClaudeAI
👀 See Also

OpenClaw Docker users: Pin to commit 0c926a2c5 to fix broken Discord and channel extensions
After updating OpenClaw via Docker, channel extensions like Discord, Signal, and WhatsApp fail with module import errors. The issue stems from commit d9c285e93 and a second Docker-specific bug. Pin to commit 0c926a2c5 for a stable workaround.

The Hitchhiker's Guide to Agentic AI — Full Overview
A comprehensive Reddit post covering how LLMs work, RL for LLMs, reasoning, evaluation, agentic memory (RAG), and multi-agent systems, with a link to the full paper.

OpenClaw Workspace Configuration Lessons from Two Months of Use
A developer's experience with OpenClaw shows that workspace quality impacts agent performance 5-10x, with specific guidance on SOUL.md, AGENTS.md, MEMORY.md, USER.md, and skills configuration.

Mac Mini M4 Pro vs Mac Studio M4 Max for Local LLM Inference – Key Considerations
A developer compares Mac Mini M4 Pro (12C CPU/16C GPU, 273 GB/s) vs Mac Studio M4 Max (16C CPU/40C GPU, 546 GB/s), both 64GB/1TB, for local inference with Gemma 4 and Qwen. Key question: is the bandwidth jump worth $600?