1- import { ConformanceCheck , CheckStatus } from '../types.js' ;
2-
3- export function createServerInitializationCheck ( initializeResponse : any , expectedSpecVersion : string = '2025-06-18' ) : ConformanceCheck {
4- const result = initializeResponse ?. result ;
5- const protocolVersion = result ?. protocolVersion ;
6- const serverInfo = result ?. serverInfo ;
7- const capabilities = result ?. capabilities ;
8-
9- const errors : string [ ] = [ ] ;
10- if ( ! initializeResponse ?. jsonrpc ) errors . push ( 'Missing jsonrpc field' ) ;
11- if ( ! initializeResponse ?. id ) errors . push ( 'Missing id field' ) ;
12- if ( ! result ) errors . push ( 'Missing result field' ) ;
13- if ( ! protocolVersion ) errors . push ( 'Missing protocolVersion in result' ) ;
14- if ( protocolVersion !== expectedSpecVersion ) errors . push ( `Protocol version mismatch: expected ${ expectedSpecVersion } , got ${ protocolVersion } ` ) ;
15- if ( ! serverInfo ) errors . push ( 'Missing serverInfo in result' ) ;
16- if ( ! serverInfo ?. name ) errors . push ( 'Missing server name in serverInfo' ) ;
17- if ( ! serverInfo ?. version ) errors . push ( 'Missing server version in serverInfo' ) ;
18- if ( capabilities === undefined ) errors . push ( 'Missing capabilities in result' ) ;
19-
20- const status : CheckStatus = errors . length === 0 ? 'SUCCESS' : 'FAILURE' ;
21-
22- return {
23- id : 'mcp-server-initialization' ,
24- name : 'MCPServerInitialization' ,
25- description : 'Validates that MCP server properly responds to initialize request' ,
26- status,
27- timestamp : new Date ( ) . toISOString ( ) ,
28- specReferences : [ { id : 'MCP-Lifecycle' , url : 'https://modelcontextprotocol.io/specification/2025-06-18/basic/lifecycle' } ] ,
29- details : {
30- expectedSpecVersion,
31- response : initializeResponse
32- } ,
33- errorMessage : errors . length > 0 ? errors . join ( '; ' ) : undefined ,
34- logs : errors . length > 0 ? errors : undefined
35- } ;
36- }
1+ import { ConformanceCheck , CheckStatus } from '../types.js' ;
0 commit comments