@@ -12,13 +12,13 @@ import type {
1212 JSONRPCResultResponse ,
1313 RequestId
1414} from '@modelcontextprotocol/core' ;
15+ import type { EventId , EventStore , StreamId } from '@modelcontextprotocol/server' ;
16+ import { McpServer } from '@modelcontextprotocol/server' ;
1517import type { ZodMatrixEntry } from '@modelcontextprotocol/test-helpers' ;
1618import { listenOnRandomPort , zodTestMatrix } from '@modelcontextprotocol/test-helpers' ;
19+ import { afterEach , beforeEach , describe , expect , it } from 'vitest' ;
1720
1821import { NodeStreamableHTTPServerTransport } from '../src/streamableHttp.js' ;
19- import { McpServer } from '@modelcontextprotocol/server' ;
20- import type { EventId , EventStore , StreamId } from '@modelcontextprotocol/server' ;
21- import { describe , expect , beforeEach , afterEach , it } from 'vitest' ;
2222
2323async function getFreePort ( ) {
2424 return new Promise ( res => {
@@ -402,10 +402,15 @@ describe.each(zodTestMatrix)('$zodVersionLabel', (entry: ZodMatrixEntry) => {
402402 'A simple test tool with request info' ,
403403 { name : z . string ( ) . describe ( 'Name to greet' ) } ,
404404 async ( { name } , { requestInfo } ) : Promise < CallToolResult > => {
405+ // Convert Headers object to plain object for JSON serialization
406+ // Headers is a Web API class that doesn't serialize with JSON.stringify
407+ const serializedRequestInfo = {
408+ headers : Object . fromEntries ( requestInfo ?. headers ?? new Headers ( ) )
409+ } ;
405410 return {
406411 content : [
407412 { type : 'text' , text : `Hello, ${ name } !` } ,
408- { type : 'text' , text : `${ JSON . stringify ( requestInfo ) } ` }
413+ { type : 'text' , text : `${ JSON . stringify ( serializedRequestInfo ) } ` }
409414 ]
410415 } ;
411416 }
0 commit comments