Principle:0xK3vin MegaMemory MCP Editor Integration
| Knowledge Sources | |
|---|---|
| Domains | MCP, Editor_Integration, Tooling |
| Last Updated | 2026-10-27 12:00 GMT |
Overview
An integration technique that registers an MCP server with a coding editor's configuration and installs workflow instructions, skill plugins, and slash commands to teach the editor's agent a persistent memory loop.
Description
MCP editor integration configures a coding editor (or AI agent environment) to launch and communicate with an MCP server via stdio. Beyond mere server registration, it installs the behavioral scaffolding the editor's agent needs to actually use the tools: instruction files (AGENTS.md / CLAUDE.md) that describe the understand → work → update loop, skill plugins that teach the agent when to call each tool, and slash commands for structured workflows like bootstrap and save.
Problem solved: Registering an MCP server only makes tools available; it does not make the agent use them. Without instruction files and skill plugins, agents rarely call memory tools proactively. Integration must (a) write the MCP server entry into the editor's config, and (b) install the behavioral instructions that make the agent follow the memory loop.
Context: MegaMemory's installer (src/install.ts) targets four editors: opencode (MCP config + AGENTS.md + skill plugin + commands), Claude Code (MCP config + CLAUDE.md + commands), Antigravity (workspace-level MCP config), and Codex (MCP config via codex mcp add CLI or TOML fallback + AGENTS.md). Installation is idempotent via a MANAGED_FILE_MARKER so re-running updates only managed files. Config reading uses JSONC comment stripping to safely merge into existing configs.
Usage
Use this principle when:
- You are building an MCP server that coding agents should use proactively
- Mere tool registration is insufficient — agents need instruction files to follow a workflow
- You need to support multiple editors with different config formats (JSON, JSONC, TOML)
- Idempotent, safe installation is required (no clobbering of user-modified files)
Theoretical Basis
Integration has three layers:
- Transport layer: The editor's config file gains an MCP server entry pointing to the server's launch command. The editor spawns the server as a stdio child process.
- Behavior layer: An instruction file (AGENTS.md / CLAUDE.md) teaches the agent the workflow ("Before tasks: call understand. After tasks: call create_concept"). This is what makes the agent proactively use the tools.
- Artifact layer: Skill plugins and slash commands provide structured entry points (e.g., /bootstrap-memory) for complex multi-step workflows.
Idempotency: A managed-file marker (MegaMemory-managed file...) distinguishes installer-written files from user-authored ones. The installer only overwrites files containing the marker, and only appends instruction snippets if the marker section is absent. Config reads parse JSONC safely and refuse to clobber unparseable configs.
Pseudo-code:
# Abstract installation (NOT real implementation)
def install(target):
runtime = detect_global_command() # "megamemory" or "node entry.js"
config = read_editor_config(target)
config["mcp"]["megamemory"] = mcp_entry(runtime)
write_editor_config(target, config)
append_instruction_file(target.agents_md, LOOP_SNIPPET)
if target == "opencode":
copy_skill_plugin("plugin/megamemory.ts")
copy_commands(["bootstrap-memory.md", "save-memory.md"])