mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-04-20 10:10:56 -07:00
fix(core)!: Force policy config to specify toolName (#23330)
This commit is contained in:
@@ -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;
|
||||
}>;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -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_*');
|
||||
});
|
||||
|
||||
@@ -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}`;
|
||||
|
||||
Reference in New Issue
Block a user