Skip to content

Commit 18e5ac6

Browse files
Phicks-debugclaude
andcommitted
fix(mcp): answer MCP 2026-07-28 discovery instead of a 400
Clients that speak only MCP 2026-07-28 open with server/discover, which /mcp rejected because the transport offered only 2025-06-18. Offer the 2026-07-28 adapter Effect already ships, after 2025-06-18 so that stays the fallback for unknown initialize versions. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 82b10d5 commit 18e5ac6

2 files changed

Lines changed: 74 additions & 1 deletion

File tree

‎apps/server/src/mcp/McpHttpServer.test.ts‎

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -823,6 +823,78 @@ it.effect("terminates HTTP MCP sessions with DELETE", () =>
823823
).pipe(Effect.provide(NodeHttpServer.layerTest)),
824824
);
825825

826+
it.effect("answers 2026-07-28 discovery and keeps 2025-06-18 as the initialize fallback", () =>
827+
Effect.scoped(
828+
Effect.gen(function* () {
829+
const token = "providerTokenWithoutDots";
830+
const scope: McpInvocationContext.McpInvocationScope = {
831+
environmentId,
832+
requestNamespace: "provider-session",
833+
thread: {
834+
threadId: ThreadId.make("thread-provider"),
835+
providerSessionId: "provider-session",
836+
providerInstanceId: ProviderInstanceId.make("codex"),
837+
},
838+
client: undefined,
839+
capabilities: new Set(["orchestration"]),
840+
issuedAt: 1,
841+
};
842+
const layerServer = McpHttpServer.layerMcpTransport.pipe(
843+
Layer.provide(ServerSettings.layerTest()),
844+
Layer.provide(
845+
Layer.mock(McpSessionRegistry.McpSessionRegistry)({
846+
resolve: (presented) =>
847+
Effect.succeed(
848+
presented === token
849+
? (scope as McpInvocationContext.McpThreadInvocationScope)
850+
: undefined,
851+
),
852+
}),
853+
),
854+
);
855+
yield* HttpRouter.serve(layerServer, {
856+
disableListenLog: true,
857+
disableLogger: true,
858+
}).pipe(Layer.build);
859+
const httpClient = (yield* HttpClient.HttpClient).pipe(
860+
HttpClient.mapRequest(HttpClientRequest.bearerToken(token)),
861+
);
862+
863+
const discoverResponse = yield* httpClient.post("/mcp", {
864+
headers: {
865+
accept: "application/json, text/event-stream",
866+
"mcp-method": "server/discover",
867+
"mcp-protocol-version": "2026-07-28",
868+
},
869+
body: HttpBody.text(
870+
`{"jsonrpc":"2.0","id":1,"method":"server/discover","params":{"_meta":{"io.modelcontextprotocol/protocolVersion":"2026-07-28","io.modelcontextprotocol/clientCapabilities":{},"io.modelcontextprotocol/clientInfo":{"name":"mcp-test","version":"1.0.0"}}}}`,
871+
"application/json",
872+
),
873+
});
874+
expect(discoverResponse.status).toBe(200);
875+
const discovered = (yield* discoverResponse.json) as {
876+
result: { supportedVersions: ReadonlyArray<string> };
877+
};
878+
expect(discovered.result.supportedVersions).toEqual(
879+
expect.arrayContaining(["2026-07-28", "2025-06-18"]),
880+
);
881+
882+
const initializeResponse = yield* httpClient.post("/mcp", {
883+
headers: { accept: "application/json, text/event-stream" },
884+
body: HttpBody.text(
885+
`{"jsonrpc":"2.0","id":2,"method":"initialize","params":{"protocolVersion":"2099-01-01","capabilities":{},"clientInfo":{"name":"mcp-test","version":"1.0.0"}}}`,
886+
"application/json",
887+
),
888+
});
889+
expect(initializeResponse.status).toBe(200);
890+
const initialized = (yield* initializeResponse.json) as {
891+
result: { protocolVersion: string };
892+
};
893+
expect(initialized.result.protocolVersion).toBe("2025-06-18");
894+
}),
895+
).pipe(Effect.provide(NodeHttpServer.layerTest)),
896+
);
897+
826898
it.effect("admits provider and OAuth client credentials and points only clients at OAuth", () =>
827899
Effect.scoped(
828900
Effect.gen(function* () {

‎apps/server/src/mcp/McpHttpServer.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1144,7 +1144,8 @@ export const layerMcpTransport = McpServer.layerHttp({
11441144
name: "T3 Code",
11451145
version: packageJson.version,
11461146
path: "/mcp",
1147-
protocols: [McpProtocol.v2025_06_18],
1147+
// The first protocol is the fallback for clients that offer an unknown version.
1148+
protocols: [McpProtocol.v2025_06_18, McpProtocol.v2026_07_28],
11481149
allowSessionTermination: true,
11491150
}).pipe(Layer.provide(layerMcpAuthMiddleware));
11501151

0 commit comments

Comments
 (0)