Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

[Bug] Compilation Error: Cannot convert 'Tool' to 'ChatQuery.ChatCompletionToolParam' when using MCP Tooling

Aperta
#389 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 3 giorni

@mvanhorn ci sta già lavorando.

Dal 4/7/2026.

  • #436 di @mvanhorn — aperta

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
25/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
swift
Ambito
api

Direzione di ricerca

Start with the README example and the ChatQuery tool parameter definitions to see how MCP tools are expected to be represented. The issue is resolved when the documented MCP example compiles with the library’s supported tool type; an open pull request is already linked.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

[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

Lingua principale
Swift
Stelle
2.9k
Fork
519
Merge medio
4g 9h
PR unite (30g)
13

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di MacPaw/OpenAI

Tutte le issue di MacPaw/OpenAI

Issue simili

Altre issue su Swift

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.