summaryrefslogtreecommitdiff
path: root/packages/core/src
diff options
context:
space:
mode:
authorJacob MacDonald <[email protected]>2025-08-20 13:10:02 -0700
committerGitHub <[email protected]>2025-08-20 20:10:02 +0000
commit1738d407456aec9ab7733374a4709cff6d59d12d (patch)
tree0671de9960c9ef3fc3e1ddd002d14e1748bc62a8 /packages/core/src
parent4642de2a5ceaf264ce3238accc1142aec4661db4 (diff)
return the JSON stringified parameters from getDescription for MCP tools and Discovered tools (#6655)
Diffstat (limited to 'packages/core/src')
-rw-r--r--packages/core/src/tools/mcp-tool.test.ts9
-rw-r--r--packages/core/src/tools/mcp-tool.ts3
-rw-r--r--packages/core/src/tools/tool-registry.test.ts10
-rw-r--r--packages/core/src/tools/tool-registry.ts3
-rw-r--r--packages/core/src/tools/tools.ts1
5 files changed, 24 insertions, 2 deletions
diff --git a/packages/core/src/tools/mcp-tool.test.ts b/packages/core/src/tools/mcp-tool.test.ts
index 3a8c10c4..d5e4eee8 100644
--- a/packages/core/src/tools/mcp-tool.test.ts
+++ b/packages/core/src/tools/mcp-tool.test.ts
@@ -743,4 +743,13 @@ describe('DiscoveredMCPTool', () => {
}
});
});
+
+ describe('DiscoveredMCPToolInvocation', () => {
+ it('should return the stringified params from getDescription', () => {
+ const params = { param: 'testValue', param2: 'anotherOne' };
+ const invocation = tool.build(params);
+ const description = invocation.getDescription();
+ expect(description).toBe('{"param":"testValue","param2":"anotherOne"}');
+ });
+ });
});
diff --git a/packages/core/src/tools/mcp-tool.ts b/packages/core/src/tools/mcp-tool.ts
index 64952dd1..baa517f6 100644
--- a/packages/core/src/tools/mcp-tool.ts
+++ b/packages/core/src/tools/mcp-tool.ts
@@ -4,6 +4,7 @@
* SPDX-License-Identifier: Apache-2.0
*/
+import { safeJsonStringify } from '../utils/safeJsonStringify.js';
import {
BaseDeclarativeTool,
BaseToolInvocation,
@@ -152,7 +153,7 @@ class DiscoveredMCPToolInvocation extends BaseToolInvocation<
}
getDescription(): string {
- return this.displayName;
+ return safeJsonStringify(this.params);
}
}
diff --git a/packages/core/src/tools/tool-registry.test.ts b/packages/core/src/tools/tool-registry.test.ts
index cccf011f..6db60377 100644
--- a/packages/core/src/tools/tool-registry.test.ts
+++ b/packages/core/src/tools/tool-registry.test.ts
@@ -332,4 +332,14 @@ describe('ToolRegistry', () => {
expect(discoverSpy).toHaveBeenCalled();
});
});
+
+ describe('DiscoveredToolInvocation', () => {
+ it('should return the stringified params from getDescription', () => {
+ const tool = new DiscoveredTool(config, 'test-tool', 'A test tool', {});
+ const params = { param: 'testValue' };
+ const invocation = tool.build(params);
+ const description = invocation.getDescription();
+ expect(description).toBe(JSON.stringify(params));
+ });
+ });
});
diff --git a/packages/core/src/tools/tool-registry.ts b/packages/core/src/tools/tool-registry.ts
index 90531742..7acd778d 100644
--- a/packages/core/src/tools/tool-registry.ts
+++ b/packages/core/src/tools/tool-registry.ts
@@ -20,6 +20,7 @@ import { connectAndDiscover } from './mcp-client.js';
import { McpClientManager } from './mcp-client-manager.js';
import { DiscoveredMCPTool } from './mcp-tool.js';
import { parse } from 'shell-quote';
+import { safeJsonStringify } from '../utils/safeJsonStringify.js';
type ToolParams = Record<string, unknown>;
@@ -36,7 +37,7 @@ class DiscoveredToolInvocation extends BaseToolInvocation<
}
getDescription(): string {
- return `Calling discovered tool: ${this.toolName}`;
+ return safeJsonStringify(this.params);
}
async execute(
diff --git a/packages/core/src/tools/tools.ts b/packages/core/src/tools/tools.ts
index 761b670a..64a2e83a 100644
--- a/packages/core/src/tools/tools.ts
+++ b/packages/core/src/tools/tools.ts
@@ -24,6 +24,7 @@ export interface ToolInvocation<
/**
* Gets a pre-execution description of the tool operation.
+ *
* @returns A markdown string describing what the tool will do.
*/
getDescription(): string;