fix(core)!: Force policy config to specify toolName (#23330)

This commit is contained in:
Keith Schaab
2026-03-23 22:35:08 +00:00
committed by GitHub
parent 2a18e78611
commit b35c12d8d0
18 changed files with 224 additions and 64 deletions
+5 -1
View File
@@ -1755,7 +1755,11 @@ export interface McpContext {
setUserInteractedWithMcp?(): void;
isTrustedFolder(): boolean;
getPolicyEngine?(): {
getRules(): ReadonlyArray<{ toolName?: string; source?: string }>;
getRules(): ReadonlyArray<{
toolName: string;
mcpName?: string;
source?: string;
}>;
};
}
+4
View File
@@ -99,6 +99,10 @@ describe('formatMcpToolName', () => {
expect(formatMcpToolName('github', '*')).toBe('mcp_github_*');
});
it('should handle both server and tool wildcards', () => {
expect(formatMcpToolName('*', '*')).toBe('mcp_*');
});
it('should handle undefined toolName as a tool-level wildcard', () => {
expect(formatMcpToolName('github')).toBe('mcp_github_*');
});
+2 -2
View File
@@ -80,11 +80,11 @@ export function formatMcpToolName(
serverName: string,
toolName?: string,
): string {
if (serverName === '*' && !toolName) {
if (serverName === '*' && (toolName === undefined || toolName === '*')) {
return `${MCP_TOOL_PREFIX}*`;
} else if (serverName === '*') {
return `${MCP_TOOL_PREFIX}*_${toolName}`;
} else if (!toolName) {
} else if (toolName === undefined || toolName === '*') {
return `${MCP_TOOL_PREFIX}${serverName}_*`;
} else {
return `${MCP_TOOL_PREFIX}${serverName}_${toolName}`;