@@ -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+
826898it . effect ( "admits provider and OAuth client credentials and points only clients at OAuth" , ( ) =>
827899 Effect . scoped (
828900 Effect . gen ( function * ( ) {
0 commit comments