summaryrefslogtreecommitdiff
path: root/packages/core/src/tools/mcp-tool.test.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/core/src/tools/mcp-tool.test.ts')
-rw-r--r--packages/core/src/tools/mcp-tool.test.ts72
1 files changed, 72 insertions, 0 deletions
diff --git a/packages/core/src/tools/mcp-tool.test.ts b/packages/core/src/tools/mcp-tool.test.ts
index 2e700710..b5843b95 100644
--- a/packages/core/src/tools/mcp-tool.test.ts
+++ b/packages/core/src/tools/mcp-tool.test.ts
@@ -325,5 +325,77 @@ describe('DiscoveredMCPTool', () => {
);
}
});
+
+ it('should handle Cancel confirmation outcome', async () => {
+ const tool = new DiscoveredMCPTool(
+ mockCallableToolInstance,
+ serverName,
+ serverToolName,
+ baseDescription,
+ inputSchema,
+ );
+ const confirmation = await tool.shouldConfirmExecute(
+ {},
+ new AbortController().signal,
+ );
+ expect(confirmation).not.toBe(false);
+ if (
+ confirmation &&
+ typeof confirmation === 'object' &&
+ 'onConfirm' in confirmation &&
+ typeof confirmation.onConfirm === 'function'
+ ) {
+ // Cancel should not add anything to allowlist
+ await confirmation.onConfirm(ToolConfirmationOutcome.Cancel);
+ expect((DiscoveredMCPTool as any).allowlist.has(serverName)).toBe(
+ false,
+ );
+ expect(
+ (DiscoveredMCPTool as any).allowlist.has(
+ `${serverName}.${serverToolName}`,
+ ),
+ ).toBe(false);
+ } else {
+ throw new Error(
+ 'Confirmation details or onConfirm not in expected format',
+ );
+ }
+ });
+
+ it('should handle ProceedOnce confirmation outcome', async () => {
+ const tool = new DiscoveredMCPTool(
+ mockCallableToolInstance,
+ serverName,
+ serverToolName,
+ baseDescription,
+ inputSchema,
+ );
+ const confirmation = await tool.shouldConfirmExecute(
+ {},
+ new AbortController().signal,
+ );
+ expect(confirmation).not.toBe(false);
+ if (
+ confirmation &&
+ typeof confirmation === 'object' &&
+ 'onConfirm' in confirmation &&
+ typeof confirmation.onConfirm === 'function'
+ ) {
+ // ProceedOnce should not add anything to allowlist
+ await confirmation.onConfirm(ToolConfirmationOutcome.ProceedOnce);
+ expect((DiscoveredMCPTool as any).allowlist.has(serverName)).toBe(
+ false,
+ );
+ expect(
+ (DiscoveredMCPTool as any).allowlist.has(
+ `${serverName}.${serverToolName}`,
+ ),
+ ).toBe(false);
+ } else {
+ throw new Error(
+ 'Confirmation details or onConfirm not in expected format',
+ );
+ }
+ });
});
});