@@ -3,7 +3,6 @@ import { StreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/
33import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js" ;
44import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" ;
55import { JSONRPCMessage } from "@modelcontextprotocol/sdk/types.js" ;
6- import { config } from "../../../src/common/config.js" ;
76import { z } from "zod" ;
87describe ( "streamableHttpTransport" , ( ) => {
98 let transport : StreamableHTTPServerTransport ;
@@ -20,7 +19,7 @@ describe("streamableHttpTransport", () => {
2019 description : "Say hello" ,
2120 inputSchema : { name : z . string ( ) } ,
2221 } ,
23- async ( { name } ) => ( {
22+ ( { name } ) => ( {
2423 content : [ { type : "text" , text : `Hello, ${ name } !` } ] ,
2524 } )
2625 ) ;
@@ -44,12 +43,23 @@ describe("streamableHttpTransport", () => {
4443
4544 it ( "handles requests and sends responses" , async ( ) => {
4645 client . onmessage = ( message : JSONRPCMessage ) => {
46+ const messageResult = message as
47+ | {
48+ result ?: {
49+ tools : {
50+ name : string ;
51+ description : string ;
52+ } [ ] ;
53+ } ;
54+ }
55+ | undefined ;
56+
4757 expect ( message . jsonrpc ) . toBe ( "2.0" ) ;
48- expect ( message . result ) . toBeDefined ( ) ;
49- expect ( message . result . tools ) . toBeDefined ( ) ;
50- expect ( message . result . tools . length ) . toBe ( 1 ) ;
51- expect ( message . result . tools [ 0 ] . name ) . toBe ( "hello" ) ;
52- expect ( message . result . tools [ 0 ] . description ) . toBe ( "Say hello" ) ;
58+ expect ( messageResult ) . toBeDefined ( ) ;
59+ expect ( messageResult ? .result ? .tools ) . toBeDefined ( ) ;
60+ expect ( messageResult ? .result ? .tools . length ) . toBe ( 1 ) ;
61+ expect ( messageResult ? .result ? .tools [ 0 ] ? .name ) . toBe ( "hello" ) ;
62+ expect ( messageResult ? .result ? .tools [ 0 ] ? .description ) . toBe ( "Say hello" ) ;
5363 } ;
5464
5565 await client . send ( {
0 commit comments