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
+
1
3
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp' ;
2
4
import { StreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/streamableHttp.js' ;
3
5
@@ -67,19 +69,31 @@ const del = async (req: express.Request, res: express.Response) => {
67
69
} ) ;
68
70
} ;
69
71
70
- export const launchStreamableHTTPServer = async (
71
- options : McpOptions ,
72
- endpoints : Endpoint [ ] ,
73
- port : number | undefined ,
74
- ) => {
72
+ export const streamableHTTPApp = ( options : McpOptions ) => {
75
73
const app = express ( ) ;
76
74
app . use ( express . json ( ) ) ;
77
75
78
76
app . get ( '/' , get ) ;
79
77
app . post ( '/' , post ( options ) ) ;
80
78
app . delete ( '/' , del ) ;
81
79
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 ( ) ;
83
91
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
+ }
85
99
} ;
You can’t perform that action at this time.
0 commit comments