-
Notifications
You must be signed in to change notification settings - Fork 511
[Bug] Compilation Error: Cannot convert 'Tool' to 'ChatQuery.ChatCompletionToolParam' when using MCP Tooling #389
Copy link
Copy link
Open
Description
[Bug] Compilation Error: Cannot convert 'Tool' to 'ChatQuery.ChatCompletionToolParam' when using MCP Tooling
I am attempting to integrate MCP tools following the example provided in the README. However, the provided code snippet results in a compilation error during the initialization of ChatQuery.
Code Snippet (based on documentation example):
// Connect to MCP server using the MCP Swift library
let mcpClient = MCP.Client(name: "MyApp", version: "1.0.0")
let transport = HTTPClientTransport(
endpoint: URL(string: "https://api.githubcopilot.com/mcp/")!,
configuration: URLSessionConfiguration.default
)
let result = try await mcpClient.connect(transport: transport)
let toolsResponse = try await mcpClient.listTools()
// Create OpenAI MCP tool with discovered tools
let enabledToolNames = toolsResponse.tools.map { $0.name }
let mcpTool = Tool.mcpTool(
.init(
_type: .mcp,
serverLabel: "GitHub_MCP_Server",
serverUrl: "https://api.githubcopilot.com/mcp/",
allowedTools: .case1(enabledToolNames),
requireApproval: .case2(.always)
)
)
// Use in chat completion
let query = ChatQuery(
messages: [.user(.init(content: .string("Help me search GitHub repositories")))],
model: .gpt4_o,
tools: [mcpTool] // compilation error at this line
)Observed Error:
Cannot convert value of type 'Tool' to expected element type 'Array<ChatQuery.ChatCompletionToolParam>.ArrayLiteralElement' (aka 'ChatQuery.ChatCompletionToolParam')
System Information:
Operating System: macOS 15.6.1
Xcode Version: 26.0.1 (17A400)
OpenAI Swift Library Version: 0.4.6
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels