Skip to content
Source
Sign inSign up
TanStack/ai
Open History to see the last commit

mcp-tool.test.ts

34 lines1005 Bytes

1import { describe, expect, it } from 'vitest'
2import { convertMCPToolToAdapterFormat } from '../src/tools/mcp-tool'
3import type { Tool } from '@tanstack/ai'
4​
5describe('convertMCPToolToAdapterFormat', () => {
6 it('should always set type to mcp even if metadata contains a type field', () => {
7 const tool: Tool = {
8 name: 'mcp',
9 description: 'test mcp tool',
10 metadata: {
11 type: 'not_mcp',
12 server_url: 'https://example.com/mcp',
13 },
14 }
15​
16 const result = convertMCPToolToAdapterFormat(tool)
17 expect(result.type).toBe('mcp')
18 })
19​
20 it('should preserve metadata fields other than type', () => {
21 const tool: Tool = {
22 name: 'mcp',
23 description: 'test mcp tool',
24 metadata: {
25 server_url: 'https://example.com/mcp',
26 server_description: 'Test server',
27 },
28 }
29​
30 const result = convertMCPToolToAdapterFormat(tool)
31 expect(result.type).toBe('mcp')
32 expect(result.server_url).toBe('https://example.com/mcp')
33 })
34})