Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
15 commits
Select commit Hold shift + click to select a range
e9fba66
tests: an update that removes a signed-in MCP server keeps its creden…
ThomasK33 Nov 5, 2026
a8f54f1
fix: sign out OAuth credentials of MCP servers that a plugin update r…
ThomasK33 Nov 5, 2026
ef602f8
tests: an uninstall leaves the plugin's OAuth credentials stored (red)
ThomasK33 Nov 5, 2026
8752416
fix: sign out OAuth credentials of a plugin's MCP servers when it is …
ThomasK33 Nov 5, 2026
36f0393
🤖 chore: drop narrating comments from the plugin sign-out change
ThomasK33 Nov 5, 2026
15d9cb7
refactor: name the sign-in identity map by server name, fix sign-out …
ThomasK33 Nov 5, 2026
d348504
tests: an uninstall whose sign-out fails leaves the URL pending
ThomasK33 Nov 5, 2026
bec7257
tests: mark the equivalent mutants of the sign-in helpers
ThomasK33 Nov 5, 2026
fc708ab
Merge origin/main into plugin-update-oauth-removed-signout
ThomasK33 Nov 5, 2026
9909513
chore: sync the built-in docs skill content with the MCP docs
ThomasK33 Nov 5, 2026
c6d743c
tests: pin record-before-commit for uninstall and update, and the uni…
ThomasK33 Nov 6, 2026
24b2414
tests: an uninstall refuses early on a corrupt pending sign-out recor…
ThomasK33 Nov 6, 2026
3dc05b8
fix: an uninstall reads the pending sign-out record before anything s…
ThomasK33 Nov 6, 2026
a4d83f6
tests: an uninstall of a stdio-only plugin ignores a corrupt pending …
ThomasK33 Nov 6, 2026
788d670
tests: satisfy require-await in the early-refusal test
ThomasK33 Nov 6, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/config/mcp-servers.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ A remote plugin server can declare OAuth sign-in settings (a client, scopes, an

Stdio plugin servers launch with the spec's `PLUGIN_ROOT` and `PLUGIN_DATA` environment variables; per-plugin data directories live under `~/.xum/plugin-data/`.

**Settings → Plugins** installs plugins from git into `~/.xum/plugins` (paste a git URL or `owner/repo[/path/to/plugin][@ref]`); the exact location derives from the active Xum home (a legacy `~/.mux` home keeps working) and is shown in the section. Before anything is written, a consent preview lists the plugin's manifest, every skill, and every MCP server command line. Installs are pinned to the resolved commit; update checks compare the tracked branch or tag against the pinned commit and never auto-apply. With a monorepo subpath (for example `cursor/plugins/pstack`; for a full git URL, enter the folder in the **Plugin folder** field), Xum downloads only that folder's files (a sparse, partial clone) and installs it as the plugin, and the consent preview and update reviews cover only that folder: an upstream commit that changes only files outside it still shows as an update, but applies without a new review. Applying an update replaces the plugin directory wholesale — local edits to a managed plugin directory are discarded — and restarts that plugin's running MCP servers. Uninstalling removes the directory, the registry entry, and the plugin's global enablement and per-workspace server overrides, but keeps `~/.xum/plugin-data/` unless you opt in to deleting it.
**Settings → Plugins** installs plugins from git into `~/.xum/plugins` (paste a git URL or `owner/repo[/path/to/plugin][@ref]`); the exact location derives from the active Xum home (a legacy `~/.mux` home keeps working) and is shown in the section. Before anything is written, a consent preview lists the plugin's manifest, every skill, and every MCP server command line. Installs are pinned to the resolved commit; update checks compare the tracked branch or tag against the pinned commit and never auto-apply. With a monorepo subpath (for example `cursor/plugins/pstack`; for a full git URL, enter the folder in the **Plugin folder** field), Xum downloads only that folder's files (a sparse, partial clone) and installs it as the plugin, and the consent preview and update reviews cover only that folder: an upstream commit that changes only files outside it still shows as an update, but applies without a new review. Applying an update replaces the plugin directory wholesale — local edits to a managed plugin directory are discarded — and restarts that plugin's running MCP servers. An update also signs out of a remote server whose sign-in settings change or that the update removes. Uninstalling removes the directory, the registry entry, the plugin's global enablement and per-workspace server overrides, and the stored sign-in of each remote MCP server it declares, but keeps `~/.xum/plugin-data/` unless you opt in to deleting it. Stored sign-ins are keyed by server URL, so another server at the same URL is signed out too.

### Plugin server environment

Expand Down
331 changes: 331 additions & 0 deletions src/node/services/agentPlugins/installService.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import {
import {
AgentPluginInstallService,
describeSignInChanges,
signInResetUrls,
withDiskQuotaWatchdog,
} from "./installService";
import {
Expand Down Expand Up @@ -4568,6 +4569,279 @@ describe("AgentPluginInstallService", () => {
await oauth.dispose();
});

describe("stored sign-ins of plugin MCP servers that an update removes or an uninstall deletes", () => {
const docsUrl = "https://docs.example.com/mcp";
const keepUrl = "https://keep.example.com/mcp";
const oauthEntry = (url: string, clientId: string) => ({
type: "streamable-http",
url,
extensions: {
"com.openai": { auth: { type: "oauth", client: { mode: "provided", clientId } } },
},
});
const writeServers = async (servers: Record<string, unknown> | undefined) => {
const file = path.join(remoteDir, "mcp.json");
if (servers === undefined) await fsPromises.rm(file);
else
await fsPromises.writeFile(
file,
JSON.stringify({ $schema: AGENT_PLUGIN_MCP_SCHEMA_ID_1_0_0, mcpServers: servers })
);
await commitAll(remoteDir, Object.keys(servers ?? {}).join(" ") || "no MCP file");
};
const signedInStore = (urls: string[]) =>
JSON.stringify({
version: 2,
entries: Object.fromEntries(
urls.map((serverUrl) => [
serverUrl,
{
serverUrl,
updatedAtMs: Date.now(),
clientInformation: { client_id: "client-a" },
tokens: { access_token: "at", token_type: "Bearer" },
},
])
),
});
const pendingRecord = (): Promise<unknown> =>
fsPromises.readFile(path.join(muxRoot, "plugin-sign-outs-pending.json"), "utf8").then(
(text) => JSON.parse(text) as unknown,
() => null
);
const installSignedIn = async (
servers: Record<string, unknown>,
signedInUrls: string[],
hooks: { onStop?: () => Promise<void>; mcpConfigService?: MCPConfigService } = {}
) => {
const updater = new AgentPluginInstallService(config, {
mcpServerManager: {
stopServersWithKeyPrefix: () => hooks.onStop?.() ?? Promise.resolve(),
} as unknown as MCPServerManager,
...(hooks.mcpConfigService !== undefined
? { mcpConfigService: hooks.mcpConfigService }
: {}),
});
await writeServers(servers);
const preview = await updater.preview({ input: remoteDir });
await updater.install({ source: preview.source, expectedSha: preview.lockedSha });
await fsPromises.writeFile(path.join(muxRoot, "mcp-oauth.json"), signedInStore(signedInUrls));
const oauth = new McpOauthService(config, new MCPConfigService(config));
updater.setMcpOauthService(oauth);
const update = async (servers: Record<string, unknown> | undefined) => {
await writeServers(servers);
const review = await updater.previewUpdate({ name: "demo-plugin" });
await updater.update({
name: "demo-plugin",
consent: { fromSha: review.fromSha, toSha: review.toSha },
});
};
return { updater, oauth, update };
};

// The 20 s limits: each test installs and updates a plugin over git, which takes more than the
// default 5 s on a loaded runner.
test("signs out the removed server, so a later server at its URL does not inherit the credentials", async () => {
const { oauth, update } = await installSignedIn(
{ docs: oauthEntry(docsUrl, "client-a"), keep: oauthEntry(keepUrl, "client-k") },
[docsUrl, keepUrl]
);
await update({ keep: oauthEntry(keepUrl, "client-k") });
expect(await oauth.hasAuthTokens({ serverUrl: docsUrl })).toBe(false);
expect(await oauth.hasAuthTokens({ serverUrl: keepUrl })).toBe(true);
await update({
keep: oauthEntry(keepUrl, "client-k"),
docs: oauthEntry(docsUrl, "client-b"),
});
expect(await oauth.hasAuthTokens({ serverUrl: docsUrl })).toBe(false);
await oauth.dispose();
}, 20_000);

test("signs out every server when the update drops the plugin's MCP file", async () => {
const { oauth, update } = await installSignedIn({ docs: oauthEntry(docsUrl, "client-a") }, [
docsUrl,
]);
await update(undefined);
expect(await oauth.hasAuthTokens({ serverUrl: docsUrl })).toBe(false);
await oauth.dispose();
}, 20_000);

test("an uninstall signs out the plugin's servers, so a reinstall under another client does not inherit them", async () => {
const { updater, oauth } = await installSignedIn({ docs: oauthEntry(docsUrl, "client-a") }, [
docsUrl,
]);
await updater.uninstall({ name: "demo-plugin", deletePluginData: false });
expect(await oauth.hasAuthTokens({ serverUrl: docsUrl })).toBe(false);
await writeServers({ docs: oauthEntry(docsUrl, "client-b") });
const preview = await updater.preview({ input: remoteDir });
await updater.install({ source: preview.source, expectedSha: preview.lockedSha });
expect(await oauth.hasAuthTokens({ serverUrl: docsUrl })).toBe(false);
await oauth.dispose();
}, 20_000);

test("an uninstall whose sign-out fails leaves the URL pending for the next pass", async () => {
const { updater, oauth } = await installSignedIn({ docs: oauthEntry(docsUrl, "client-a") }, [
docsUrl,
]);
spyOn(oauth, "logout").mockResolvedValue({ success: false, error: "disk full" });
await updater.uninstall({ name: "demo-plugin", deletePluginData: false });
expect(await registry()).toEqual([]);
const record = await fsPromises.readFile(
path.join(muxRoot, "plugin-sign-outs-pending.json"),
"utf8"
);
expect(JSON.parse(record)).toEqual({ version: 1, urls: [docsUrl] });
await oauth.dispose();
}, 20_000);

test("an uninstall that fails keeps the sign-in and records no sign-out", async () => {
const { updater, oauth } = await installSignedIn({ docs: oauthEntry(docsUrl, "client-a") }, [
docsUrl,
]);
const internals = updater as unknown as {
writeRegistry: (envelope: Record<string, unknown>, entries: unknown[]) => Promise<void>;
};
const writeSpy = spyOn(internals, "writeRegistry").mockImplementationOnce(() =>
Promise.reject(new Error("ENOSPC: no space left on device"))
);
try {
await expect(
updater.uninstall({ name: "demo-plugin", deletePluginData: false })
).rejects.toThrow(/persist the plugin registry/);
} finally {
writeSpy.mockRestore();
}
expect(await registry()).toHaveLength(1);
expect(await oauth.hasAuthTokens({ serverUrl: docsUrl })).toBe(true);
expect(await pathExists(path.join(muxRoot, "plugin-sign-outs-pending.json"))).toBe(false);
await oauth.dispose();
}, 20_000);

test("a plugin whose MCP file cannot be read can still be uninstalled", async () => {
const { updater, oauth } = await installSignedIn({ docs: oauthEntry(docsUrl, "client-a") }, [
docsUrl,
]);
await fsPromises.writeFile(path.join(pluginsDir(), "demo-plugin", "mcp.json"), "{ not json");
await updater.uninstall({ name: "demo-plugin", deletePluginData: false });
expect(await registry()).toEqual([]);
await oauth.dispose();
}, 20_000);
test("an update records its sign-outs before the old tree stops and moves", async () => {
let armed = false;
let atFirstStop: unknown = "not read";
const { update, oauth } = await installSignedIn(
{ docs: oauthEntry(docsUrl, "client-a") },
[docsUrl],
{
onStop: async () => {
if (armed && atFirstStop === "not read") atFirstStop = await pendingRecord();
},
}
);
armed = true;
await update({ docs: oauthEntry(docsUrl, "client-b") });
expect(atFirstStop).toEqual({ version: 1, urls: [docsUrl] });
await oauth.dispose();
}, 20_000);

test("an uninstall records its sign-outs before the registry commit", async () => {
const { updater, oauth } = await installSignedIn({ docs: oauthEntry(docsUrl, "client-a") }, [
docsUrl,
]);
const internals = updater as unknown as {
writeRegistry: (envelope: Record<string, unknown>, entries: unknown[]) => Promise<void>;
};
const realWrite = internals.writeRegistry.bind(internals);
let atCommit: unknown = "not read";
const writeSpy = spyOn(internals, "writeRegistry").mockImplementation(
async (envelope, entries) => {
if (atCommit === "not read") atCommit = await pendingRecord();
return realWrite(envelope, entries);
}
);
try {
await updater.uninstall({ name: "demo-plugin", deletePluginData: false });
} finally {
writeSpy.mockRestore();
}
expect(atCommit).toEqual({ version: 1, urls: [docsUrl] });
await oauth.dispose();
}, 20_000);

test("an uninstall refuses at once while the pending sign-out record is corrupt, and changes nothing", async () => {
const mcpConfigService = new MCPConfigService(config, {
agentPluginsMcpProvider: createAgentPluginsMcpProvider({ xumHome: muxRoot }),
});
let armed = false;
let stops = 0;
const { updater, oauth } = await installSignedIn(
{ docs: oauthEntry(docsUrl, "client-a") },
[docsUrl],
{
mcpConfigService,
onStop: () => {
if (armed) stops++;
return Promise.resolve();
},
}
);
const key = buildPluginServerKey(
computePluginInstanceId(path.join(pluginsDir(), "demo-plugin")),
"docs"
);
expect(await mcpConfigService.setServerEnabled(key, true)).toEqual({
success: true,
data: undefined,
});
await fsPromises.writeFile(path.join(muxRoot, "plugin-sign-outs-pending.json"), "{ not json");
armed = true;
const failure = await updater
.uninstall({ name: "demo-plugin", deletePluginData: false })
.then(
() => undefined,
(error: unknown) => error as Error
);
// The record's own error, naming the Settings recovery step, before anything moves.
expect(failure?.message).toMatch(
/^The pending plugin sign-out record .*Sign out of plugin MCP servers/
);
expect(stops).toBe(0);
// The record fences plugin discovery, so read the global enablement from its file.
const globalConfig = jsonc.parse(
await fsPromises.readFile(path.join(muxRoot, "mcp.jsonc"), "utf8")
) as { enabledPluginServers?: string[] };
expect(globalConfig.enabledPluginServers).toEqual([key]);
expect(await registry()).toHaveLength(1);
expect(await oauth.hasAuthTokens({ serverUrl: docsUrl })).toBe(true);
await oauth.dispose();
}, 20_000);

test("an uninstall of a plugin with no remote servers ignores a corrupt pending record", async () => {
const preview = await service.preview({ input: remoteDir });
await service.install({ source: preview.source, expectedSha: preview.lockedSha });
await fsPromises.writeFile(path.join(muxRoot, "plugin-sign-outs-pending.json"), "{ not json");
await service.uninstall({ name: "demo-plugin", deletePluginData: false });
expect(await registry()).toEqual([]);
}, 20_000);

test("a plugin whose servers cannot be listed can still be uninstalled", async () => {
const { updater, oauth } = await installSignedIn({ docs: oauthEntry(docsUrl, "client-a") }, [
docsUrl,
]);
const discover = spyOn(discoveryModule, "discoverAgentPluginAt").mockRejectedValueOnce(
new Error("EACCES: permission denied")
);
try {
await updater.uninstall({ name: "demo-plugin", deletePluginData: false });
expect(discover).toHaveBeenCalled();
} finally {
discover.mockRestore();
}
expect(await registry()).toEqual([]);
await oauth.dispose();
}, 20_000);
});

test("an update review reads a Codex .mcp.json once per tree, not once per server", async () => {
await fsPromises.rm(path.join(remoteDir, "mcp.json"));
const servers = (secret: string) =>
Expand Down Expand Up @@ -8879,6 +9153,63 @@ describe("describeSignInChanges", () => {
});
});

describe("signInResetUrls", () => {
// The credential key drops a trailing slash, as McpOauthService.credentialKey does.
const key = (url: string): string | null => url.replace(/\/$/, "");
const tree = (servers: Record<string, { url: string; identity: string } | null>) =>
new Map(
Object.entries(servers).map(([name, signIn]) => [name, signIn === null ? {} : { signIn }])
);
const at = (url: string, identity: string) => ({ url, identity });
const mcp = "https://mcp.example.com/mcp";

test("resets a server whose identity changes, and no server whose identity stays", () => {
expect(signInResetUrls(tree({ a: at(mcp, "x") }), tree({ a: at(mcp, "y") }), key)).toEqual([
mcp,
]);
expect(signInResetUrls(tree({ a: at(mcp, "x") }), tree({ a: at(mcp, "x") }), key)).toEqual([]);
});

test("matches by credential key: a respelled URL with the same identity is not a removal", () => {
expect(
signInResetUrls(tree({ a: at(mcp, "x") }), tree({ b: at(`${mcp}/`, "x") }), key)
).toEqual([]);
expect(
signInResetUrls(tree({ a: at(mcp, "x") }), tree({ b: at(`${mcp}/`, "y") }), key)
).toEqual([`${mcp}/`]);
});

test("a sibling that already has the new identity does not mask a change", () => {
const current = tree({ a: at(mcp, "x"), b: at(mcp, "y") });
expect(signInResetUrls(current, tree({ a: at(mcp, "y"), b: at(mcp, "y") }), key)).toEqual([
mcp,
]);
});

test("a renamed entry has no previous self: any other identity at the key resets it", () => {
const current = tree({ a: at(mcp, "x"), b: at(mcp, "y") });
expect(signInResetUrls(current, tree({ c: at(mcp, "y"), b: at(mcp, "y") }), key)).toEqual([
mcp,
]);
expect(
signInResetUrls(tree({ a: at(mcp, "y"), b: at(mcp, "y") }), tree({ c: at(mcp, "y") }), key)
).toEqual([]);
});

test("resets the URL of each server the update removes, and no other", () => {
const other = "https://other.example.com/mcp";
const current = tree({ a: at(mcp, "x"), b: at(other, "x"), local: null });
expect(signInResetUrls(current, tree({ b: at(other, "x") }), key)).toEqual([mcp]);
expect(signInResetUrls(current, tree({}), key)).toEqual([mcp, other]);
});

test("a server added at a new key, a tree with no current servers and an unkeyed URL reset nothing", () => {
expect(signInResetUrls(tree({}), tree({ a: at(mcp, "x") }), key)).toEqual([]);
expect(signInResetUrls(undefined, tree({ a: at(mcp, "x") }), key)).toEqual([]);
expect(signInResetUrls(tree({ a: at(mcp, "x") }), tree({}), () => null)).toEqual([]);
});
});

describe("file review of a Cursor plugin with a runnable command hook (D1, D30)", () => {
let muxRoot: string;
let remoteDir: string;
Expand Down
Loading
Loading