Skip to content

Commit 4f3fa17

Browse files
authored
Merge pull request #75 from dunward/main
Add option default stringify in BaseTool execute
2 parents c21faf8 + d0b98f4 commit 4f3fa17

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/tools/BaseTool.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ export abstract class MCPTool<TInput extends Record<string, any> = {}>
5151
abstract name: string;
5252
abstract description: string;
5353
protected abstract schema: ToolInputSchema<TInput>;
54+
protected useStringify: boolean = true;
5455
[key: string]: unknown;
5556

5657
get inputSchema(): { type: "object"; properties?: Record<string, unknown> } {
@@ -127,7 +128,10 @@ export abstract class MCPTool<TInput extends Record<string, any> = {}>
127128
}
128129

129130
return {
130-
content: [{ type: "text", text: JSON.stringify(data) }],
131+
content: [{
132+
type: "text",
133+
text: this.useStringify ? JSON.stringify(data) : String(data)
134+
}],
131135
};
132136
}
133137

0 commit comments

Comments
 (0)