|
6 | 6 |
|
7 | 7 | import { describe, it, expect } from 'vitest'; |
8 | 8 | import { ValidationError } from '../core/errors.js'; |
9 | | -import { resolveUpstreamMcpConfig, hasUpstreamMcpFlag } from './upstream-mcp-config.js'; |
| 9 | +import { resolveUpstreamMcpConfig, hasUpstreamMcpFlag, looksLikeUpstreamMcpProxy } from './upstream-mcp-config.js'; |
10 | 10 | import type { Profile } from '../types/profile.js'; |
11 | 11 |
|
12 | 12 | /** Minimal valid tool definition to satisfy Profile type. */ |
@@ -371,3 +371,57 @@ describe('upstream_mcp_from_env D-01 migration', () => { |
371 | 371 | expect(resolved?.name).toBe('p1'); |
372 | 372 | }); |
373 | 373 | }); |
| 374 | + |
| 375 | +describe('looksLikeUpstreamMcpProxy', () => { |
| 376 | + it('returns true for valid http-streamable object', () => { |
| 377 | + expect(looksLikeUpstreamMcpProxy({ |
| 378 | + name: 'p1', |
| 379 | + transport: { type: 'http-streamable', url: 'https://example.com/mcp' }, |
| 380 | + })).toBe(true); |
| 381 | + }); |
| 382 | + |
| 383 | + it('returns false for null', () => { |
| 384 | + expect(looksLikeUpstreamMcpProxy(null)).toBe(false); |
| 385 | + }); |
| 386 | + |
| 387 | + it('returns false for undefined', () => { |
| 388 | + expect(looksLikeUpstreamMcpProxy(undefined)).toBe(false); |
| 389 | + }); |
| 390 | + |
| 391 | + it('returns false for array (legacy shape)', () => { |
| 392 | + expect(looksLikeUpstreamMcpProxy([{ transport: { type: 'http-streamable', url: 'https://example.com/mcp' } }])).toBe(false); |
| 393 | + }); |
| 394 | + |
| 395 | + it('returns false for empty object', () => { |
| 396 | + expect(looksLikeUpstreamMcpProxy({})).toBe(false); |
| 397 | + }); |
| 398 | + |
| 399 | + it('returns false when transport is missing', () => { |
| 400 | + expect(looksLikeUpstreamMcpProxy({ name: 'p1' })).toBe(false); |
| 401 | + }); |
| 402 | + |
| 403 | + it('returns false for stdio transport', () => { |
| 404 | + expect(looksLikeUpstreamMcpProxy({ |
| 405 | + name: 'p1', |
| 406 | + transport: { type: 'stdio', command: 'npx' }, |
| 407 | + })).toBe(false); |
| 408 | + }); |
| 409 | + |
| 410 | + it('returns false when url is empty string', () => { |
| 411 | + expect(looksLikeUpstreamMcpProxy({ |
| 412 | + name: 'p1', |
| 413 | + transport: { type: 'http-streamable', url: ' ' }, |
| 414 | + })).toBe(false); |
| 415 | + }); |
| 416 | + |
| 417 | + it('returns false when url is missing', () => { |
| 418 | + expect(looksLikeUpstreamMcpProxy({ |
| 419 | + name: 'p1', |
| 420 | + transport: { type: 'http-streamable' }, |
| 421 | + })).toBe(false); |
| 422 | + }); |
| 423 | + |
| 424 | + it('returns false when transport is an array', () => { |
| 425 | + expect(looksLikeUpstreamMcpProxy({ transport: [{ type: 'http-streamable', url: 'https://example.com' }] })).toBe(false); |
| 426 | + }); |
| 427 | +}); |
0 commit comments