Skip to content

Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.

Go

MUL-3263: support managed MCP config for Cursor (#4081)

Bohan Jiangf415099c4a24
diff --git a/apps/docs/content/docs/providers.ja.mdx b/apps/docs/content/docs/providers.ja.mdx
index 5f5762b5e4..237361b0cb 100644
--- a/apps/docs/content/docs/providers.ja.mdx
+++ b/apps/docs/content/docs/providers.ja.mdx
@@ -14,16 +14,16 @@ Multica は **12 個の AI コーディングツール**を標準でサポート
| ツール | ベンダー | セッション再開 | MCP | スキル注入パス | モデル選択 |
|---|---|---|---|---|---|
| **Antigravity** | Google | ✅ (`--conversation <id>`) | ❌ | `.agents/skills/` | 動的探索(`agy models`) |
-| **Claude Code** | Anthropic | ✅ | **✅(実際に使用する唯一のツール)** | `.claude/skills/` | 静的 + flag |
-| **Codex** | OpenAI | ⚠️ コードは存在するが到達不可 | ❌ | `$CODEX_HOME/skills/` | 静的 |
+| **Claude Code** | Anthropic | ✅ | ✅ | `.claude/skills/` | 静的 + flag |
+| **Codex** | OpenAI | ⚠️ コードは存在するが到達不可 | ✅ | `$CODEX_HOME/skills/` | 静的 |
| **Copilot** | GitHub | ✅ | ❌ | `.github/skills/` | 静的(アカウントの権限で決定) |
-| **Cursor** | Anysphere | ⚠️ コードは存在するが使用不可 | ❌ | `.cursor/skills/` | 動的探索 |
+| **Cursor** | Anysphere | ⚠️ コードは存在するが使用不可 | ✅ | `.cursor/skills/` | 動的探索 |
| **Gemini** | Google | ❌ | ❌ | `.agent_context/skills/` | 静的 |
-| **Hermes** | Nous Research | ✅ | ❌ | `.agent_context/skills/`(フォールバック) | 動的探索 |
-| **Kimi** | Moonshot | ✅ | ❌ | `.kimi/skills/` | 動的探索 |
-| **Kiro CLI** | Amazon | ✅ | ❌ | `.kiro/skills/` | 動的探索 |
-| **OpenCode** | SST | ✅ | ❌ | `.opencode/skills/` | 動的探索 |
-| **OpenClaw** | オープンソース | ✅ | ❌ | `.agent_context/skills/`(フォールバック) | エージェントにバインドされ、タスクごとに切り替え不可 |
+| **Hermes** | Nous Research | ✅ | ✅ | `.agent_context/skills/`(フォールバック) | 動的探索 |
+| **Kimi** | Moonshot | ✅ | ✅ | `.kimi/skills/` | 動的探索 |
+| **Kiro CLI** | Amazon | ✅ | ✅ | `.kiro/skills/` | 動的探索 |
+| **OpenCode** | SST | ✅ | ✅ | `.opencode/skills/` | 動的探索 + variant |
+| **OpenClaw** | オープンソース | ✅ | ✅ | `.agent_context/skills/`(フォールバック) | エージェントにバインドされ、タスクごとに切り替え不可 |
| **Pi** | Inflection AI | ✅(セッションがファイルパス) | ❌ | `.pi/skills/` | 動的探索 |
## 各ツールの用途
@@ -34,11 +34,11 @@ Google が提供します。CLI バイナリ名は `agy` です。Google の Ant
### Claude Code
-Anthropic が提供します。**新規ユーザーにとって第一の選択肢**であり、最も完成度の高い機能セットを備えています: セッション再開が実際に動作し、**11 個の中で MCP 構成を本当に読み取る唯一のツール**であり、`--max-turns` や `--append-system-prompt` のような細かな調整 flag をサポートします。Anthropic API キーが必要です。
+Anthropic が提供します。**新規ユーザーにとって第一の選択肢**であり、最も完成度の高い機能セットを備えています: セッション再開が実際に動作し、MCP 構成を読み取り、`--max-turns` や `--append-system-prompt` のような細かな調整 flag をサポートします。Anthropic API キーが必要です。
### Codex
-OpenAI が提供します。JSON-RPC 2.0 を使用し、ステートフルな能力がより強く、よりきめ細かい承認メカニズム(`exec_command` および `patch_apply` に対する手動承認)を備えています。**セッション再開のコードは存在しますが、現在は到達できません** — 再開が必要なら、Claude Code または ACP 系のいずれかを選んでください。
+OpenAI が提供します。JSON-RPC 2.0 を使用し、ステートフルな能力がより強く、よりきめ細かい承認メカニズム(`exec_command` および `patch_apply` に対する手動承認)を備えています。MCP 構成はタスクごとの `$CODEX_HOME/config.toml` に書き込まれます。**セッション再開のコードは存在しますが、現在は到達できません** — 再開が必要なら、Claude Code または ACP 系のいずれかを選んでください。
### Copilot
@@ -46,7 +46,7 @@ GitHub が提供します。モデルルーティングは GitHub アカウン
### Cursor
-Anysphere が提供し、Cursor エディターに対応する CLI です。**セッション再開のコードは存在しますが、実際には動作しません** — Cursor CLI のイベントストリームがセッション ID を返さないため、渡す再開値は常に無効です。再開が必要なら、別のものを選んでください。
+Anysphere が提供し、Cursor エディターに対応する CLI です。**セッション再開のコードは存在しますが、実際には動作しません** — Cursor CLI のイベントストリームがセッション ID を返さないため、渡す再開値は常に無効です。再開が必要なら、別のものを選んでください。MCP 構成はタスクワークスペースの `.cursor/mcp.json` に書き込まれ、Cursor のプロジェクト approval ファイルはタスクごとの `CURSOR_DATA_DIR` 配下に置かれるため、管理対象 MCP server はユーザーのグローバル Cursor approvals に依存しません。
### Gemini
@@ -54,23 +54,23 @@ Google が提供し、Gemini 2.5 および 3 シリーズをサポートしま
### Hermes
-Nous Research が提供します。ACP プロトコルを使用します(Kimi とトランスポート層を共有します)。セッション再開が動作します。しかし**スキル注入パスは専用のものではなく汎用のフォールバック**(`.agent_context/skills/`)です — Hermes CLI 自体がこのパスを読み取らない場合、スキルが適用されないことがあります。テストで確認してください。
+Nous Research が提供します。ACP プロトコルを使用します(Kimi とトランスポート層を共有します)。セッション再開が動作し、MCP 構成は ACP `mcpServers` として渡されます。しかし**スキル注入パスは専用のものではなく汎用のフォールバック**(`.agent_context/skills/`)です — Hermes CLI 自体がこのパスを読み取らない場合、スキルが適用されないことがあります。テストで確認してください。
### Kimi
-Moonshot が提供し、中国市場を対象としています。Hermes と ACP プロトコルを共有しますが、スキルパス `.kimi/skills/` は Kimi CLI のネイティブな探索メカニズムであり、Hermes のフォールバックとは異なります。
+Moonshot が提供し、中国市場を対象としています。Hermes と ACP プロトコルを共有し、MCP 構成も ACP `mcpServers` として渡されますが、スキルパス `.kimi/skills/` は Kimi CLI のネイティブな探索メカニズムであり、Hermes のフォールバックとは異なります。
### Kiro CLI
-Amazon が提供します。`kiro-cli acp` を通じて stdio 上で ACP を使用します。セッション再開は ACP `session/load` で動作し、モデル選択は `session/set_model` で動作し、スキルはプロジェクトレベルのネイティブ探索のために `.kiro/skills/` にコピーされます。
+Amazon が提供します。`kiro-cli acp` を通じて stdio 上で ACP を使用します。セッション再開は ACP `session/load` で動作し、MCP 構成は ACP `mcpServers` として渡され、モデル選択は `session/set_model` で動作し、スキルはプロジェクトレベルのネイティブ探索のために `.kiro/skills/` にコピーされます。
### OpenCode
-SST が提供するオープンソースです。利用可能なモデルを動的に探索します(CLI の構成ファイルをスキャン)。セッション再開が動作します。**自分のモデルカタログをカスタマイズしたい、いじるのが好きなユーザーに適しています。**
+SST が提供するオープンソースです。利用可能なモデルと model variant を動的に探索します(CLI の構成ファイルをスキャン)。セッション再開が動作し、エージェントの `mcp_config` フィールドを消費します。Multica は `OPENCODE_CONFIG_CONTENT` 環境変数でインライン注入するため、エージェントの MCP server はタスク workdir の `opencode.json`(エージェントまたはユーザーが所有するファイル)を書き換えずに OpenCode に届きます。モデルが variant を公開している場合、Multica はそれをエージェントの thinking selector として表示し、選択値を `opencode run --variant` で OpenCode に渡します。**自分のモデルカタログをカスタマイズしたい、いじるのが好きなユーザーに適しています。**
### OpenClaw
-オープンソースプロジェクトであり、CLI エージェントオーケストレーターです。**モデルはエージェント層にバインドされます**(`openclaw agents add --model`) — タスクごとに上書きできません。構成は厳格に制御されます: ユーザーは `--model` や `--system-prompt` を渡せず、エージェント登録時の構成が決定します。
+オープンソースプロジェクトであり、CLI エージェントオーケストレーターです。MCP 構成は Multica のタスクごとの config wrapper 経由で書き込まれます。**モデルはエージェント層にバインドされます**(`openclaw agents add --model`) — タスクごとに上書きできません。構成は厳格に制御されます: ユーザーは `--model` や `--system-prompt` を渡せず、エージェント登録時の構成が決定します。
### Pi
@@ -88,12 +88,14 @@ Inflection AI が提供し、ミニマルです。**セッション再開の方
**意思決定のために**: ワークフローでエージェントがタスク間でコンテキストを保持する必要がある場合(失敗時のリトライ、手動の再実行、対話的な反復)、✅ の行にあるツールだけを選んでください。
-## MCP 構成: Claude Code だけが実際に読み取る
+## MCP 構成: ツールごとの対応
-**12 個のツールのうち、`mcp_config` を実際に消費するのは Claude Code だけです**。残りの 11 個はこのフィールドを受け取りますが、**完全に無視します** — エラーも警告もなく、構成はただ効果を発揮しません。
+**12 個のツールのうち、`mcp_config` を実際に消費するのは 8 個です: Claude Code、Codex、Cursor、Hermes、Kimi、Kiro CLI、OpenCode、OpenClaw**。残りの 4 個はこのフィールドを受け取りますが、**無視します** — エラーも警告もなく、構成はただ効果を発揮しません。
+
+接続方式はツールごとに異なります: Claude Code は `--mcp-config` と `--strict-mcp-config` で受け取り、Codex は daemon 管理の `mcp_servers` ブロックをタスクごとの `$CODEX_HOME/config.toml` に書き込み、Cursor は `.cursor/mcp.json` とタスクごとの `CURSOR_DATA_DIR` 配下のプロジェクト approval を書き込みます。Hermes、Kimi、Kiro CLI は ACP `mcpServers` で受け取ります。OpenCode は `OPENCODE_CONFIG_CONTENT` 環境変数でインライン構成を受け取り、OpenClaw は Multica のタスクごとの config wrapper 経由で `mcp.servers` を受け取ります。OpenCode の経路はプロジェクトの `opencode.json` を書き換えません。
<Callout type="warning">
-エージェント構成で `mcp_config` を設定しても、Claude Code 以外のツールを選んだ場合、MCP サーバーはそのエージェントに**何の効果**も及ぼしません。現在、MCP 連携は Claude Code のみをカバーしています。
+エージェント構成で `mcp_config` を設定しても、MCP 列に ✅ がないツールを選んだ場合、MCP サーバーはそのエージェントに**何の効果**も及ぼしません。MCP 連携はツールごとに実装されています。
</Callout>
## スキルファイルが置かれる場所
diff --git a/apps/docs/content/docs/providers.ko.mdx b/apps/docs/content/docs/providers.ko.mdx
index 155d11dc2a..4bb80a759a 100644
--- a/apps/docs/content/docs/providers.ko.mdx
+++ b/apps/docs/content/docs/providers.ko.mdx
@@ -17,7 +17,7 @@ Multica는 **12개의 AI 코딩 도구**를 기본 지원합니다. 이들은
| **Claude Code** | Anthropic | ✅ | ✅ | `.claude/skills/` | 정적 + flag |
| **Codex** | OpenAI | ⚠️ 코드는 존재하지만 도달 불가 | ✅ | `$CODEX_HOME/skills/` | 정적 |
| **Copilot** | GitHub | ✅ | ❌ | `.github/skills/` | 정적 (계정 권한으로 결정) |
-| **Cursor** | Anysphere | ⚠️ 코드는 존재하지만 사용 불가 | ❌ | `.cursor/skills/` | 동적 탐색 |
+| **Cursor** | Anysphere | ⚠️ 코드는 존재하지만 사용 불가 | ✅ | `.cursor/skills/` | 동적 탐색 |
| **Gemini** | Google | ❌ | ❌ | `.agent_context/skills/` | 정적 |
| **Hermes** | Nous Research | ✅ | ✅ | `.agent_context/skills/` (fallback) | 동적 탐색 |
| **Kimi** | Moonshot | ✅ | ✅ | `.kimi/skills/` | 동적 탐색 |
@@ -46,7 +46,7 @@ GitHub에서 제공합니다. 모델 라우팅은 GitHub 계정 권한을 거칩
### Cursor
-Anysphere에서 제공하며, Cursor 에디터에 대응하는 CLI입니다. **세션 재개 코드는 존재하지만 실제로는 동작하지 않습니다** — Cursor CLI 이벤트 스트림이 세션 ID를 반환하지 않으므로, 전달하는 재개 값은 항상 무효입니다. 재개가 필요하다면 다른 것을 선택하세요.
+Anysphere에서 제공하며, Cursor 에디터에 대응하는 CLI입니다. **세션 재개 코드는 존재하지만 실제로는 동작하지 않습니다** — Cursor CLI 이벤트 스트림이 세션 ID를 반환하지 않으므로, 전달하는 재개 값은 항상 무효입니다. 재개가 필요하다면 다른 것을 선택하세요. MCP 구성은 작업 워크스페이스의 `.cursor/mcp.json`에 기록되고, Cursor의 프로젝트 approval 파일은 작업별 `CURSOR_DATA_DIR` 아래에 기록되므로, 관리되는 MCP 서버는 사용자의 전역 Cursor approval에 의존하지 않습니다.
### Gemini
@@ -90,9 +90,9 @@ Inflection AI에서 제공하며, 미니멀합니다. **세션 재개 방식이
## MCP 구성: 도구별 지원
-**12개 도구 중 `mcp_config`를 실제로 소비하는 것은 7개입니다: Claude Code, Codex, Hermes, Kimi, Kiro CLI, OpenCode, OpenClaw**. 나머지 5개는 이 필드를 받아들이지만 **무시합니다** — 오류도, 경고도 없으며, 구성이 그저 효과를 내지 못합니다.
+**12개 도구 중 `mcp_config`를 실제로 소비하는 것은 8개입니다: Claude Code, Codex, Cursor, Hermes, Kimi, Kiro CLI, OpenCode, OpenClaw**. 나머지 4개는 이 필드를 받아들이지만 **무시합니다** — 오류도, 경고도 없으며, 구성이 그저 효과를 내지 못합니다.
-각 도구의 연결 방식은 다릅니다: Claude Code는 `--mcp-config`와 `--strict-mcp-config`로 받고, Codex는 데몬이 관리하는 `mcp_servers` 블록을 작업별 `$CODEX_HOME/config.toml`에 기록하며, Hermes/Kimi/Kiro CLI는 ACP `mcpServers`로 받습니다. OpenCode는 `OPENCODE_CONFIG_CONTENT` 환경 변수로 인라인 구성을 받고, OpenClaw는 Multica의 작업별 config wrapper를 통해 `mcp.servers`를 받습니다. OpenCode 경로는 프로젝트의 `opencode.json`을 다시 쓰지 않습니다.
+각 도구의 연결 방식은 다릅니다: Claude Code는 `--mcp-config`와 `--strict-mcp-config`로 받고, Codex는 데몬이 관리하는 `mcp_servers` 블록을 작업별 `$CODEX_HOME/config.toml`에 기록하며, Cursor는 `.cursor/mcp.json`과 작업별 `CURSOR_DATA_DIR` 아래의 프로젝트 approval을 기록합니다. Hermes/Kimi/Kiro CLI는 ACP `mcpServers`로 받습니다. OpenCode는 `OPENCODE_CONFIG_CONTENT` 환경 변수로 인라인 구성을 받고, OpenClaw는 Multica의 작업별 config wrapper를 통해 `mcp.servers`를 받습니다. OpenCode 경로는 프로젝트의 `opencode.json`을 다시 쓰지 않습니다.
<Callout type="warning">
에이전트 구성에서 `mcp_config`를 설정했더라도 MCP 열에 ✅가 없는 도구를 선택하면, MCP 서버가 해당 에이전트에 **아무런 효과**도 미치지 않습니다. MCP 연동은 도구별로 구현됩니다.
diff --git a/apps/docs/content/docs/providers.mdx b/apps/docs/content/docs/providers.mdx
index 3d4b85bd3b..75c64e0097 100644
--- a/apps/docs/content/docs/providers.mdx
+++ b/apps/docs/content/docs/providers.mdx
@@ -17,7 +17,7 @@ For guidance on picking a tool when creating an agent, see [Creating and configu
| **Claude Code** | Anthropic | ✅ | ✅ | `.claude/skills/` | Static + flag |
| **Codex** | OpenAI | ⚠️ Code exists but unreachable | ✅ | `$CODEX_HOME/skills/` | Static |
| **Copilot** | GitHub | ✅ | ❌ | `.github/skills/` | Static (determined by account entitlement) |
-| **Cursor** | Anysphere | ⚠️ Code exists but unusable | ❌ | `.cursor/skills/` | Dynamic discovery |
+| **Cursor** | Anysphere | ⚠️ Code exists but unusable | ✅ | `.cursor/skills/` | Dynamic discovery |
| **Gemini** | Google | ❌ | ❌ | `.agent_context/skills/` | Static |
| **Hermes** | Nous Research | ✅ | ✅ | `.agent_context/skills/` (fallback) | Dynamic discovery |
| **Kimi** | Moonshot | ✅ | ✅ | `.kimi/skills/` | Dynamic discovery |
@@ -46,7 +46,7 @@ From GitHub. Model routing goes through your GitHub account entitlement — the
### Cursor
-From Anysphere, the CLI counterpart to the Cursor editor. **Session resumption code exists but doesn't actually work** — the Cursor CLI event stream doesn't return a session ID, so any resume value you pass is always invalid. If you need resume, pick something else.
+From Anysphere, the CLI counterpart to the Cursor editor. **Session resumption code exists but doesn't actually work** — the Cursor CLI event stream doesn't return a session ID, so any resume value you pass is always invalid. If you need resume, pick something else. MCP config is materialized into the task workspace's `.cursor/mcp.json`, with Cursor's project approval file written under a per-task `CURSOR_DATA_DIR` so managed MCP servers do not depend on the user's global Cursor approvals.
### Gemini
@@ -90,9 +90,9 @@ The session resumption mechanism is covered in [Tasks](/tasks#can-a-task-continu
## MCP configuration: provider-specific support
-**Of the 12 tools, seven consume `mcp_config`: Claude Code, Codex, Hermes, Kimi, Kiro CLI, OpenCode, and OpenClaw**. The other five accept the field but **ignore it** — no error, no warning, the config just has no effect.
+**Of the 12 tools, eight consume `mcp_config`: Claude Code, Codex, Cursor, Hermes, Kimi, Kiro CLI, OpenCode, and OpenClaw**. The other four accept the field but **ignore it** — no error, no warning, the config just has no effect.
-The runtime paths are provider-specific: Claude Code receives it through `--mcp-config` paired with `--strict-mcp-config`; Codex writes a daemon-managed `mcp_servers` block into the per-task `$CODEX_HOME/config.toml`; Hermes, Kimi, and Kiro CLI receive ACP `mcpServers`; OpenCode receives inline config through `OPENCODE_CONFIG_CONTENT`; OpenClaw receives `mcp.servers` through Multica's per-task config wrapper. OpenCode's path does **not** rewrite the project's `opencode.json`.
+The runtime paths are provider-specific: Claude Code receives it through `--mcp-config` paired with `--strict-mcp-config`; Codex writes a daemon-managed `mcp_servers` block into the per-task `$CODEX_HOME/config.toml`; Cursor writes `.cursor/mcp.json` plus per-task project approvals under `CURSOR_DATA_DIR`; Hermes, Kimi, and Kiro CLI receive ACP `mcpServers`; OpenCode receives inline config through `OPENCODE_CONFIG_CONTENT`; OpenClaw receives `mcp.servers` through Multica's per-task config wrapper. OpenCode's path does **not** rewrite the project's `opencode.json`.
<Callout type="warning">
If you set `mcp_config` in an agent configuration but pick a tool not marked ✅ in the MCP column, your MCP servers have **no effect** on that agent. MCP integration is provider-specific.
diff --git a/apps/docs/content/docs/providers.zh.mdx b/apps/docs/content/docs/providers.zh.mdx
index 128ee982e6..a3ed71972c 100644
--- a/apps/docs/content/docs/providers.zh.mdx
+++ b/apps/docs/content/docs/providers.zh.mdx
@@ -17,7 +17,7 @@ Multica 内置支持 **12 款 AI 编程工具**。它们都实现了同一套接
| **Claude Code** | Anthropic | ✅ | ✅ | `.claude/skills/` | 静态 + flag |
| **Codex** | OpenAI | ⚠️ 代码存在但不可达 | ✅ | `$CODEX_HOME/skills/` | 静态 |
| **Copilot** | GitHub | ✅ | ❌ | `.github/skills/` | 静态(账号权益决定)|
-| **Cursor** | Anysphere | ⚠️ 代码存在但不可用 | ❌ | `.cursor/skills/` | 动态发现 |
+| **Cursor** | Anysphere | ⚠️ 代码存在但不可用 | ✅ | `.cursor/skills/` | 动态发现 |
| **Gemini** | Google | ❌ | ❌ | `.agent_context/skills/` | 静态 |
| **Hermes** | Nous Research | ✅ | ✅ | `.agent_context/skills/` (fallback)| 动态发现 |
| **Kimi** | Moonshot | ✅ | ✅ | `.kimi/skills/` | 动态发现 |
@@ -46,7 +46,7 @@ GitHub 出品。模型路由走你的 GitHub 账号权益——工具自己不
### Cursor
-Anysphere 出品,Cursor 编辑器的 CLI 对应物。**会话恢复代码存在但实际不工作**——Cursor CLI 的事件流里不回传 session ID,所以你传的 resume 值永远无效。如果要 resume,选别的。
+Anysphere 出品,Cursor 编辑器的 CLI 对应物。**会话恢复代码存在但实际不工作**——Cursor CLI 的事件流里不回传 session ID,所以你传的 resume 值永远无效。如果要 resume,选别的。MCP 配置会写入任务工作区的 `.cursor/mcp.json`,Cursor 的项目 approval 文件写在单次任务的 `CURSOR_DATA_DIR` 下,因此托管的 MCP server 不依赖用户全局 Cursor approvals。
### Gemini
@@ -90,9 +90,9 @@ Inflection AI 出品,极简主义。**会话恢复机制特殊**——session
## MCP 配置:按工具不同
-**12 款工具里有 7 款实际消费 `mcp_config`:Claude Code、Codex、Hermes、Kimi、Kiro CLI、OpenCode、OpenClaw**。其他 5 款会接收这个字段但**忽略**——不报错、不警告,只是配置不生效。
+**12 款工具里有 8 款实际消费 `mcp_config`:Claude Code、Codex、Cursor、Hermes、Kimi、Kiro CLI、OpenCode、OpenClaw**。其他 4 款会接收这个字段但**忽略**——不报错、不警告,只是配置不生效。
-各工具的接入方式不同:Claude Code 通过 `--mcp-config` 加 `--strict-mcp-config` 接收;Codex 会把 daemon 管理的 `mcp_servers` block 写入单次任务的 `$CODEX_HOME/config.toml`;Hermes、Kimi、Kiro CLI 通过 ACP `mcpServers` 接收;OpenCode 通过 `OPENCODE_CONFIG_CONTENT` 环境变量内联接收;OpenClaw 通过 Multica 的单次任务配置 wrapper 接收 `mcp.servers`。OpenCode 这条路径**不会**改写项目里的 `opencode.json`。
+各工具的接入方式不同:Claude Code 通过 `--mcp-config` 加 `--strict-mcp-config` 接收;Codex 会把 daemon 管理的 `mcp_servers` block 写入单次任务的 `$CODEX_HOME/config.toml`;Cursor 会写入 `.cursor/mcp.json`,并把项目 approval 写到单次任务的 `CURSOR_DATA_DIR`;Hermes、Kimi、Kiro CLI 通过 ACP `mcpServers` 接收;OpenCode 通过 `OPENCODE_CONFIG_CONTENT` 环境变量内联接收;OpenClaw 通过 Multica 的单次任务配置 wrapper 接收 `mcp.servers`。OpenCode 这条路径**不会**改写项目里的 `opencode.json`。
<Callout type="warning">
如果你在智能体配置里设置了 `mcp_config`,但选了矩阵 MCP 列没有标 ✅ 的工具,你的 MCP server 对这个智能体**没有效果**。MCP 集成是按工具实现的。
diff --git a/apps/docs/content/docs/skills.ja.mdx b/apps/docs/content/docs/skills.ja.mdx
index 6d8fb2db6c..5e5089e687 100644
--- a/apps/docs/content/docs/skills.ja.mdx
+++ b/apps/docs/content/docs/skills.ja.mdx
@@ -54,7 +54,7 @@ GitHub や ClawHub からインポートしたスキルには、スクリプト
- **スキル** = 構造化された**ナレッジパック**(静的なコンテンツ + 指示)。エージェントはスキルを読んで「問題 X を見たら、こう考えてこう行動する」を学びます。
- **MCP**(Model Context Protocol)= **ツールチャネル**。エージェントは MCP を使って外部サービス(データベース、ファイルシステム、サードパーティ API)に接続し、それらを**呼び出します**。
-この 2 つは相互補完的です。現在の Multica では、MCP のサポートを**実際に使うのは Claude Code だけ**です — 他のツールは MCP 設定を受け取りはしますが、実際には使いません。MCP 専用のセクションは今後のリリースで追加される予定です。
+この 2 つは相互補完的です。現在の Multica では、MCP サポートは**ツールごとに実装されています**: Claude Code、Codex、Cursor、Hermes、Kimi、Kiro CLI、OpenCode、OpenClaw は `mcp_config` を使用し、他のツールはこのフィールドを受け取っても実際には使いません。MCP 専用のセクションは今後のリリースで追加される予定です。
---
diff --git a/apps/docs/content/docs/skills.ko.mdx b/apps/docs/content/docs/skills.ko.mdx
index 96e3c97e30..e72a80d62e 100644
--- a/apps/docs/content/docs/skills.ko.mdx
+++ b/apps/docs/content/docs/skills.ko.mdx
@@ -54,7 +54,7 @@ GitHub나 ClawHub에서 가져온 스킬에는 스크립트와 실행 가능한
- **스킬** = 구조화된 **지식 팩**(정적 콘텐츠 + 지침). 에이전트는 스킬을 읽어 "문제 X를 만나면 이렇게 생각하고 이렇게 처리하라"를 학습합니다.
- **MCP**(Model Context Protocol) = **도구 채널**. 에이전트는 MCP를 사용해 외부 서비스(데이터베이스, 파일 시스템, 서드파티 API)에 연결하고 이를 **호출**합니다.
-이 둘은 상호 보완적입니다. 현재 Multica에서 MCP 지원은 **도구별로 구현됩니다**: Claude Code, Codex, Hermes, Kimi, Kiro CLI, OpenCode, OpenClaw는 `mcp_config`를 사용하고, 다른 도구들은 이 필드를 받더라도 실제로 사용하지 않습니다. MCP 전용 섹션은 추후 릴리스에서 추가될 예정입니다.
+이 둘은 상호 보완적입니다. 현재 Multica에서 MCP 지원은 **도구별로 구현됩니다**: Claude Code, Codex, Cursor, Hermes, Kimi, Kiro CLI, OpenCode, OpenClaw는 `mcp_config`를 사용하고, 다른 도구들은 이 필드를 받더라도 실제로 사용하지 않습니다. MCP 전용 섹션은 추후 릴리스에서 추가될 예정입니다.
---
diff --git a/apps/docs/content/docs/skills.mdx b/apps/docs/content/docs/skills.mdx
index 900c42b732..a4da42c854 100644
--- a/apps/docs/content/docs/skills.mdx
+++ b/apps/docs/content/docs/skills.mdx
@@ -54,7 +54,7 @@ Both augment what an agent can do, but in different directions:
- **Skill** = a structured **knowledge pack** (static content + instructions). The agent reads a skill to learn "when I see problem X, here's how to think and what to do."
- **MCP** (Model Context Protocol) = a **tool channel**. The agent uses MCP to connect to external services (databases, filesystems, third-party APIs) and **invoke** them.
-The two are complementary. In Multica today, MCP support is **provider-specific**: Claude Code, Codex, Hermes, Kimi, Kiro CLI, OpenCode, and OpenClaw consume `mcp_config`; other tools receive the field but don't actually use it. A dedicated MCP section will come in a later release.
+The two are complementary. In Multica today, MCP support is **provider-specific**: Claude Code, Codex, Cursor, Hermes, Kimi, Kiro CLI, OpenCode, and OpenClaw consume `mcp_config`; other tools receive the field but don't actually use it. A dedicated MCP section will come in a later release.
---
diff --git a/apps/docs/content/docs/skills.zh.mdx b/apps/docs/content/docs/skills.zh.mdx
index 08919c29b9..bc88263f64 100644
--- a/apps/docs/content/docs/skills.zh.mdx
+++ b/apps/docs/content/docs/skills.zh.mdx
@@ -54,7 +54,7 @@ Skill 导入后需要**挂载到具体的智能体**才会生效。一个智能
- **Skill** = 结构化的**知识包**(静态内容 + 指令)。智能体读 Skill 来学"遇到 X 类问题该怎么想、怎么做"。
- **MCP**(Model Context Protocol)= **工具通道**。智能体通过 MCP 连外部服务(数据库、文件系统、第三方 API)并**调用**它们。
-两者可以同时用。目前 Multica 的 MCP 支持是**按工具实现**的:Claude Code、Codex、Hermes、Kimi、Kiro CLI、OpenCode、OpenClaw 会消费 `mcp_config`;其他工具会接收到这个字段但不会实际用。MCP 的专题会在后续版本展开。
+两者可以同时用。目前 Multica 的 MCP 支持是**按工具实现**的:Claude Code、Codex、Cursor、Hermes、Kimi、Kiro CLI、OpenCode、OpenClaw 会消费 `mcp_config`;其他工具会接收到这个字段但不会实际用。MCP 的专题会在后续版本展开。
---
diff --git a/packages/core/agents/mcp-support.ts b/packages/core/agents/mcp-support.ts
index 5d3d12daec..c1e352f25a 100644
--- a/packages/core/agents/mcp-support.ts
+++ b/packages/core/agents/mcp-support.ts
@@ -2,13 +2,13 @@
// forwards MCP servers to the underlying CLI. The MCP config tab is hidden
// for every other provider so a user can't save a value the runtime will
// silently ignore. Keep this list in sync with the backends in
-// `server/pkg/agent/` that read `ExecOptions.McpConfig`, plus the OpenClaw
-// per-task wrapper preparer in `server/internal/daemon/execenv/` which
-// materialises `mcp.servers` into the synthesised config rather than going
-// through ExecOptions.
+// `server/pkg/agent/` that read `ExecOptions.McpConfig`, plus providers whose
+// per-task preparers in `server/internal/daemon/execenv/` materialise MCP
+// config for CLIs that do not receive it through ExecOptions.
const MCP_SUPPORTED_PROVIDERS = new Set([
"claude",
"codex",
+ "cursor",
"hermes",
"kimi",
"kiro",
diff --git a/packages/views/agents/components/agent-overview-pane.test.tsx b/packages/views/agents/components/agent-overview-pane.test.tsx
index 86d46ea81a..509a4bb2d5 100644
--- a/packages/views/agents/components/agent-overview-pane.test.tsx
+++ b/packages/views/agents/components/agent-overview-pane.test.tsx
@@ -125,6 +125,7 @@ describe("AgentOverviewPane MCP tab visibility", () => {
it.each([
["Claude", "claude"],
["Codex", "codex"],
+ ["Cursor", "cursor"],
["Hermes", "hermes"],
["Kimi", "kimi"],
["Kiro", "kiro"],
diff --git a/server/internal/daemon/daemon.go b/server/internal/daemon/daemon.go
index 3c29ed7b2d..771bc60f32 100644
--- a/server/internal/daemon/daemon.go
+++ b/server/internal/daemon/daemon.go
@@ -2871,6 +2871,13 @@ func (d *Daemon) runTask(ctx context.Context, task Task, provider string, slot i
if env.CodexHome != "" {
agentEnv["CODEX_HOME"] = env.CodexHome
}
+ // Point Cursor at per-task project state when managed MCP is present.
+ // The workdir .cursor/mcp.json carries the managed server list, while
+ // CURSOR_DATA_DIR isolates the matching project approvals from the user's
+ // persistent ~/.cursor/projects state.
+ if env.CursorDataDir != "" {
+ agentEnv["CURSOR_DATA_DIR"] = env.CursorDataDir
+ }
// Point OpenClaw at the per-task synthesized config. The config pins
// agents.defaults.workspace (and any agents.list[].workspace) to the
// task workdir, so the CLI's native skill scanner picks up the per-task
@@ -3761,7 +3768,7 @@ func isBlockedEnvKey(key string) bool {
return true
}
switch upper {
- case "HOME", "PATH", "USER", "SHELL", "TERM", "CODEX_HOME", "OPENCLAW_CONFIG_PATH", "OPENCLAW_INCLUDE_ROOTS":
+ case "HOME", "PATH", "USER", "SHELL", "TERM", "CODEX_HOME", "CURSOR_DATA_DIR", "OPENCLAW_CONFIG_PATH", "OPENCLAW_INCLUDE_ROOTS":
return true
}
return false
diff --git a/server/internal/daemon/daemon_test.go b/server/internal/daemon/daemon_test.go
index fa748e5f9c..f8d53e6286 100644
--- a/server/internal/daemon/daemon_test.go
+++ b/server/internal/daemon/daemon_test.go
@@ -81,6 +81,36 @@ func TestTriggerRestart_BrewLinuxCellarDeleted(t *testing.T) {
}
}
+func TestIsBlockedEnvKey(t *testing.T) {
+ t.Parallel()
+
+ tests := []struct {
+ key string
+ want bool
+ }{
+ {key: "MULTICA_TOKEN", want: true},
+ {key: "multica_runtime_id", want: true},
+ {key: "HOME", want: true},
+ {key: "PATH", want: true},
+ {key: "CODEX_HOME", want: true},
+ {key: "CURSOR_DATA_DIR", want: true},
+ {key: "cursor_data_dir", want: true},
+ {key: "OPENCLAW_CONFIG_PATH", want: true},
+ {key: "OPENCLAW_INCLUDE_ROOTS", want: true},
+ {key: "ANTHROPIC_API_KEY", want: false},
+ {key: "CURSOR_AGENT", want: false},
+ }
+
+ for _, tt := range tests {
+ t.Run(tt.key, func(t *testing.T) {
+ t.Parallel()
+ if got := isBlockedEnvKey(tt.key); got != tt.want {
+ t.Fatalf("isBlockedEnvKey(%q) = %v, want %v", tt.key, got, tt.want)
+ }
+ })
+ }
+}
+
// When `brew --prefix` is unavailable but the executable path is under a
// known Cellar root, triggerRestart must recover the prefix from the
// known-prefix list and target <prefix>/bin/multica.
diff --git a/server/internal/daemon/execenv/cursor_mcp.go b/server/internal/daemon/execenv/cursor_mcp.go
new file mode 100644
index 0000000000..d6b581b15c
--- /dev/null
+++ b/server/internal/daemon/execenv/cursor_mcp.go
@@ -0,0 +1,196 @@
+package execenv
+
+import (
+ "bytes"
+ "crypto/sha256"
+ "encoding/hex"
+ "encoding/json"
+ "errors"
+ "fmt"
+ "os"
+ "path/filepath"
+ "sort"
+ "strings"
+)
+
+const cursorWorkspaceTrustedFile = ".workspace-trusted"
+
+type cursorMcpConfigFile struct {
+ McpServers map[string]json.RawMessage `json:"mcpServers"`
+}
+
+// prepareCursorMcpConfig writes the Cursor-native MCP sidecars for agents that
+// have an explicit managed mcp_config saved. A nil/null mcp_config means "let
+// Cursor behave normally", so no .cursor/mcp.json or CURSOR_DATA_DIR is created.
+func prepareCursorMcpConfig(envRoot, workDir string, mcpConfig json.RawMessage, manifest *sidecarManifest) (string, error) {
+ if !hasManagedCursorMcpConfig(mcpConfig) {
+ return "", nil
+ }
+ if envRoot == "" {
+ return "", fmt.Errorf("env root is required for managed cursor mcp_config")
+ }
+
+ projectRoot := cursorProjectRoot(workDir)
+ servers, err := parseCursorManagedMcpServers(mcpConfig)
+ if err != nil {
+ return "", err
+ }
+
+ cursorDir := filepath.Join(projectRoot, ".cursor")
+ if err := recordMkdirAll(cursorDir, 0o755, manifest); err != nil {
+ return "", fmt.Errorf("create .cursor dir: %w", err)
+ }
+ configData, err := marshalCursorMcpConfig(servers)
+ if err != nil {
+ return "", err
+ }
+ if err := recordWriteFile(filepath.Join(cursorDir, "mcp.json"), configData, 0o600, manifest); err != nil {
+ if errors.Is(err, errPathPreExists) {
+ return "", fmt.Errorf("managed cursor mcp_config would overwrite existing .cursor/mcp.json")
+ }
+ return "", fmt.Errorf("write .cursor/mcp.json: %w", err)
+ }
+
+ cursorDataDir := filepath.Join(envRoot, "cursor-data")
+ projectDataDir := filepath.Join(cursorDataDir, "projects", cursorSlugifyPath(projectRoot))
+ if err := os.MkdirAll(projectDataDir, 0o700); err != nil {
+ return "", fmt.Errorf("create cursor project data dir: %w", err)
+ }
+ approvals, err := cursorMcpApprovalKeys(projectRoot, servers)
+ if err != nil {
+ return "", err
+ }
+ approvalData, err := json.MarshalIndent(approvals, "", " ")
+ if err != nil {
+ return "", fmt.Errorf("marshal cursor mcp approvals: %w", err)
+ }
+ if err := os.WriteFile(filepath.Join(projectDataDir, "mcp-approvals.json"), approvalData, 0o600); err != nil {
+ return "", fmt.Errorf("write cursor mcp approvals: %w", err)
+ }
+ trustData, err := json.MarshalIndent(map[string]string{
+ "trustedAt": "1970-01-01T00:00:00Z",
+ "workspacePath": projectRoot,
+ "trustMethod": "multica-managed",
+ }, "", " ")
+ if err != nil {
+ return "", fmt.Errorf("marshal cursor workspace trust: %w", err)
+ }
+ if err := os.WriteFile(filepath.Join(projectDataDir, cursorWorkspaceTrustedFile), trustData, 0o600); err != nil {
+ return "", fmt.Errorf("write cursor workspace trust: %w", err)
+ }
+
+ return cursorDataDir, nil
+}
+
+func hasManagedCursorMcpConfig(raw json.RawMessage) bool {
+ trimmed := bytes.TrimSpace(raw)
+ return len(trimmed) > 0 && !bytes.Equal(trimmed, []byte("null"))
+}
+
+func parseCursorManagedMcpServers(raw json.RawMessage) (map[string]json.RawMessage, error) {
+ var cfg struct {
+ McpServers map[string]json.RawMessage `json:"mcpServers"`
+ }
+ if err := json.Unmarshal(raw, &cfg); err != nil {
+ return nil, fmt.Errorf("parse mcp_config json: %w", err)
+ }
+ if cfg.McpServers == nil {
+ return map[string]json.RawMessage{}, nil
+ }
+ for name, server := range cfg.McpServers {
+ if strings.TrimSpace(name) == "" {
+ return nil, fmt.Errorf("mcp server name must not be empty")
+ }
+ var obj map[string]any
+ if err := json.Unmarshal(server, &obj); err != nil {
+ return nil, fmt.Errorf("mcp_servers.%s: %w", name, err)
+ }
+ if obj == nil {
+ return nil, fmt.Errorf("mcp_servers.%s must be a JSON object", name)
+ }
+ }
+ return cfg.McpServers, nil
+}
+
+func marshalCursorMcpConfig(servers map[string]json.RawMessage) ([]byte, error) {
+ if servers == nil {
+ servers = map[string]json.RawMessage{}
+ }
+ data, err := json.MarshalIndent(cursorMcpConfigFile{McpServers: servers}, "", " ")
+ if err != nil {
+ return nil, fmt.Errorf("marshal cursor mcp config: %w", err)
+ }
+ return append(data, '\n'), nil
+}
+
+func cursorMcpApprovalKeys(projectRoot string, servers map[string]json.RawMessage) ([]string, error) {
+ names := make([]string, 0, len(servers))
+ for name := range servers {
+ names = append(names, name)
+ }
+ sort.Strings(names)
+
+ approvals := make([]string, 0, len(names))
+ for _, name := range names {
+ compact := &bytes.Buffer{}
+ if err := json.Compact(compact, servers[name]); err != nil {
+ return nil, fmt.Errorf("compact mcp_servers.%s: %w", name, err)
+ }
+ pathJSON, err := json.Marshal(projectRoot)
+ if err != nil {
+ return nil, fmt.Errorf("marshal cursor project root: %w", err)
+ }
+ payload := []byte(`{"path":`)
+ payload = append(payload, pathJSON...)
+ payload = append(payload, []byte(`,"server":`)...)
+ payload = append(payload, compact.Bytes()...)
+ payload = append(payload, '}')
+
+ sum := sha256.Sum256(payload)
+ approvals = append(approvals, name+"-"+hex.EncodeToString(sum[:])[:16])
+ }
+ return approvals, nil
+}
+
+func cursorProjectRoot(workDir string) string {
+ if workDir == "" {
+ return workDir
+ }
+ dir, err := filepath.EvalSymlinks(workDir)
+ if err != nil {
+ dir = workDir
+ }
+ dir, err = filepath.Abs(dir)
+ if err != nil {
+ dir = workDir
+ }
+ fallback := dir
+ for {
+ if _, err := os.Stat(filepath.Join(dir, ".git")); err == nil {
+ return dir
+ }
+ parent := filepath.Dir(dir)
+ if parent == dir {
+ return fallback
+ }
+ dir = parent
+ }
+}
+
+func cursorSlugifyPath(path string) string {
+ var b strings.Builder
+ lastDash := false
+ for _, r := range path {
+ isAlphaNum := (r >= 'a' && r <= 'z') || (r >= 'A' && r <= 'Z') || (r >= '0' && r <= '9')
+ if isAlphaNum {
+ b.WriteRune(r)
+ lastDash = false
+ continue
+ }
+ if !lastDash {
+ b.WriteByte('-')
+ lastDash = true
+ }
+ }
+ return strings.Trim(b.String(), "-")
+}
diff --git a/server/internal/daemon/execenv/cursor_mcp_test.go b/server/internal/daemon/execenv/cursor_mcp_test.go
new file mode 100644
index 0000000000..ad48774de3
--- /dev/null
+++ b/server/internal/daemon/execenv/cursor_mcp_test.go
@@ -0,0 +1,163 @@
+package execenv
+
+import (
+ "encoding/json"
+ "os"
+ "path/filepath"
+ "reflect"
+ "testing"
+)
+
+func TestCursorMcpApprovalKeyMatchesCursorAgent(t *testing.T) {
+ t.Parallel()
+
+ keys, err := cursorMcpApprovalKeys("/tmp/work", map[string]json.RawMessage{
+ "fetch": json.RawMessage(`{"command":"uvx","args":["mcp-server-fetch"]}`),
+ })
+ if err != nil {
+ t.Fatalf("cursorMcpApprovalKeys: %v", err)
+ }
+ want := []string{"fetch-b3a6127d3cbd8e52"}
+ if !reflect.DeepEqual(keys, want) {
+ t.Fatalf("approval keys = %v, want %v", keys, want)
+ }
+}
+
+func TestPrepareCursorMcpConfigWritesProjectConfigAndApprovals(t *testing.T) {
+ t.Parallel()
+
+ envRoot := t.TempDir()
+ workDir := filepath.Join(envRoot, "workdir")
+ if err := os.MkdirAll(workDir, 0o755); err != nil {
+ t.Fatalf("mkdir workDir: %v", err)
+ }
+ manifest := &sidecarManifest{}
+ mcpConfig := json.RawMessage(`{
+ "mcpServers": {
+ "fetch": {"command":"uvx","args":["mcp-server-fetch"]},
+ "http": {"url":"https://mcp.example.com","type":"http"}
+ }
+ }`)
+
+ cursorDataDir, err := prepareCursorMcpConfig(envRoot, workDir, mcpConfig, manifest)
+ if err != nil {
+ t.Fatalf("prepareCursorMcpConfig: %v", err)
+ }
+ if cursorDataDir != filepath.Join(envRoot, "cursor-data") {
+ t.Fatalf("CursorDataDir = %q, want envRoot/cursor-data", cursorDataDir)
+ }
+
+ rawConfig, err := os.ReadFile(filepath.Join(workDir, ".cursor", "mcp.json"))
+ if err != nil {
+ t.Fatalf("read .cursor/mcp.json: %v", err)
+ }
+ var cfg cursorMcpConfigFile
+ if err := json.Unmarshal(rawConfig, &cfg); err != nil {
+ t.Fatalf("unmarshal .cursor/mcp.json: %v\n%s", err, rawConfig)
+ }
+ if len(cfg.McpServers) != 2 {
+ t.Fatalf("mcpServers length = %d, want 2: %s", len(cfg.McpServers), rawConfig)
+ }
+ if mode := filePerm(t, filepath.Join(workDir, ".cursor", "mcp.json")); mode != 0o600 {
+ t.Fatalf(".cursor/mcp.json mode = %#o, want 0600", mode)
+ }
+
+ projectRoot := cursorProjectRoot(workDir)
+ projectDataDir := filepath.Join(cursorDataDir, "projects", cursorSlugifyPath(projectRoot))
+ rawApprovals, err := os.ReadFile(filepath.Join(projectDataDir, "mcp-approvals.json"))
+ if err != nil {
+ t.Fatalf("read mcp-approvals.json: %v", err)
+ }
+ var approvals []string
+ if err := json.Unmarshal(rawApprovals, &approvals); err != nil {
+ t.Fatalf("unmarshal mcp-approvals.json: %v\n%s", err, rawApprovals)
+ }
+ wantApprovals, err := cursorMcpApprovalKeys(projectRoot, cfg.McpServers)
+ if err != nil {
+ t.Fatalf("expected approvals: %v", err)
+ }
+ if !reflect.DeepEqual(approvals, wantApprovals) {
+ t.Fatalf("approvals = %v, want %v", approvals, wantApprovals)
+ }
+ if mode := filePerm(t, filepath.Join(projectDataDir, "mcp-approvals.json")); mode != 0o600 {
+ t.Fatalf("mcp-approvals.json mode = %#o, want 0600", mode)
+ }
+ if _, err := os.Stat(filepath.Join(projectDataDir, cursorWorkspaceTrustedFile)); err != nil {
+ t.Fatalf("workspace trust file missing: %v", err)
+ }
+ if len(manifest.Files) == 0 {
+ t.Fatal("manifest did not record .cursor/mcp.json")
+ }
+}
+
+func TestPrepareCursorMcpConfigManagedEmptySet(t *testing.T) {
+ t.Parallel()
+
+ envRoot := t.TempDir()
+ workDir := filepath.Join(envRoot, "workdir")
+ if err := os.MkdirAll(workDir, 0o755); err != nil {
+ t.Fatalf("mkdir workDir: %v", err)
+ }
+ cursorDataDir, err := prepareCursorMcpConfig(envRoot, workDir, json.RawMessage(`{"mcpServers":{}}`), &sidecarManifest{})
+ if err != nil {
+ t.Fatalf("prepareCursorMcpConfig: %v", err)
+ }
+ if cursorDataDir == "" {
+ t.Fatal("managed empty mcp_config should still isolate CursorDataDir")
+ }
+ projectRoot := cursorProjectRoot(workDir)
+ rawApprovals, err := os.ReadFile(filepath.Join(cursorDataDir, "projects", cursorSlugifyPath(projectRoot), "mcp-approvals.json"))
+ if err != nil {
+ t.Fatalf("read mcp-approvals.json: %v", err)
+ }
+ var approvals []string
+ if err := json.Unmarshal(rawApprovals, &approvals); err != nil {
+ t.Fatalf("unmarshal approvals: %v", err)
+ }
+ if len(approvals) != 0 {
+ t.Fatalf("approvals length = %d, want 0: %v", len(approvals), approvals)
+ }
+}
+
+func TestPrepareCursorMcpConfigNilDoesNotTakeOwnership(t *testing.T) {
+ t.Parallel()
+
+ envRoot := t.TempDir()
+ workDir := filepath.Join(envRoot, "workdir")
+ if err := os.MkdirAll(workDir, 0o755); err != nil {
+ t.Fatalf("mkdir workDir: %v", err)
+ }
+ cursorDataDir, err := prepareCursorMcpConfig(envRoot, workDir, nil, &sidecarManifest{})
+ if err != nil {
+ t.Fatalf("prepareCursorMcpConfig: %v", err)
+ }
+ if cursorDataDir != "" {
+ t.Fatalf("CursorDataDir = %q, want empty", cursorDataDir)
+ }
+ if _, err := os.Stat(filepath.Join(workDir, ".cursor", "mcp.json")); !os.IsNotExist(err) {
+ t.Fatalf(".cursor/mcp.json should not exist, stat err=%v", err)
+ }
+}
+
+func TestPrepareCursorMcpConfigRejectsMalformedConfig(t *testing.T) {
+ t.Parallel()
+
+ envRoot := t.TempDir()
+ workDir := filepath.Join(envRoot, "workdir")
+ if err := os.MkdirAll(workDir, 0o755); err != nil {
+ t.Fatalf("mkdir workDir: %v", err)
+ }
+ _, err := prepareCursorMcpConfig(envRoot, workDir, json.RawMessage(`{"mcpServers":{"bad":42}}`), &sidecarManifest{})
+ if err == nil {
+ t.Fatal("expected malformed server config to fail")
+ }
+}
+
+func filePerm(t *testing.T, path string) os.FileMode {
+ t.Helper()
+ info, err := os.Stat(path)
+ if err != nil {
+ t.Fatalf("stat %s: %v", path, err)
+ }
+ return info.Mode().Perm()
+}
diff --git a/server/internal/daemon/execenv/execenv.go b/server/internal/daemon/execenv/execenv.go
index ef7137e60a..d7d280e6b8 100644
--- a/server/internal/daemon/execenv/execenv.go
+++ b/server/internal/daemon/execenv/execenv.go
@@ -41,7 +41,7 @@ type PrepareParams struct {
OpenclawBin string // resolved openclaw CLI path (only used when Provider == "openclaw"); empty = look up on PATH
// McpConfig is the agent's saved `mcp_config` JSON, forwarded to the
// provider-specific config preparer when that provider materialises MCP
- // via a per-task config file. Only OpenClaw consumes it here today; other
+ // via a per-task config file. Cursor and OpenClaw consume it here; other
// providers wire MCP via ExecOptions.McpConfig in the agent backend.
McpConfig json.RawMessage
// LocalWorkDir, when non-empty, redirects the agent's working directory
@@ -147,6 +147,11 @@ type Environment struct {
// directory holding the wrapper file. Empty when no $include is
// emitted (fresh install).
OpenclawIncludeRoot string
+ // CursorDataDir is the per-task Cursor data directory (set only for
+ // cursor provider when the agent has managed mcp_config). The daemon
+ // exports this as CURSOR_DATA_DIR so project-level MCP approvals are
+ // isolated from the user's persistent ~/.cursor/projects state.
+ CursorDataDir string
logger *slog.Logger // for cleanup logging
}
@@ -219,9 +224,6 @@ func Prepare(params PrepareParams, logger *slog.Logger) (*Environment, error) {
if err := writeContextFiles(workDir, params.Provider, params.Task, manifest); err != nil {
return nil, fmt.Errorf("execenv: write context files: %w", err)
}
- if err := writeSidecarManifest(envRoot, manifest); err != nil {
- logger.Warn("execenv: write sidecar manifest failed (non-fatal)", "error", err)
- }
// For Codex, set up a per-task CODEX_HOME seeded from ~/.codex/ with skills.
if params.Provider == "codex" {
@@ -235,6 +237,23 @@ func Prepare(params PrepareParams, logger *slog.Logger) (*Environment, error) {
env.CodexHome = codexHome
}
+ // For Cursor, materialize managed MCP into project-local config and use
+ // an isolated CURSOR_DATA_DIR for the per-workdir approval sidecar. Cursor
+ // still reads ~/.cursor/mcp.json, but only servers with approval entries in
+ // this per-task data dir can load, so user-global MCP servers do not leak
+ // into managed-MCP runs.
+ if params.Provider == "cursor" {
+ cursorDataDir, err := prepareCursorMcpConfig(envRoot, workDir, params.McpConfig, manifest)
+ if err != nil {
+ return nil, fmt.Errorf("execenv: prepare cursor mcp config: %w", err)
+ }
+ env.CursorDataDir = cursorDataDir
+ }
+
+ if err := writeSidecarManifest(envRoot, manifest); err != nil {
+ logger.Warn("execenv: write sidecar manifest failed (non-fatal)", "error", err)
+ }
+
// For OpenClaw, synthesize a per-task config that pins workspace to
// workDir. The skill scanner then reads {workDir}/skills/ (written by
// writeContextFiles above). Fail closed on errors: a malformed user
@@ -354,11 +373,6 @@ func Reuse(params ReuseParams, logger *slog.Logger) *Environment {
if err := writeContextFiles(params.WorkDir, params.Provider, params.Task, manifest); err != nil {
logger.Warn("execenv: refresh context files failed", "error", err)
}
- if env.RootDir != "" {
- if err := writeSidecarManifest(env.RootDir, manifest); err != nil {
- logger.Warn("execenv: refresh sidecar manifest failed", "error", err)
- }
- }
// Restore CodexHome for Codex provider — the per-task codex-home directory
// lives alongside the workdir. Re-run prepareCodexHomeWithOpts to ensure
@@ -375,6 +389,24 @@ func Reuse(params ReuseParams, logger *slog.Logger) *Environment {
}
}
+ // Refresh Cursor's managed MCP sidecars on reuse. A newly saved agent
+ // mcp_config must replace the prior run's .cursor/mcp.json and isolated
+ // approvals before the next cursor-agent process starts.
+ if params.Provider == "cursor" && env.RootDir != "" {
+ cursorDataDir, err := prepareCursorMcpConfig(env.RootDir, params.WorkDir, params.McpConfig, manifest)
+ if err != nil {
+ logger.Warn("execenv: refresh cursor mcp config failed", "error", err)
+ return nil
+ }
+ env.CursorDataDir = cursorDataDir
+ }
+
+ if env.RootDir != "" {
+ if err := writeSidecarManifest(env.RootDir, manifest); err != nil {
+ logger.Warn("execenv: refresh sidecar manifest failed", "error", err)
+ }
+ }
+
// Refresh the per-task OpenClaw config on reuse — the user may have
// added/removed agents or rotated providers since the prior task ran,
// and the workspace override always re-targets the current workDir.