File tree Expand file tree Collapse file tree
packages/server/src/server Expand file tree Collapse file tree Original file line number Diff line number Diff line change 4848 cache-dependency-path : pnpm-lock.yaml
4949 - run : pnpm install
5050 - run : pnpm run build:all
51- - run : pnpm run test:conformance:server
51+ - run : pnpm run test:conformance:server:dual
Original file line number Diff line number Diff line change @@ -146,6 +146,18 @@ export class SessionCompat {
146146 response : jsonError ( 400 , - 32_600 , 'Invalid Request: Only one initialization request is allowed' )
147147 } ;
148148 }
149+ // v1 parity: an initialize POST that already carries an Mcp-Session-Id is a
150+ // re-init against an existing session and is rejected (the v1 app pattern
151+ // routed it to the existing transport, which returned "Server already
152+ // initialized"). Without this check a confused/retrying client mints a new
153+ // session per retry in multi-session mode.
154+ if ( req . headers . get ( 'mcp-session-id' ) !== null ) {
155+ this . _onerror ?.( new Error ( 'Invalid Request: initialize must not carry Mcp-Session-Id' ) ) ;
156+ return {
157+ ok : false ,
158+ response : jsonError ( 400 , - 32_600 , 'Invalid Request: Server already initialized' )
159+ } ;
160+ }
149161 this . _evictIdle ( ) ;
150162 if ( this . _singleSession && this . _sessions . size > 0 ) {
151163 this . _onerror ?.( new Error ( 'Invalid Request: Server already initialized' ) ) ;
You can’t perform that action at this time.
0 commit comments