File tree Expand file tree Collapse file tree 1 file changed +21
-7
lines changed Expand file tree Collapse file tree 1 file changed +21
-7
lines changed Original file line number Diff line number Diff line change 1+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
13import { McpServer } from '@modelcontextprotocol/sdk/server/mcp' ;
24import { StreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/streamableHttp.js' ;
35
@@ -67,19 +69,31 @@ const del = async (req: express.Request, res: express.Response) => {
6769 } ) ;
6870} ;
6971
70- export const launchStreamableHTTPServer = async (
71- options : McpOptions ,
72- endpoints : Endpoint [ ] ,
73- port : number | undefined ,
74- ) => {
72+ export const streamableHTTPApp = ( options : McpOptions ) => {
7573 const app = express ( ) ;
7674 app . use ( express . json ( ) ) ;
7775
7876 app . get ( '/' , get ) ;
7977 app . post ( '/' , post ( options ) ) ;
8078 app . delete ( '/' , del ) ;
8179
82- console . error ( `MCP Server running on streamable HTTP on port ${ port } ` ) ;
80+ return app ;
81+ } ;
82+
83+ export const launchStreamableHTTPServer = async (
84+ options : McpOptions ,
85+ endpoints : Endpoint [ ] ,
86+ port : number | undefined ,
87+ ) => {
88+ const app = streamableHTTPApp ( options ) ;
89+ const server = app . listen ( port ) ;
90+ const address = server . address ( ) ;
8391
84- app . listen ( port ) ;
92+ if ( typeof address === 'string' ) {
93+ console . error ( `MCP Server running on streamable HTTP at ${ address } ` ) ;
94+ } else if ( address !== null ) {
95+ console . error ( `MCP Server running on streamable HTTP on port ${ address . port } ` ) ;
96+ } else {
97+ console . error ( `MCP Server running on streamable HTTP on port ${ port } ` ) ;
98+ }
8599} ;
You can’t perform that action at this time.
0 commit comments