File tree 2 files changed +30
-10
lines changed
2 files changed +30
-10
lines changed Original file line number Diff line number Diff line change 2
2
3
3
import { startServer } from '../build/index.js' ;
4
4
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 1
1
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js" ;
2
- import startServer from "./server/server.js" ;
2
+ import startServerImpl from "./server/server.js" ;
3
3
4
- // Start the server
5
- async function main ( ) {
4
+ export const startServer = async ( ) => {
6
5
try {
7
- const server = await startServer ( ) ;
6
+ const server = await startServerImpl ( ) ;
8
7
const transport = new StdioServerTransport ( ) ;
9
8
await server . connect ( transport ) ;
10
9
console . error ( "Starknet MCP Server running on stdio" ) ;
10
+ return server ;
11
11
} catch ( error ) {
12
12
console . error ( "Error starting Starknet MCP server:" , error ) ;
13
13
process . exit ( 1 ) ;
14
14
}
15
- }
15
+ } ;
16
16
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