@@ -75,10 +75,7 @@ export class MCPServer {
7575 private shutdownResolve ?: ( ) => void ;
7676
7777 constructor ( config : MCPServerConfig = { } ) {
78- this . basePath = config . basePath
79- ? resolve ( config . basePath )
80- : join ( process . cwd ( ) , 'dist' ) ;
81-
78+ this . basePath = this . resolveBasePath ( config . basePath ) ;
8279 this . serverName = config . name ?? this . getDefaultName ( ) ;
8380 this . serverVersion = config . version ?? this . getDefaultVersion ( ) ;
8481 this . transportConfig = config . transport ?? { type : "stdio" } ;
@@ -87,13 +84,23 @@ export class MCPServer {
8784 `Initializing MCP Server: ${ this . serverName } @${ this . serverVersion } `
8885 ) ;
8986
90- this . toolLoader = new ToolLoader ( join ( this . basePath , 'tools' ) ) ;
91- this . promptLoader = new PromptLoader ( join ( this . basePath , 'prompts' ) ) ;
92- this . resourceLoader = new ResourceLoader ( join ( this . basePath , 'resources' ) ) ;
87+ this . toolLoader = new ToolLoader ( this . basePath ) ;
88+ this . promptLoader = new PromptLoader ( this . basePath ) ;
89+ this . resourceLoader = new ResourceLoader ( this . basePath ) ;
90+
91+ logger . debug ( `Looking for tools in: ${ join ( dirname ( this . basePath ) , 'tools' ) } ` ) ;
92+ logger . debug ( `Looking for prompts in: ${ join ( dirname ( this . basePath ) , 'prompts' ) } ` ) ;
93+ logger . debug ( `Looking for resources in: ${ join ( dirname ( this . basePath ) , 'resources' ) } ` ) ;
94+ }
9395
94- logger . debug ( `Looking for tools in: ${ join ( this . basePath , 'tools' ) } ` ) ;
95- logger . debug ( `Looking for prompts in: ${ join ( this . basePath , 'prompts' ) } ` ) ;
96- logger . debug ( `Looking for resources in: ${ join ( this . basePath , 'resources' ) } ` ) ;
96+ private resolveBasePath ( configPath ?: string ) : string {
97+ if ( configPath ) {
98+ return configPath ;
99+ }
100+ if ( process . argv [ 1 ] ) {
101+ return process . argv [ 1 ] ;
102+ }
103+ return process . cwd ( ) ;
97104 }
98105
99106 private createTransport ( ) : BaseTransport {
0 commit comments