Skip to content

Commit aa035a0

Browse files
committed
fix: tool loader base dir
1 parent 369fd36 commit aa035a0

File tree

2 files changed

+18
-11
lines changed

2 files changed

+18
-11
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "mcp-framework",
3-
"version": "0.1.25",
3+
"version": "0.1.25-beta.6",
44

55
"description": "Framework for building Model Context Protocol (MCP) servers in Typescript",
66
"type": "module",

src/core/MCPServer.ts

+17-10
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)