return the JSON stringified parameters from getDescription for MCP tools and Discovered tools (#6655)
This commit is contained in:
parent
4642de2a5c
commit
1738d40745
|
@ -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"}');
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import { safeJsonStringify } from '../utils/safeJsonStringify.js';
|
||||||
import {
|
import {
|
||||||
BaseDeclarativeTool,
|
BaseDeclarativeTool,
|
||||||
BaseToolInvocation,
|
BaseToolInvocation,
|
||||||
|
@ -152,7 +153,7 @@ class DiscoveredMCPToolInvocation extends BaseToolInvocation<
|
||||||
}
|
}
|
||||||
|
|
||||||
getDescription(): string {
|
getDescription(): string {
|
||||||
return this.displayName;
|
return safeJsonStringify(this.params);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -332,4 +332,14 @@ describe('ToolRegistry', () => {
|
||||||
expect(discoverSpy).toHaveBeenCalled();
|
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));
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -20,6 +20,7 @@ import { connectAndDiscover } from './mcp-client.js';
|
||||||
import { McpClientManager } from './mcp-client-manager.js';
|
import { McpClientManager } from './mcp-client-manager.js';
|
||||||
import { DiscoveredMCPTool } from './mcp-tool.js';
|
import { DiscoveredMCPTool } from './mcp-tool.js';
|
||||||
import { parse } from 'shell-quote';
|
import { parse } from 'shell-quote';
|
||||||
|
import { safeJsonStringify } from '../utils/safeJsonStringify.js';
|
||||||
|
|
||||||
type ToolParams = Record<string, unknown>;
|
type ToolParams = Record<string, unknown>;
|
||||||
|
|
||||||
|
@ -36,7 +37,7 @@ class DiscoveredToolInvocation extends BaseToolInvocation<
|
||||||
}
|
}
|
||||||
|
|
||||||
getDescription(): string {
|
getDescription(): string {
|
||||||
return `Calling discovered tool: ${this.toolName}`;
|
return safeJsonStringify(this.params);
|
||||||
}
|
}
|
||||||
|
|
||||||
async execute(
|
async execute(
|
||||||
|
|
|
@ -24,6 +24,7 @@ export interface ToolInvocation<
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a pre-execution description of the tool operation.
|
* Gets a pre-execution description of the tool operation.
|
||||||
|
*
|
||||||
* @returns A markdown string describing what the tool will do.
|
* @returns A markdown string describing what the tool will do.
|
||||||
*/
|
*/
|
||||||
getDescription(): string;
|
getDescription(): string;
|
||||||
|
|
Loading…
Reference in New Issue