1+ import { ConformanceCheck , CheckStatus } from '../types.js' ;
2+
3+ export function createServerInfoCheck ( serverInfo : { name : string ; version : string } ) : ConformanceCheck {
4+ return {
5+ id : 'server-info' ,
6+ name : 'ServerInfo' ,
7+ description : 'Test server info returned to client' ,
8+ status : 'INFO' ,
9+ timestamp : new Date ( ) . toISOString ( ) ,
10+ specReferences : [ { id : 'MCP-Lifecycle' , url : 'https://modelcontextprotocol.io/specification/2025-06-18/basic/lifecycle' } ] ,
11+ details : {
12+ serverName : serverInfo . name ,
13+ serverVersion : serverInfo . version
14+ }
15+ } ;
16+ }
17+
18+ export function createClientInitializationCheck ( initializeRequest : any , expectedSpecVersion : string = '2025-06-18' ) : ConformanceCheck {
19+ const protocolVersionSent = initializeRequest ?. protocolVersion ;
20+ const versionMatch = protocolVersionSent === expectedSpecVersion ;
21+
22+ const errors : string [ ] = [ ] ;
23+ if ( ! protocolVersionSent ) errors . push ( 'Protocol version not provided' ) ;
24+ if ( ! versionMatch ) errors . push ( `Version mismatch: expected ${ expectedSpecVersion } , got ${ protocolVersionSent } ` ) ;
25+ if ( ! initializeRequest ?. clientInfo ?. name ) errors . push ( 'Client name missing' ) ;
26+ if ( ! initializeRequest ?. clientInfo ?. version ) errors . push ( 'Client version missing' ) ;
27+
28+ const status : CheckStatus = errors . length === 0 ? 'SUCCESS' : 'FAILURE' ;
29+
30+ return {
31+ id : 'mcp-client-initialization' ,
32+ name : 'MCPClientInitialization' ,
33+ description : 'Validates that MCP client properly initializes with server' ,
34+ status,
35+ timestamp : new Date ( ) . toISOString ( ) ,
36+ specReferences : [ { id : 'MCP-Lifecycle' , url : 'https://modelcontextprotocol.io/specification/2025-06-18/basic/lifecycle' } ] ,
37+ details : {
38+ protocolVersionSent,
39+ expectedSpecVersion,
40+ versionMatch,
41+ clientName : initializeRequest ?. clientInfo ?. name ,
42+ clientVersion : initializeRequest ?. clientInfo ?. version
43+ } ,
44+ errorMessage : errors . length > 0 ? errors . join ( '; ' ) : undefined ,
45+ logs : errors . length > 0 ? errors : undefined
46+ } ;
47+ }
0 commit comments