Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -7102,13 +7102,15 @@ describe("ClaudeAdapterV2 background wake turns", () => {
),
);

it.effect("asks to sign in to a configured MCP server, but not to a claude.ai connector", () =>
it.effect("asks to sign in to a configured MCP server, but not to a connector or plugin", () =>
Effect.gen(function* () {
const harness = yield* makeWakeHarnessWithOptions({
mcp: {
mcpServerStatus: Effect.succeed([
{ name: "linear", status: "needs-auth" },
{ name: "claude.ai Gmail", status: "needs-auth", scope: "claudeai" },
{ name: "plugin:legal:slack", status: "needs-auth", source: "plugin" },
{ name: "plugin:design:figma", status: "needs-auth" },
{ name: "docs", status: "connected" },
]),
readMcpResource: () => Effect.die("unexpected MCP resource read"),
Expand Down Expand Up @@ -7165,6 +7167,61 @@ describe("ClaudeAdapterV2 background wake turns", () => {
),
);

it.effect("skips the MCP status request when init lists only plugins and connectors", () =>
Effect.gen(function* () {
let statusRequests = 0;
const harness = yield* makeWakeHarnessWithOptions({
mcp: {
mcpServerStatus: Effect.sync(() => {
statusRequests += 1;
return [];
}),
readMcpResource: () => Effect.die("unexpected MCP resource read"),
callMcpTool: () => Effect.die("unexpected MCP tool call"),
},
});
yield* harness.runtime.startTurn(
makeClaudeTestTurnInput({
threadId: harness.threadId,
providerThread: harness.providerThread,
now: yield* DateTime.now,
attemptId: RunAttemptId.make("mcp-plugin-init"),
text: "Plan the sprint",
attachments: [],
}),
);
yield* harness.offerAndWait(
claudeSdkFrame({
type: "system",
subtype: "init",
uuid: "mcp-plugin-init",
session_id: WAKE_NATIVE_SESSION,
mcp_servers: [
{ name: "plugin:legal:slack", status: "pending" },
{ name: "plugin:design:figma", status: "needs-auth" },
{ name: "claude.ai Gmail", status: "needs-auth" },
],
}),
);
yield* Queue.offer(
harness.sdkMessages,
makeResultFrame({ uuid: "mcp-plugin-init-result", result: "Planned" }),
);
yield* Queue.take(harness.terminalReceipts);
assert.strictEqual(statusRequests, 0);
}).pipe(
Effect.scoped,
Effect.provide(
Layer.mergeAll(
IdAllocator.layer,
McpProviderSessions.layer,
NodeServices.layer,
NodeCrypto.layer,
),
),
),
);

// regression: #38284 an MCP app's update-model-context note must reach Claude's next turn
it.effect("sends MCP app model context with the next Claude turn", () =>
Effect.gen(function* () {
Expand Down
19 changes: 15 additions & 4 deletions apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -977,6 +977,10 @@ async function sendClaudeControlRequest(
return Predicate.isObject(reply) ? reply.response : undefined;
}

// Older CLIs omit `source`; plugin servers are always named `plugin:<plugin>:<server>`.
const isClaudePluginMcpServer = (server: { readonly name: string; readonly source?: string }) =>
server.source === "plugin" || server.name.startsWith("plugin:");

const decodeClaudeMcpAuthenticateReply = Schema.decodeUnknownEffect(
Schema.Struct({
authUrl: Schema.optional(Schema.String),
Expand Down Expand Up @@ -8802,8 +8806,14 @@ export const makeClaudeAdapterV2 = Effect.fn("makeClaudeAdapterV2")(function* (
);
liveQuery.checkMcpSignIns = statuses.some((status) => status.status === "pending");
for (const status of statuses) {
// Every claude.ai connector the user never connected reports this too.
if (status.status !== "needs-auth" || status.scope === "claudeai") continue;
// Unconnected claude.ai connectors and plugin-bundled servers report this too.
if (
status.status !== "needs-auth" ||
status.scope === "claudeai" ||
isClaudePluginMcpServer(status)
) {
continue;
}
const key = `${liveQuery.nativeThreadId}\u0000${status.name}`;
if (announcedMcpSignIns.has(key)) continue;
announcedMcpSignIns.add(key);
Expand Down Expand Up @@ -13364,8 +13374,9 @@ export const makeClaudeAdapterV2 = Effect.fn("makeClaudeAdapterV2")(function* (
context.checkMcpSignIns = (message.mcp_servers ?? []).some(
(server) =>
(server.status === "pending" || server.status === "needs-auth") &&
// claude.ai connectors the user never connected need a sign-in too.
!server.name.startsWith("claude.ai "),
// Unconnected claude.ai connectors and plugin servers are never announced.
!server.name.startsWith("claude.ai ") &&
!isClaudePluginMcpServer(server),
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
);
}
if (
Expand Down
Loading