Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
| 1 | import { describe, it, expect, vi } from 'vitest'; |
| 2 | import ComposioClient, { Auth, createFetchTransport } from '@composio/client'; |
| 3 | import { MCP } from '../../src/models/MCP'; |
| 4 | import logger from '../../src/utils/logger'; |
| 5 | |
| 6 | vi.mock('../../src/telemetry/Telemetry', () => ({ |
| 7 | telemetry: { instrument: vi.fn() }, |
| 8 | })); |
| 9 | |
| 10 | const json = (body: unknown) => |
| 11 | new Response(JSON.stringify(body), { headers: { 'content-type': 'application/json' } }); |
| 12 | |
| 13 | describe('MCP.generate managed auth deprecation', () => { |
| 14 | it('replaces the API client notice with one SDK notice per process', async () => { |
| 15 | const clientLogger = { error: vi.fn(), warn: vi.fn(), info: vi.fn(), debug: vi.fn() }; |
| 16 | const client = new ComposioClient({ |
| 17 | auth: Auth.project('test-api-key'), |
| 18 | baseURL: 'https://backend.composio.test', |
| 19 | logger: clientLogger, |
| 20 | logLevel: 'warn', |
| 21 | transport: createFetchTransport({ |
| 22 | fetch: async input => |
| 23 | String(input).includes('/generate') |
| 24 | ? json({ mcp_url: 'https://mcp.test', connected_account_urls: [], user_ids_url: ['u'] }) |
| 25 | : json({ id: 'mcp_123', name: 'server', allowed_tools: [], auth_config_ids: [] }), |
| 26 | }), |
| 27 | }); |
| 28 | const sdkWarn = vi.spyOn(logger, 'warn').mockImplementation(() => {}); |
| 29 | const mcp = new MCP(client); |
| 30 | |
| 31 | await mcp.generate('user123', 'mcp_123'); |
| 32 | await mcp.generate('user123', 'mcp_123'); |
| 33 | await mcp.generate('user123', 'mcp_123', { manuallyManageConnections: true }); |
| 34 | |
| 35 | expect(clientLogger.warn).not.toHaveBeenCalled(); |
| 36 | expect(sdkWarn).toHaveBeenCalledTimes(1); |
| 37 | expect(sdkWarn.mock.calls[0][0]).toContain('include_composio_helper_actions'); |
| 38 | }); |
| 39 | }); |