ZedのMCPサーバでコンテキスト共有したい

AI

ZedでAIエージェントを使って書いてもらってると、GitHub Copilot経由でGPT-5.2-Codexの272Kというのがコンテキストウインドウの最大らしく、まあこの数値が大きくなったところで無限になるわけじゃないし、大きくなればなるほどウインドウ内のフォーカスがブレる気がするので、セッションを跨いでコンテキストを共有したい、と。

で、Ruleとか色々あるので、gitに履歴を取るとかはもちろん可能にしても、やはりMCPサーバを書かないとできないこともあって、書いた。

homebrew-agentops_mcp_server

brew tap rioriost/agentops_mcp_server
brew install agentops_mcp_server

brewでインストールして、ZedにMCPサーバを追加する。

{
  "agentops-server": {
    "command": "/opt/homebrew/bin/agentops_mcp_server",
    "args": [],
    "env": {}
  }
}

あと、ツールを許可しないと毎回Yesしないとならないので、適宜allowしてください。

"agent": {
  "tool_permissions": {
    "tools": {
      "create_directory": {
        "default": "allow"
      },
      "fetch": {
        "default": "allow"
      },
      "web_search": {
        "default": "allow"
      },
      "terminal": {
        "default": "allow"
      },
      "mcp:agentops-server:handoff.read": {
        "default": "allow"
      },
      "mcp:agentops-server:handoff_read": {
        "default": "allow"
      },
      "mcp:agentops-server:handoff.update": {
        "default": "allow"
      },
      "mcp:agentops-server:handoff_update": {
        "default": "allow"
      },
      "mcp:agentops-server:handoff.normalize": {
        "default": "allow"
      },
      "mcp:agentops-server:handoff_normalize": {
        "default": "allow"
      },
      "mcp:agentops-server:session.log_append": {
        "default": "allow"
      },
      "mcp:agentops-server:session_log_append": {
        "default": "allow"
      },
      "mcp:agentops-server:session.capture_context": {
        "default": "allow"
      },
      "mcp:agentops-server:session_capture_context": {
        "default": "allow"
      },
      "mcp:agentops-server:session.checkpoint": {
        "default": "allow"
      },
      "mcp:agentops-server:session_checkpoint": {
        "default": "allow"
      },
      "mcp:agentops-server:session.diff_since_checkpoint": {
        "default": "allow"
      },
      "mcp:agentops-server:session_diff_since_checkpoint": {
        "default": "allow"
      },
      "mcp:agentops-server:repo.verify": {
        "default": "allow"
      },
      "mcp:agentops-server:repo_verify": {
        "default": "allow"
      },
      "mcp:agentops-server:repo.commit": {
        "default": "allow"
      },
      "mcp:agentops-server:repo_commit": {
        "default": "allow"
      },
      "mcp:agentops-server:repo.status_summary": {
        "default": "allow"
      },
      "mcp:agentops-server:repo_status_summary": {
        "default": "allow"
      },
      "mcp:agentops-server:repo.commit_message_suggest": {
        "default": "allow"
      },
      "mcp:agentops-server:repo_commit_message_suggest": {
        "default": "allow"
      },
      "mcp:agentops-server:tests.suggest": {
        "default": "allow"
      },
      "mcp:agentops-server:tests_suggest": {
        "default": "allow"
      },
      "mcp:agentops-server:tests.suggest_from_failures": {
        "default": "allow"
      },
      "mcp:agentops-server:tests_suggest_from_failures": {
        "default": "allow"
      },
      "mcp:agentops-server:commit_if_verified": {
        "default": "allow"
      },
      "mcp:agentops-server:log_append": {
        "default": "allow"
      }
    }
  },
  "default_model": {
    "provider": "copilot_chat",
    "model": "gpt-5.2-codex"
  }
},

次にプロジェクト用のディレクトリを作る。

zed-agentops-init your_project

で、Zedで[Command]+[O]で、your_projectフォルダを開く。

エージェントパネル(下のスクショだと、右下の部分)に、例えばPythonなら「uv initして」「uv add numpyして、main.pyでimport」とかやると、.agent/handoff.mdに履歴が溜まって、verifyして、git add / commitを自動でどんどんやってくれます。

コンテキストウインドウがリミットいって、新しいセッション(スレッド)を開くと、.agent/handoff.mdを自動的に読み込みます。Zedは前スレを要約して受け渡すはずなんだけど、現状、エラー出まくりでダメです。

Zedの画面、.agent/handoff.mdが次のセッションで自動的に開かれる

もっと豪勢な仕組みにしても良いんだろうけど、Zedと小さなMCPサーバだけで動くので、お手軽だと思われ。

タイトルとURLをコピーしました