Skip to content

AI-native knowledge base & Evernote/Obsidian alternative with instant sync & native MCP. Free on Cloudflare or self-hosted via Docker.

feat(desktop): grant ACP agents session-scoped note access

tianma-ifd2513bf90948
diff --git a/apps/desktop/electron-builder.yml b/apps/desktop/electron-builder.yml
index 94f6e3a5..9a8ecf7b 100644
--- a/apps/desktop/electron-builder.yml
+++ b/apps/desktop/electron-builder.yml
@@ -27,6 +27,11 @@ files:
- src/**
- package.json
extraResources:
+ - from: ../../scripts
+ to: mcp-bridge
+ filter:
+ - edgeever-mcp-stdio.mjs
+ - mcp-http-headers.mjs
- from: ../web/dist
to: web
filter:
diff --git a/apps/desktop/src/main/acp-host.mjs b/apps/desktop/src/main/acp-host.mjs
index 92490cd3..5f089be6 100644
--- a/apps/desktop/src/main/acp-host.mjs
+++ b/apps/desktop/src/main/acp-host.mjs
@@ -5,9 +5,11 @@ import { mkdtemp, rm } from "node:fs/promises";
import { homedir, tmpdir } from "node:os";
import path from "node:path";
import { Readable, Writable } from "node:stream";
+import { fileURLToPath } from "node:url";
import { ClientSideConnection, ndJsonStream, PROTOCOL_VERSION, RequestError } from "@agentclientprotocol/sdk";
import { waitForChildProcessSpawn } from "./child-process-start.mjs";
import { createAcpAdapterManager } from "./acp-adapter-manager.mjs";
+import { startAcpMcpBridge } from "./acp-mcp-bridge.mjs";
const ADAPTERS = {
codex: { id: "codex", label: "Codex" },
@@ -659,6 +661,17 @@ export function createAcpHostRuntime(options = {}) {
const updateFailures = new Map();
const installingIds = new Set();
const latestStatus = new Map();
+ const mcpScriptPath = options.mcpScriptPath ?? fileURLToPath(new URL("../../../../scripts/edgeever-mcp-stdio.mjs", import.meta.url));
+ const mcpServerFor = (bridge) => ({
+ name: "edgeever-current-workspace",
+ command: options.mcpExecutablePath ?? process.execPath,
+ args: [mcpScriptPath],
+ env: [
+ { name: "ELECTRON_RUN_AS_NODE", value: "1" },
+ { name: "EDGEEVER_URL", value: bridge.url },
+ { name: "EDGEEVER_TOKEN", value: bridge.secret },
+ ],
+ });
const resolveCommand = (input) => {
if (input?.id === "antigravity" && typeof input.path === "string" && input.path.trim()) return resolveAcpCommand(input, commandDeps);
@@ -668,7 +681,7 @@ export function createAcpHostRuntime(options = {}) {
return resolveAcpCommand(input, commandDeps);
};
- const connect = async (command, requestId, emit, signal, authMethodId) => {
+ const connect = async (command, requestId, emit, signal, authMethodId, mcpServers = []) => {
const cwd = await createAcpWorkspace(mkdtempImpl, options.tmpRoot);
let child = null;
let authMethods = [];
@@ -687,7 +700,7 @@ export function createAcpHostRuntime(options = {}) {
if (!authMethods.some((method) => method.id === authMethodId)) throw new Error("invalid_auth_method");
await connection.authenticate({ methodId: authMethodId });
}
- const session = await connection.newSession({ cwd, mcpServers: [] });
+ const session = await connection.newSession({ cwd, mcpServers });
if (signal?.aborted) throw Object.assign(new Error("connection_timeout"), { code: "TIMEOUT" });
return {
cwd,
@@ -855,9 +868,18 @@ export function createAcpHostRuntime(options = {}) {
if (!resolved.ok) return fail(promptFailureMessage(resolved));
let connected;
+ let mcpBridge;
try {
- connected = await withHandshakeTimeout((signal) => connect(resolved.command, requestId, notify, signal));
+ if (options.mcpAccess) {
+ const access = await options.mcpAccess();
+ mcpBridge = await (options.startMcpBridge ?? startAcpMcpBridge)(access);
+ }
+ connected = await withHandshakeTimeout((signal) => connect(
+ resolved.command, requestId, notify, signal, undefined,
+ mcpBridge ? [mcpServerFor(mcpBridge)] : [],
+ ));
} catch (error) {
+ await mcpBridge?.close();
return fail(promptFailureMessage(classifyAcpFailure(error)));
}
@@ -869,9 +891,16 @@ export function createAcpHostRuntime(options = {}) {
attachments: input.attachments,
promptCapabilities: connected.promptCapabilities,
});
+ if (mcpBridge) {
+ content.blocks.unshift({
+ type: "text",
+ text: "For EdgeEver note operations in this conversation, use only the session-provided MCP server named edgeever-current-workspace. It is connected to the account currently signed in to EdgeEver. Ignore any EdgeEver MCP server from your persistent configuration, which may target a different instance or account.",
+ });
+ }
} catch (error) {
connected.stop();
await removeAcpWorkspace(connected.cwd, rmImpl);
+ await mcpBridge?.close();
return fail(promptFailureMessage(classifyAcpFailure(error)));
}
@@ -879,6 +908,7 @@ export function createAcpHostRuntime(options = {}) {
cancelled: false,
settled: false,
...connected,
+ mcpBridge,
};
active.set(requestId, session);
const finish = (event) => {
@@ -888,6 +918,7 @@ export function createAcpHostRuntime(options = {}) {
session.stop();
active.delete(requestId);
void removeAcpWorkspace(session.cwd, rmImpl);
+ void session.mcpBridge?.close();
};
void connected.connection.prompt({ sessionId: connected.sessionId, prompt: content.blocks }).then(() => {
finish({ requestId, type: "done" });
@@ -908,6 +939,7 @@ export function createAcpHostRuntime(options = {}) {
// The process may already be gone. Killing it is enough.
}
session.stop();
+ void session.mcpBridge?.close();
return { ok: true };
},
};
@@ -919,7 +951,7 @@ const failureFields = (failure) => (
: { state: failure.state }
);
-export function registerAcpIpc(ipcMain, runtime = createAcpHostRuntime(), { allowInstall = () => false } = {}) {
+export function registerAcpIpc(ipcMain, runtime = createAcpHostRuntime(), { allowInstall = () => false, allowPrompt = allowInstall } = {}) {
const send = (sender, event) => {
if (!sender || sender.isDestroyed?.()) return;
sender.send("desktop:acp-event", event);
@@ -934,7 +966,13 @@ export function registerAcpIpc(ipcMain, runtime = createAcpHostRuntime(), { allo
if (!allowInstall(event.sender)) throw new Error("adapter_auth_forbidden");
return runtime.authenticateAdapter(input);
});
- ipcMain.handle("desktop:acp-prompt", (event, input) => runtime.prompt(input, (acpEvent) => send(event.sender, acpEvent)));
- ipcMain.handle("desktop:acp-cancel", (_event, requestId) => runtime.cancel(requestId));
+ ipcMain.handle("desktop:acp-prompt", (event, input) => {
+ if (!allowPrompt(event.sender)) throw new Error("acp_prompt_forbidden");
+ return runtime.prompt(input, (acpEvent) => send(event.sender, acpEvent));
+ });
+ ipcMain.handle("desktop:acp-cancel", (event, requestId) => {
+ if (!allowPrompt(event.sender)) throw new Error("acp_cancel_forbidden");
+ return runtime.cancel(requestId);
+ });
return runtime;
}
diff --git a/apps/desktop/src/main/acp-host.test.mjs b/apps/desktop/src/main/acp-host.test.mjs
index d8056cb6..350a401a 100644
--- a/apps/desktop/src/main/acp-host.test.mjs
+++ b/apps/desktop/src/main/acp-host.test.mjs
@@ -589,6 +589,40 @@ describe("ACP stdio session", () => {
}
}, 15_000);
+ sessionTest("provides the signed-in workspace MCP server only during an ACP prompt", async () => {
+ const directory = await mkdtemp(path.join(tmpdir(), "edgeever-acp-mcp-"));
+ const reportPath = path.join(directory, "report.json");
+ let closed = false;
+ try {
+ const scriptPath = await writeFakeAgent(directory, {
+ reportPath,
+ secretPath: path.join(directory, "secret.txt"),
+ allowImage: false,
+ allowEmbedded: false,
+ hold: false,
+ });
+ const runtime = createAcpHostRuntime({
+ mcpAccess: () => ({ baseUrl: "https://notes.example", sessionToken: "login-secret" }),
+ startMcpBridge: () => ({
+ url: "http://127.0.0.1:12345",
+ secret: "temporary-secret",
+ close: async () => { closed = true; },
+ }),
+ });
+ const events = collector();
+ await runtime.prompt({ adapterId: "antigravity", path: scriptPath, prompt: "List my notes" }, events.emit);
+ await events.waitFor((event) => event.type === "done");
+ const servers = (await readReport(reportPath)).newSession.mcpServers;
+ expect(servers).toHaveLength(1);
+ expect(servers[0].name).toBe("edgeever-current-workspace");
+ expect(servers[0].env).toContainEqual({ name: "EDGEEVER_TOKEN", value: "temporary-secret" });
+ expect(JSON.stringify(servers)).not.toContain("login-secret");
+ expect(closed).toBe(true);
+ } finally {
+ await rm(directory, { recursive: true, force: true });
+ }
+ }, 15_000);
+
sessionTest("offers advertised agent login and verifies a session after authentication", async () => {
const directory = await mkdtemp(path.join(tmpdir(), "edgeever-acp-auth-"));
const reportPath = path.join(directory, "report.json");
@@ -742,4 +776,5 @@ test("desktop preload and main process expose the ACP host", async () => {
const handlers = new Map();
registerAcpIpc({ handle: (channel, handler) => handlers.set(channel, handler) });
expect([...handlers.keys()]).toEqual(["desktop:acp-list", "desktop:acp-probe", "desktop:acp-install", "desktop:acp-authenticate", "desktop:acp-prompt", "desktop:acp-cancel"]);
+ expect(() => handlers.get("desktop:acp-prompt")({ sender: {} }, { prompt: "test" })).toThrow("acp_prompt_forbidden");
});
diff --git a/apps/desktop/src/main/acp-mcp-bridge.mjs b/apps/desktop/src/main/acp-mcp-bridge.mjs
new file mode 100644
index 00000000..b58be01d
--- /dev/null
+++ b/apps/desktop/src/main/acp-mcp-bridge.mjs
@@ -0,0 +1,106 @@
+import { randomBytes, timingSafeEqual } from "node:crypto";
+import { once } from "node:events";
+import { createServer } from "node:http";
+
+const MAX_REQUEST_BYTES = 32 * 1024 * 1024;
+const FORWARDED_HEADERS = ["mcp-protocol-version", "mcp-method", "mcp-name"];
+
+const sameSecret = (received, expected) => {
+ if (typeof received !== "string") return false;
+ const left = Buffer.from(received);
+ const right = Buffer.from(expected);
+ return left.length === right.length && timingSafeEqual(left, right);
+};
+
+const readBody = async (request) => {
+ const chunks = [];
+ let size = 0;
+ for await (const chunk of request) {
+ size += chunk.length;
+ if (size > MAX_REQUEST_BYTES) throw new Error("request_too_large");
+ chunks.push(chunk);
+ }
+ return Buffer.concat(chunks);
+};
+
+export async function startAcpMcpBridge({ baseUrl, sessionToken, accountId, isCurrent, fetchImpl = fetch } = {}) {
+ if (typeof baseUrl !== "string" || !/^https?:\/\//.test(baseUrl) || !sessionToken) {
+ throw new Error("note_access_unavailable");
+ }
+ let instance;
+ try { instance = new URL(baseUrl); }
+ catch { throw new Error("note_access_unavailable"); }
+ if (instance.username || instance.password || instance.search || instance.hash) throw new Error("note_access_unavailable");
+ const origin = instance.href.replace(/\/+$/, "");
+ let session;
+ try {
+ session = await fetchImpl(`${origin}/api/v1/auth/session`, {
+ headers: { Authorization: `Bearer ${sessionToken}` },
+ redirect: "manual",
+ signal: AbortSignal.timeout(10_000),
+ });
+ } catch { throw new Error("note_access_unavailable"); }
+ const identity = await session.json().catch(() => null);
+ if (!session.ok || identity?.authenticated !== true || (accountId && identity?.user?.id !== accountId)) {
+ throw new Error("note_access_unavailable");
+ }
+
+ const secret = randomBytes(32).toString("hex");
+ const server = createServer(async (request, response) => {
+ response.setHeader("Cache-Control", "no-store");
+ if (request.method !== "POST" || request.url !== "/mcp") {
+ response.writeHead(404).end();
+ return;
+ }
+ if (!isCurrent?.() || !sameSecret(request.headers.authorization, `Bearer ${secret}`)) {
+ response.writeHead(401).end();
+ return;
+ }
+ if (!String(request.headers["content-type"] ?? "").toLowerCase().startsWith("application/json")) {
+ response.writeHead(415).end();
+ return;
+ }
+ try {
+ const body = await readBody(request);
+ const headers = {
+ Authorization: `Bearer ${sessionToken}`,
+ Accept: "application/json, text/event-stream",
+ "Content-Type": "application/json",
+ };
+ for (const name of FORWARDED_HEADERS) {
+ if (typeof request.headers[name] === "string") headers[name] = request.headers[name];
+ }
+ if (!isCurrent()) throw new Error("note_access_unavailable");
+ const upstream = await fetchImpl(`${origin}/mcp`, { method: "POST", headers, body, redirect: "manual" });
+ if (upstream.status >= 300 && upstream.status < 400) throw new Error("unexpected_redirect");
+ response.writeHead(upstream.status, { "Content-Type": upstream.headers.get("content-type") ?? "application/json" });
+ if (upstream.body) {
+ for await (const chunk of upstream.body) {
+ if (!response.write(chunk)) await once(response, "drain");
+ }
+ }
+ response.end();
+ } catch (error) {
+ if (response.headersSent) response.destroy();
+ else response.writeHead(error?.message === "request_too_large" ? 413 : 502).end();
+ }
+ });
+ try {
+ await new Promise((resolve, reject) => {
+ server.once("error", reject);
+ server.listen(0, "127.0.0.1", resolve);
+ });
+ } catch (error) {
+ server.close();
+ throw error;
+ }
+ const address = server.address();
+ return {
+ url: `http://127.0.0.1:${address.port}`,
+ secret,
+ close: () => new Promise((resolve) => {
+ server.close(resolve);
+ server.closeAllConnections();
+ }),
+ };
+}
diff --git a/apps/desktop/src/main/acp-mcp-bridge.test.mjs b/apps/desktop/src/main/acp-mcp-bridge.test.mjs
new file mode 100644
index 00000000..9f7e7207
--- /dev/null
+++ b/apps/desktop/src/main/acp-mcp-bridge.test.mjs
@@ -0,0 +1,106 @@
+import { afterEach, expect, test } from "bun:test";
+import { spawn } from "node:child_process";
+import { createServer } from "node:http";
+import { fileURLToPath } from "node:url";
+import { startAcpMcpBridge } from "./acp-mcp-bridge.mjs";
+
+const servers = [];
+afterEach(async () => {
+ await Promise.all(servers.splice(0).map((server) => new Promise((resolve) => server.close(resolve))));
+});
+
+const upstream = async () => {
+ const requests = [];
+ const server = createServer(async (request, response) => {
+ const chunks = [];
+ for await (const chunk of request) chunks.push(chunk);
+ const body = Buffer.concat(chunks).toString("utf8");
+ requests.push({ url: request.url, authorization: request.headers.authorization, body });
+ response.setHeader("Content-Type", "application/json");
+ if (request.url === "/api/v1/auth/session") {
+ response.end(JSON.stringify({
+ authenticated: request.headers.authorization === "Bearer long-lived-session",
+ user: { id: "account-one" },
+ }));
+ return;
+ }
+ response.end(JSON.stringify({ jsonrpc: "2.0", id: 1, result: { tools: [] } }));
+ });
+ await new Promise((resolve) => server.listen(0, "127.0.0.1", resolve));
+ servers.push(server);
+ return { url: `http://127.0.0.1:${server.address().port}`, requests };
+};
+
+test("ACP bridge forwards only authorized MCP requests and never exposes the login token", async () => {
+ const remote = await upstream();
+ let current = true;
+ const bridge = await startAcpMcpBridge({
+ baseUrl: remote.url,
+ sessionToken: "long-lived-session",
+ isCurrent: () => current,
+ });
+ try {
+ expect(bridge.url).not.toContain("long-lived-session");
+ expect(bridge.secret).not.toBe("long-lived-session");
+ const request = (authorization) => fetch(`${bridge.url}/mcp`, {
+ method: "POST",
+ headers: { authorization, "content-type": "application/json" },
+ body: JSON.stringify({ jsonrpc: "2.0", id: 1, method: "tools/list" }),
+ });
+ expect((await request("Bearer wrong")).status).toBe(401);
+ expect(remote.requests).toHaveLength(1);
+ expect((await request(`Bearer ${bridge.secret}`)).status).toBe(200);
+ expect(remote.requests.at(-1)?.authorization).toBe("Bearer long-lived-session");
+ current = false;
+ expect((await request(`Bearer ${bridge.secret}`)).status).toBe(401);
+ expect(remote.requests).toHaveLength(2);
+ } finally {
+ await bridge.close();
+ }
+});
+
+test("ACP bridge refuses an invalid desktop session", async () => {
+ const remote = await upstream();
+ await expect(startAcpMcpBridge({
+ baseUrl: remote.url,
+ sessionToken: "invalid-session",
+ isCurrent: () => true,
+ })).rejects.toThrow("note_access_unavailable");
+ await expect(startAcpMcpBridge({
+ baseUrl: remote.url,
+ sessionToken: "long-lived-session",
+ accountId: "account-two",
+ isCurrent: () => true,
+ })).rejects.toThrow("note_access_unavailable");
+});
+
+test("the packaged MCP stdio adapter reaches the signed-in instance through the ACP bridge", async () => {
+ const remote = await upstream();
+ const bridge = await startAcpMcpBridge({
+ baseUrl: remote.url,
+ sessionToken: "long-lived-session",
+ isCurrent: () => true,
+ });
+ const script = fileURLToPath(new URL("../../../../scripts/edgeever-mcp-stdio.mjs", import.meta.url));
+ const child = spawn(process.execPath, [script], {
+ stdio: ["pipe", "pipe", "pipe"],
+ env: { ...process.env, EDGEEVER_URL: bridge.url, EDGEEVER_TOKEN: bridge.secret },
+ });
+ try {
+ const response = new Promise((resolve, reject) => {
+ const timeout = setTimeout(() => reject(new Error("MCP stdio adapter timed out")), 5000);
+ child.stdout.once("data", (chunk) => {
+ clearTimeout(timeout);
+ try { resolve(JSON.parse(chunk.toString("utf8").trim())); }
+ catch (error) { reject(error); }
+ });
+ child.once("error", reject);
+ });
+ child.stdin.write(`${JSON.stringify({ jsonrpc: "2.0", id: 1, method: "tools/list" })}\n`);
+ expect((await response).result).toEqual({ tools: [] });
+ expect(remote.requests.at(-1)?.authorization).toBe("Bearer long-lived-session");
+ } finally {
+ child.kill();
+ await bridge.close();
+ }
+});
diff --git a/apps/desktop/src/main/index.mjs b/apps/desktop/src/main/index.mjs
index 90a8cb90..bf03f757 100644
--- a/apps/desktop/src/main/index.mjs
+++ b/apps/desktop/src/main/index.mjs
@@ -1596,6 +1596,20 @@ const startApplication = async () => {
});
const acpRuntime = registerAcpIpc(ipcMain, createAcpHostRuntime({
adapterStore: join(app.getPath("userData"), "acp-adapters"),
+ mcpScriptPath: app.isPackaged
+ ? join(process.resourcesPath, "mcp-bridge", "edgeever-mcp-stdio.mjs")
+ : join(projectRoot, "scripts", "edgeever-mcp-stdio.mjs"),
+ mcpAccess: () => {
+ const baseUrl = configuredApiBaseUrl;
+ const sessionToken = desktopSessionToken;
+ const accountId = activeAccountId;
+ return {
+ baseUrl,
+ sessionToken,
+ accountId,
+ isCurrent: () => configuredApiBaseUrl === baseUrl && desktopSessionToken === sessionToken && activeAccountId === accountId,
+ };
+ },
}), { allowInstall: (sender) => sender === mainWindow?.webContents });
await acpRuntime.pruneAdapters().catch(() => {});
const refreshAdapters = () => { void acpRuntime.installDetected().catch(() => []).then(() => acpRuntime.updateInstalled()).catch(() => {}); };
diff --git a/apps/web/src/components/ai-sidebar/AiSidebar.tsx b/apps/web/src/components/ai-sidebar/AiSidebar.tsx
index 87c70153..6ae57b49 100644
--- a/apps/web/src/components/ai-sidebar/AiSidebar.tsx
+++ b/apps/web/src/components/ai-sidebar/AiSidebar.tsx
@@ -980,7 +980,9 @@ function AiSidebarSession({
setLocalTurns((previous) => previous.map((turn) => turn.id === turnId && turn.status === "running"
? { ...turn, status: event.type === "error" ? "failed" : "completed" }
: turn));
- if (event.type === "error" && event.message) setError(event.message);
+ if (event.type === "error" && event.message) {
+ setError(event.message === "note_access_unavailable" ? t("aiAssistant.sidebar.noteAccessUnavailable") : event.message);
+ }
if (active.current?.requestId === event.requestId) {
active.current = null;
locked.current = false;
@@ -1528,8 +1530,9 @@ function AiSidebarSession({
{localAdapterId ? t(`aiAssistant.agentSource.${localAdapterId}`) : t("aiAssistant.sidebar.localStatus")}
</span>
</TooltipTrigger>
- <TooltipContent>
- {localAdapterId ? t(`aiAssistant.agentSource.${localAdapterId}`) : t("aiAssistant.sidebar.localStatus")}
+ <TooltipContent className="max-w-xs">
+ <p>{localAdapterId ? t(`aiAssistant.agentSource.${localAdapterId}`) : t("aiAssistant.sidebar.localStatus")}</p>
+ <p className="mt-1">{t("aiAssistant.agentSource.localHint")}</p>
</TooltipContent>
</Tooltip>
</TooltipProvider>
diff --git a/docs/acp-note-access.md b/docs/acp-note-access.md
new file mode 100644
index 00000000..79a07775
--- /dev/null
+++ b/docs/acp-note-access.md
@@ -0,0 +1,9 @@
+# Note access for local ACP agents
+
+When a user sends a message to a local agent in the desktop app, EdgeEver automatically supplies MCP tools for the signed-in account. The user does not need to configure the EdgeEver instance in the agent or create an API token. The tools follow the existing server-side note permissions and can read, create, edit, and delete content in the current workspace. The agent's other local tool permissions remain subject to the agent and ACP client.
+
+The desktop main process retains the login credential and creates a temporary loopback bridge for each turn. The agent receives a temporary credential for that bridge. The bridge expires when the turn ends or is cancelled, or when the current instance or login session changes. A turn with note tools does not start if the current sign-in state cannot be verified.
+
+The ACP session server is named `edgeever-current-workspace`. An agent that already has EdgeEver MCP configured may see two sets of tools. This causes no protocol conflict, but the configurations may target different instances or accounts and may lead to duplicate writes. EdgeEver instructs the agent to use the session server and warns the user to check existing configurations. ACP cannot guarantee that an agent's persistent MCP configuration is replaced or removed.
+
+This feature changes the permission boundary for local ACP agents. Before a formal release, verify tool discovery, account switching, writes, and failure recovery with supported real agents, packaged desktop apps, and an upgrade from an older version.
diff --git a/docs/acp-note-access.zh-CN.md b/docs/acp-note-access.zh-CN.md
new file mode 100644
index 00000000..0d29a57a
--- /dev/null
+++ b/docs/acp-note-access.zh-CN.md
@@ -0,0 +1,9 @@
+# 本机 ACP Agent 的笔记库访问
+
+桌面端在用户向本机 Agent 发送消息时,自动提供当前登录账号的 EdgeEver MCP 工具。用户无需在 Agent 中配置 EdgeEver 实例或创建 API Token。工具遵循现有服务端笔记权限,可读取、创建、修改和删除当前工作区中的内容。Agent 的其他本机工具权限仍由其自身和 ACP 客户端控制。
+
+桌面主进程保留登录会话凭据,并为每次对话轮次建立仅监听本机的临时转发入口。Agent 获得的是该入口的临时凭据;轮次结束、取消或当前实例及登录会话改变时,入口失效。无法确认当前登录状态时,不启动带笔记工具的 Agent 轮次。
+
+ACP 会话中的服务名为 `edgeever-current-workspace`。如果 Agent 自己已经配置了 EdgeEver MCP,它可能同时看到两套工具。协议层面不会冲突,但两套配置可能指向不同的实例或账号,也可能导致重复写入。EdgeEver 会在会话中指示 Agent 使用本次提供的服务,并在设置中提示用户核对既有配置;ACP 协议无法保证覆盖或移除 Agent 的持久 MCP 配置。
+
+本功能改变了本机 ACP Agent 的权限边界。正式发布前仍须在受支持的真实 Agent、打包桌面客户端和旧版本升级链路上验证工具发现、账号切换、读写及失败恢复。
diff --git a/package.json b/package.json
index 13d399c5..d5dac00b 100644
--- a/package.json
+++ b/package.json
@@ -63,7 +63,7 @@
"release": "bun scripts/release.mjs",
"publish:stores": "bun scripts/store-delivery.mjs",
"test:desktop:sidecar": "bun scripts/test-desktop-sidecar.mjs",
- "test:desktop": "bun test apps/desktop/src/main/account-scope.test.mjs apps/desktop/src/main/app-protocol.test.mjs apps/desktop/src/main/child-process-start.test.mjs apps/desktop/src/main/clipboard-write.test.mjs apps/desktop/src/main/desktop-diagnostics.test.mjs apps/desktop/src/main/desktop-menu.test.mjs apps/desktop/src/main/desktop-update-flow.test.mjs apps/desktop/src/main/diagnostic-log.test.mjs apps/desktop/src/main/file-association.test.mjs apps/desktop/src/main/wechat-chat-archive.test.mjs apps/desktop/src/main/wechat-share-import.test.mjs apps/desktop/src/main/share-extension-registration.test.mjs apps/desktop/src/main/windows-share-menu.test.mjs apps/desktop/src/main/file-permissions.test.mjs apps/desktop/src/main/installation-location.test.mjs apps/desktop/src/main/local-data-reset.test.mjs apps/desktop/src/main/ai-direct.test.mjs apps/desktop/src/main/plugin-public-network.test.mjs apps/desktop/src/main/renderer-recovery.test.mjs apps/desktop/src/main/renderer-hibernate.test.mjs apps/desktop/src/main/renderer-startup-guard.test.mjs apps/desktop/src/main/renderer-storage-migration.test.mjs apps/desktop/src/main/resource-request.test.mjs apps/desktop/src/main/resource-url.test.mjs apps/desktop/src/main/scheduled-task-scheduler.test.mjs apps/desktop/src/main/screenshot-capture.test.mjs apps/desktop/src/main/staged-resource.test.mjs apps/desktop/src/main/staged-resource-alias.test.mjs apps/desktop/src/main/tray-icon.test.mjs apps/desktop/src/main/user-data-directory.test.mjs apps/desktop/src/main/window-open-policy.test.mjs apps/desktop/src/main/window-visibility.test.mjs apps/desktop/src/main/windows-update-trust.test.mjs apps/web/src/lib/api.test.mjs apps/web/src/lib/app-page-path.test.mjs apps/web/src/lib/clipboard.test.mjs apps/web/src/lib/desktop-renderer-ready.test.mjs apps/web/src/lib/desktop-workspace-restore.test.mjs apps/web/src/lib/desktop-repository.test.mjs apps/web/src/lib/desktop-resources.test.mjs apps/web/src/lib/desktop-sync.test.mjs apps/web/src/lib/local-mirror.test.mjs apps/web/src/lib/repository.test.mjs apps/web/src/lib/runtime.test.mjs apps/web/src/lib/screenshot-import.test.mjs apps/web/src/lib/wechat-chat-import.test.mjs apps/web/src/lib/shared-file-import.test.mjs apps/web/src/lib/sync-queue.test.mjs && bun test --cwd apps/desktop src/main/acp-adapter-manager.test.mjs src/main/acp-host.test.mjs && bun run test:desktop:sidecar",
+ "test:desktop": "bun test apps/desktop/src/main/account-scope.test.mjs apps/desktop/src/main/app-protocol.test.mjs apps/desktop/src/main/child-process-start.test.mjs apps/desktop/src/main/clipboard-write.test.mjs apps/desktop/src/main/desktop-diagnostics.test.mjs apps/desktop/src/main/desktop-menu.test.mjs apps/desktop/src/main/desktop-update-flow.test.mjs apps/desktop/src/main/diagnostic-log.test.mjs apps/desktop/src/main/file-association.test.mjs apps/desktop/src/main/wechat-chat-archive.test.mjs apps/desktop/src/main/wechat-share-import.test.mjs apps/desktop/src/main/share-extension-registration.test.mjs apps/desktop/src/main/windows-share-menu.test.mjs apps/desktop/src/main/file-permissions.test.mjs apps/desktop/src/main/installation-location.test.mjs apps/desktop/src/main/local-data-reset.test.mjs apps/desktop/src/main/ai-direct.test.mjs apps/desktop/src/main/plugin-public-network.test.mjs apps/desktop/src/main/renderer-recovery.test.mjs apps/desktop/src/main/renderer-hibernate.test.mjs apps/desktop/src/main/renderer-startup-guard.test.mjs apps/desktop/src/main/renderer-storage-migration.test.mjs apps/desktop/src/main/resource-request.test.mjs apps/desktop/src/main/resource-url.test.mjs apps/desktop/src/main/scheduled-task-scheduler.test.mjs apps/desktop/src/main/screenshot-capture.test.mjs apps/desktop/src/main/staged-resource.test.mjs apps/desktop/src/main/staged-resource-alias.test.mjs apps/desktop/src/main/tray-icon.test.mjs apps/desktop/src/main/user-data-directory.test.mjs apps/desktop/src/main/window-open-policy.test.mjs apps/desktop/src/main/window-visibility.test.mjs apps/desktop/src/main/windows-update-trust.test.mjs apps/web/src/lib/api.test.mjs apps/web/src/lib/app-page-path.test.mjs apps/web/src/lib/clipboard.test.mjs apps/web/src/lib/desktop-renderer-ready.test.mjs apps/web/src/lib/desktop-workspace-restore.test.mjs apps/web/src/lib/desktop-repository.test.mjs apps/web/src/lib/desktop-resources.test.mjs apps/web/src/lib/desktop-sync.test.mjs apps/web/src/lib/local-mirror.test.mjs apps/web/src/lib/repository.test.mjs apps/web/src/lib/runtime.test.mjs apps/web/src/lib/screenshot-import.test.mjs apps/web/src/lib/wechat-chat-import.test.mjs apps/web/src/lib/shared-file-import.test.mjs apps/web/src/lib/sync-queue.test.mjs && bun test --cwd apps/desktop src/main/acp-adapter-manager.test.mjs src/main/acp-host.test.mjs src/main/acp-mcp-bridge.test.mjs && bun run test:desktop:sidecar",
"verify:desktop-renderer": "bun scripts/verify-desktop-renderer.mjs",
"verify:renderer-origin-migration": "bun run --cwd apps/desktop verify-origin-migration",
"verify:desktop-cross-version-startup": "bun scripts/verify-desktop-cross-version-startup.mjs",
diff --git a/packages/shared/src/i18n/en-US.ts b/packages/shared/src/i18n/en-US.ts
index da5c854f..1be35891 100644
--- a/packages/shared/src/i18n/en-US.ts
+++ b/packages/shared/src/i18n/en-US.ts
@@ -1361,6 +1361,7 @@ export const enUS = {
localRejected: "This local agent does not support these files. They stay in the composer: {{names}}",
localStatus: "Local agent",
localMissing: "No local agent is available. Choose an adapter, or use the built-in assistant.",
+ noteAccessUnavailable: "Could not connect to this account's notes. Check the instance connection and sign-in status, then try again.",
unavailable: "Sign in to a personal account to send. Demo mode and signed-out sessions cannot use the built-in assistant.",
proposalConfirm: "Apply to note",
proposalReject: "Don't apply",
@@ -1391,7 +1392,7 @@ export const enUS = {
builtin: "Built-in Agent",
builtinHint: "Uses the model services and tools configured below.",
local: "Local Agent (ACP)",
- localHint: "Connects to Codex, Antigravity, Grok Build, or WorkBuddy on this machine.",
+ localHint: "Connects to a local Agent and automatically grants access to read, edit, and delete notes in the signed-in account. No separate MCP setup is needed. If the Agent already has EdgeEver MCP, check that it uses the same instance and account.",
adapter: "Agent",
codex: "Codex",
antigravity: "Antigravity",
diff --git a/packages/shared/src/i18n/ja.ts b/packages/shared/src/i18n/ja.ts
index 6c325e79..a569c2ed 100644
--- a/packages/shared/src/i18n/ja.ts
+++ b/packages/shared/src/i18n/ja.ts
@@ -1361,6 +1361,7 @@ export const ja = {
localRejected: "このローカル Agent は次のファイルに対応していません。入力欄に残しています:{{names}}",
localStatus: "ローカル Agent",
localMissing: "使えるローカル Agent がありません。アダプターを選ぶか、内蔵アシスタントを使ってください。",
+ noteAccessUnavailable: "このアカウントのノートに接続できません。インスタンスへの接続とログイン状態を確認して、再試行してください。",
unavailable: "送信するには個人アカウントでサインインしてください。デモモードや未ログインでは内蔵アシスタントを使えません。",
proposalConfirm: "ノートに適用",
proposalReject: "適用しない",
@@ -1391,7 +1392,7 @@ export const ja = {
builtin: "内蔵 Agent",
builtinHint: "下で設定したモデルサービスとツールを使用します。",
local: "ローカル Agent (ACP)",
- localHint: "このマシン上の Codex、Antigravity、Grok Build、または WorkBuddy に接続します。",
+ localHint: "ローカル Agent に接続し、ログイン中のアカウントのノートを閲覧・編集・削除する権限を自動で付与します。MCP の別途設定は不要です。Agent に EdgeEver MCP が設定済みの場合は、同じインスタンスとアカウントを指しているか確認してください。",
adapter: "エージェント",
codex: "Codex",
antigravity: "Antigravity",
diff --git a/packages/shared/src/i18n/zh-CN.ts b/packages/shared/src/i18n/zh-CN.ts
index 70a7b329..e493079c 100644
--- a/packages/shared/src/i18n/zh-CN.ts
+++ b/packages/shared/src/i18n/zh-CN.ts
@@ -1361,6 +1361,7 @@ export const zhCN = {
localRejected: "本地 Agent 不支持这些文件,已留在输入框:{{names}}",
localStatus: "本地 Agent",
localMissing: "还没有可用的本地 Agent。请先选择适配器,或改用内置助手。",
+ noteAccessUnavailable: "无法连接当前账号的笔记库。请检查实例连接和登录状态后重试。",
unavailable: "需要登录个人账户后才能发送。演示模式或未登录时不能使用内置助手。",
proposalConfirm: "应用到笔记",
proposalReject: "不采用",
@@ -1391,7 +1392,7 @@ export const zhCN = {
builtin: "内置 Agent",
builtinHint: "直接调用下方配置的模型服务与工具。",
local: "本机 Agent (ACP)",
- localHint: "连接本机安装的 Codex、Antigravity、Grok Build 或 WorkBuddy 等 Agent。",
+ localHint: "连接本机 Agent。会自动提供当前登录账号的笔记库读写与删除权限,无需另配 MCP;若 Agent 已配置 EdgeEver MCP,请确认它指向同一实例和账号。",
adapter: "Agent",
codex: "Codex",
antigravity: "Antigravity",
diff --git a/scripts/edgeever-mcp-stdio.mjs b/scripts/edgeever-mcp-stdio.mjs
index bd4ced8f..c4cd8c61 100644
--- a/scripts/edgeever-mcp-stdio.mjs
+++ b/scripts/edgeever-mcp-stdio.mjs
@@ -140,10 +140,14 @@ async function forwardToEdgeEver(request) {
}
async function createClient(profileName) {
- const config = await readConfig();
+ const directUrl = process.env.EDGEEVER_URL;
+ const directToken = process.env.EDGEEVER_TOKEN;
+ // ACP supplies both values for its short-lived local bridge. In that mode,
+ // do not read an unrelated MCP profile from the user's home directory.
+ const config = directUrl && directToken ? {} : await readConfig();
const profile = profileName ? config.profiles?.[profileName] : undefined;
- const baseUrl = (process.env.EDGEEVER_URL || profile?.url || DEFAULT_URL).replace(/\/+$/, "");
- const token = process.env.EDGEEVER_TOKEN || profile?.token;
+ const baseUrl = (directUrl || profile?.url || DEFAULT_URL).replace(/\/+$/, "");
+ const token = directToken || profile?.token;
if (!token) {
throw new Error("EDGEEVER_TOKEN is required, or configure a profile with `bun run cli -- profile set`.");