File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 22
33import { startServer } from '../build/index.js' ;
44
5- startServer ( ) ;
5+ const args = process . argv . slice ( 2 ) ;
6+ const mode = args [ 0 ] ?. toLowerCase ( ) ;
7+
8+ if ( mode === 'http' ) {
9+ // If the HTTP server module exists, import and run it
10+ import ( '../build/http-server.js' )
11+ . catch ( error => {
12+ console . error ( 'Error starting HTTP server:' , error ) ;
13+ process . exit ( 1 ) ;
14+ } ) ;
15+ } else {
16+ // Default to stdio server
17+ startServer ( )
18+ . catch ( error => {
19+ console . error ( 'Error starting stdio server:' , error ) ;
20+ process . exit ( 1 ) ;
21+ } ) ;
22+ }
Original file line number Diff line number Diff line change 11import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js" ;
2- import startServer from "./server/server.js" ;
2+ import startServerImpl from "./server/server.js" ;
33
4- // Start the server
5- async function main ( ) {
4+ export const startServer = async ( ) => {
65 try {
7- const server = await startServer ( ) ;
6+ const server = await startServerImpl ( ) ;
87 const transport = new StdioServerTransport ( ) ;
98 await server . connect ( transport ) ;
109 console . error ( "Starknet MCP Server running on stdio" ) ;
10+ return server ;
1111 } catch ( error ) {
1212 console . error ( "Error starting Starknet MCP server:" , error ) ;
1313 process . exit ( 1 ) ;
1414 }
15- }
15+ } ;
1616
17- main ( ) . catch ( ( error ) => {
18- console . error ( "Fatal error in main():" , error ) ;
19- process . exit ( 1 ) ;
20- } ) ;
17+ // Start the server when this file is run directly
18+ if ( import . meta. url === `file://${ process . argv [ 1 ] } ` ) {
19+ startServer ( ) . catch ( ( error ) => {
20+ console . error ( "Fatal error in main():" , error ) ;
21+ process . exit ( 1 ) ;
22+ } ) ;
23+ }
You can’t perform that action at this time.
0 commit comments