@devries-cameron20 / t3code-1 / commits / 5b64e52917
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

fix(mcp): answer MCP 2026-07-28 discovery instead of a 400 (#28683)

Co-authored-by: phicks-debug <phicks-debug@users.noreply.github.com> Co-authored-by: maria-rcks <maria@kuuro.net> Co-authored-by: Julius Marminge <julius0216@outlook.com>

Phicks-debug committed Nov 12, 2026 at 22:10 UTC 5b64e52917f37504053259a42a82d5f712b3cdfc
2 files changed +119 -1
apps/server/src/mcp/McpHttpServer.test.ts
+117
@@ -994,6 +994,123 @@ it.effect("terminates HTTP MCP sessions with DELETE", () =>
994 ).pipe(Effect.provide(NodeHttpServer.layerTest)),
995 );
996
997 +it.effect("answers 2026-07-28 discovery and keeps 2025-06-18 as the initialize fallback", () =>
998 + Effect.scoped(
999 + Effect.gen(function* () {
1000 + const token = "providerTokenWithoutDots";
1001 + const scope: McpInvocationContext.McpInvocationScope = {
1002 + environmentId,
1003 + requestNamespace: "provider-session",
1004 + thread: {
1005 + threadId: ThreadId.make("thread-provider"),
1006 + providerSessionId: "provider-session",
1007 + providerInstanceId: ProviderInstanceId.make("codex"),
1008 + },
1009 + client: undefined,
1010 + capabilities: new Set(["orchestration"]),
1011 + issuedAt: 1,
1012 + };
1013 + const ProbeToolkit = Toolkit.make(
1014 + Tool.make("probe", {
1015 + description: "Reports success.",
1016 + success: Schema.Struct({ ok: Schema.Boolean }),
1017 + }),
1018 + );
1019 + const layerServer = McpHttpServer.layerMcpTransport(
1020 + McpHttpServer.toolkitRegistration(
1021 + ProbeToolkit,
1022 + McpToolAccess.toLayer(ProbeToolkit, {
1023 + probe: McpToolAccess.reads(() => Effect.succeed({ ok: true })),
1024 + }),
1025 + ),
1026 + ).pipe(
1027 + Layer.provide(ServerSettings.layerTest()),
1028 + Layer.provide(
1029 + Layer.mock(McpSessionRegistry.McpSessionRegistry)({
1030 + resolve: (presented) =>
1031 + Effect.succeed(
1032 + presented === token
1033 + ? (scope as McpInvocationContext.McpThreadInvocationScope)
1034 + : undefined,
1035 + ),
1036 + }),
1037 + ),
1038 + );
1039 + yield* HttpRouter.serve(layerServer, {
1040 + disableListenLog: true,
1041 + disableLogger: true,
1042 + }).pipe(Layer.build);
1043 + const httpClient = (yield* HttpClient.HttpClient).pipe(
1044 + HttpClient.mapRequest(HttpClientRequest.bearerToken(token)),
1045 + );
1046 +
1047 + const discoverResponse = yield* httpClient.post("/mcp", {
1048 + headers: {
1049 + accept: "application/json, text/event-stream",
1050 + "mcp-method": "server/discover",
1051 + "mcp-protocol-version": "2026-07-28",
1052 + },
1053 + body: HttpBody.text(
1054 + `{"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"}}}}`,
1055 + "application/json",
1056 + ),
1057 + });
1058 + expect(discoverResponse.status).toBe(200);
1059 + const discovered = (yield* discoverResponse.json) as {
1060 + result: { supportedVersions: ReadonlyArray<string> };
1061 + };
1062 + expect(discovered.result.supportedVersions).toEqual(
1063 + expect.arrayContaining(["2026-07-28", "2025-06-18"]),
1064 + );
1065 +
1066 + const toolsResponse = yield* httpClient.post("/mcp", {
1067 + headers: {
1068 + accept: "application/json, text/event-stream",
1069 + "mcp-method": "tools/list",
1070 + "mcp-protocol-version": "2026-07-28",
1071 + },
1072 + body: HttpBody.text(
1073 + JSON.stringify({
1074 + jsonrpc: "2.0",
1075 + id: 3,
1076 + method: "tools/list",
1077 + params: {
1078 + _meta: {
1079 + "io.modelcontextprotocol/protocolVersion": "2026-07-28",
1080 + "io.modelcontextprotocol/clientCapabilities": {},
1081 + "io.modelcontextprotocol/clientInfo": { name: "mcp-test", version: "1.0.0" },
1082 + },
1083 + },
1084 + }),
1085 + "application/json",
1086 + ),
1087 + });
1088 + expect(toolsResponse.status).toBe(200);
1089 + const tools = (yield* toolsResponse.json) as {
1090 + error?: unknown;
1091 + result: { tools: ReadonlyArray<{ name: string }> };
1092 + };
1093 + expect(tools.error).toBeUndefined();
1094 + expect(tools.result.tools).toEqual(
1095 + expect.arrayContaining([expect.objectContaining({ name: "probe" })]),
1096 + );
1097 +
1098 + const initializeResponse = yield* httpClient.post("/mcp", {
1099 + headers: { accept: "application/json, text/event-stream" },
1100 + body: HttpBody.text(
1101 + `{"jsonrpc":"2.0","id":2,"method":"initialize","params":{"protocolVersion":"2099-01-01","capabilities":{},"clientInfo":{"name":"mcp-test","version":"1.0.0"}}}`,
1102 + "application/json",
1103 + ),
1104 + });
1105 + expect(initializeResponse.status).toBe(200);
1106 + const initialized = (yield* initializeResponse.json) as {
1107 + result: { protocolVersion: string };
1108 + };
1109 + expect(initialized.result.protocolVersion).toBe("2025-06-18");
1110 + }),
1111 + ).pipe(Effect.provide(NodeHttpServer.layerTest)),
1112 +);
1113 +
1114 it.effect("admits provider and OAuth client credentials and points only clients at OAuth", () =>
1115 Effect.scoped(
1116 Effect.gen(function* () {
apps/server/src/mcp/McpHttpServer.ts
+2 -1
@@ -1307,7 +1307,8 @@ export const layerMcpTransport = <RA, RE, RR>(registrations: Layer.Layer<RA, RE,
1307 name: "T3 Code",
1308 version: packageJson.version,
1309 path: "/mcp",
1310 - protocols: [McpProtocol.v2025_06_18],
1310 + // The first protocol is the fallback for clients that offer an unknown version.
1311 + protocols: [McpProtocol.v2025_06_18, McpProtocol.v2026_07_28],
1312 allowSessionTermination: true,
1313 registrations,
1314 }).pipe(Layer.provide(layerMcpAuthMiddleware));