Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions packages/core/src/tools/mcp-tool.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -736,7 +736,7 @@ describe('DiscoveredMCPTool', () => {
});

describe('getDefaultPermission and getConfirmationDetails', () => {
it('should return ask even if trust is true and folder is trusted (trust logic moved to PM)', async () => {
it('should return allow when trust is true', async () => {
const trustedTool = new DiscoveredMCPTool(
mockCallableToolInstance,
serverName,
Expand All @@ -748,7 +748,7 @@ describe('DiscoveredMCPTool', () => {
{ isTrustedFolder: () => true } as any,
);
const invocation = trustedTool.build({ param: 'mock' });
expect(await invocation.getDefaultPermission()).toBe('ask');
expect(await invocation.getDefaultPermission()).toBe('allow');
});

it('should return ask if not trusted', async () => {
Expand Down Expand Up @@ -808,7 +808,7 @@ describe('DiscoveredMCPTool', () => {
isTrustedFolder: () => isTrusted,
});

it('should return ask even if trust is true and folder is trusted (trust logic moved to PM)', async () => {
it('should return allow when trust is true and folder is trusted', async () => {
const trustedTool = new DiscoveredMCPTool(
mockCallableToolInstance,
serverName,
Expand All @@ -820,7 +820,7 @@ describe('DiscoveredMCPTool', () => {
mockConfig(true) as any, // isTrustedFolder = true
);
const invocation = trustedTool.build({ param: 'mock' });
expect(await invocation.getDefaultPermission()).toBe('ask');
expect(await invocation.getDefaultPermission()).toBe('allow');
});

it('should return ask if trust is true but folder is not trusted', async () => {
Expand Down
11 changes: 7 additions & 4 deletions packages/core/src/tools/mcp-tool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,14 +124,17 @@ class DiscoveredMCPToolInvocation extends BaseToolInvocation<
}

/**
* MCP tool default permission based on annotations:
* MCP tool default permission based on trust and annotations:
* - trust: true in a trusted folder → 'allow' (server explicitly trusted by user config)
* - readOnlyHint → 'allow'
* - All other MCP tools → 'ask'
*
* Note: trust/isTrustedFolder logic is now handled by PM rules,
* not by getDefaultPermission().
*/
override async getDefaultPermission(): Promise<PermissionDecision> {
// MCP servers explicitly marked as trusted bypass confirmation,
// but only when the workspace folder is also trusted (security gate).
if (this.trust === true && this.cliConfig?.isTrustedFolder()) {
return 'allow';
}
// MCP tools annotated with readOnlyHint: true are safe
if (this.annotations?.readOnlyHint === true) {
return 'allow';
Expand Down
Loading