Skip to content

agentmemory connect zed overwrites existing Zed settings.json instead of merging context_servers #952

Description

@IgorArkhipov

Summary

Running agentmemory connect zed appears to overwrite the entire existing Zed config at ~/.config/zed/settings.json instead of preserving existing settings and only adding/updating the context_servers.agentmemory entry.

What happened

I ran:

agentmemory connect zed

The command reported success and created a backup:

→ Using MCP via ~/.config/zed/settings.json (key: context_servers).
Backup: /Users/<username>/.agentmemory/backups/zed-2026-06-20T03-15-54-964Z.json
zed → /Users/<username>/.config/zed/settings.json

But the existing /Users/<username>/.config/zed/settings.json contents were wiped and replaced with the new AgentMemory context server config:

{
  "context_servers": {
    "agentmemory": {
      "command": "npx",
      "args": ["-y", "@agentmemory/mcp"],
      "env": {
        "AGENTMEMORY_URL": "${AGENTMEMORY_URL:-http://localhost:3111}",
        "AGENTMEMORY_SECRET": "${AGENTMEMORY_SECRET:-}",
        "AGENTMEMORY_TOOLS": "${AGENTMEMORY_TOOLS:-all}"
      }
    }
  }
}

Expected behavior

agentmemory connect zed should preserve all existing Zed settings and merge/upsert only:

"context_servers": {
  "agentmemory": { ... }
}

Existing top-level settings and existing context_servers entries should remain intact.

Actual behavior

The command replaces the whole settings file, causing unrelated Zed preferences and existing context server settings to be lost.
A backup is created, but the command still reports success after destructive behavior.

Suggested fix

Parse the existing Zed settings file, merge context_servers.agentmemory into it, and write the merged result back.
If the existing settings file cannot be parsed, the command should fail safely or ask before replacing it.

A regression test would be useful for:

  • preserving unrelated top-level Zed settings
  • preserving existing context_servers entries
  • updating an existing context_servers.agentmemory entry
  • not overwriting the file when parsing fails

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions