@@ -75,10 +75,7 @@ export class MCPServer {
75
75
private shutdownResolve ?: ( ) => void ;
76
76
77
77
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 ) ;
82
79
this . serverName = config . name ?? this . getDefaultName ( ) ;
83
80
this . serverVersion = config . version ?? this . getDefaultVersion ( ) ;
84
81
this . transportConfig = config . transport ?? { type : "stdio" } ;
@@ -87,13 +84,23 @@ export class MCPServer {
87
84
`Initializing MCP Server: ${ this . serverName } @${ this . serverVersion } `
88
85
) ;
89
86
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
+ }
93
95
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 ( ) ;
97
104
}
98
105
99
106
private createTransport ( ) : BaseTransport {
0 commit comments