@@ -41,20 +41,26 @@ class StreamableHttpTransport implements TransportInterface
4141 private ?int $ outgoingStatusCode = null ;
4242
4343 /** @var array<string, string> */
44- private array $ corsHeaders = [
45- 'Access-Control-Allow-Origin ' => '* ' ,
46- 'Access-Control-Allow-Methods ' => 'GET, POST, DELETE, OPTIONS ' ,
47- 'Access-Control-Allow-Headers ' => 'Content-Type, Mcp-Session-Id, Mcp-Protocol-Version, Last-Event-ID, Authorization, Accept ' ,
48- ];
44+ private array $ corsHeaders ;
4945
46+ /**
47+ * @param array<string, string> $corsHeaders
48+ */
5049 public function __construct (
5150 private readonly ServerRequestInterface $ request ,
5251 private readonly ResponseFactoryInterface $ responseFactory ,
5352 private readonly StreamFactoryInterface $ streamFactory ,
53+ array $ corsHeaders = [],
5454 private readonly LoggerInterface $ logger = new NullLogger (),
5555 ) {
5656 $ sessionIdString = $ this ->request ->getHeaderLine ('Mcp-Session-Id ' );
5757 $ this ->sessionId = $ sessionIdString ? Uuid::fromString ($ sessionIdString ) : null ;
58+
59+ $ this ->corsHeaders = array_merge ([
60+ 'Access-Control-Allow-Origin ' => '* ' ,
61+ 'Access-Control-Allow-Methods ' => 'GET, POST, DELETE, OPTIONS ' ,
62+ 'Access-Control-Allow-Headers ' => 'Content-Type, Mcp-Session-Id, Mcp-Protocol-Version, Last-Event-ID, Authorization, Accept ' ,
63+ ], $ corsHeaders );
5864 }
5965
6066 public function initialize (): void
0 commit comments