feat(policy): Propagate Tool Annotations for MCP Servers (#20083)

This commit is contained in:
Jerop Kipruto
2026-02-24 09:20:11 -05:00
committed by GitHub
parent ee2e947435
commit 15f6c8b8da
19 changed files with 455 additions and 41 deletions
+4 -1
View File
@@ -59,10 +59,11 @@ describe('policy.ts', () => {
expect(mockPolicyEngine.check).toHaveBeenCalledWith(
{ name: 'test-tool', args: {} },
undefined,
undefined,
);
});
it('should pass serverName for MCP tools', async () => {
it('should pass serverName and toolAnnotations for MCP tools', async () => {
const mockPolicyEngine = {
check: vi.fn().mockResolvedValue({ decision: PolicyDecision.ALLOW }),
} as unknown as Mocked<PolicyEngine>;
@@ -73,6 +74,7 @@ describe('policy.ts', () => {
const mcpTool = Object.create(DiscoveredMCPTool.prototype);
mcpTool.serverName = 'my-server';
mcpTool._toolAnnotations = { readOnlyHint: true };
const toolCall = {
request: { name: 'mcp-tool', args: {} },
@@ -83,6 +85,7 @@ describe('policy.ts', () => {
expect(mockPolicyEngine.check).toHaveBeenCalledWith(
{ name: 'mcp-tool', args: {} },
'my-server',
{ readOnlyHint: true },
);
});