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

Server fails to decode ChatGPT's `initialize` (`experimental` typed `[String: String]`, `extensions` unmodeled); error is returned inside an HTTP 200

Aperta
#262 1 commento 1 reazione 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

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

Direzione di ricerca

Start in Sources/MCP/Client/Client.swift at Client.Capabilities and compare its decoding with the initialize JSON shown in the issue and the 2025-11-25 schema. Verify that nested experimental entries and extensions decode without preventing the initialize handler from running, then confirm the resulting request no longer returns the JSON-RPC error inside HTTP 200.

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

Descrizione

bug

Describe the bug
Client.Capabilities types experimental as [String: String]? (Sources/MCP/Client/Client.swift, line 128 in 0.12.1) and has no extensions property. The MCP schema defines experimental as a map of arbitrary objects ({ [key: string]: object }), and extensions is a spec-defined ClientCapabilities field as of protocol 2025-11-25 (https://modelcontextprotocol.io/extensions/overview).

ChatGPT's MCP client (openai-mcp, protocol 2025-11-25) sends both fields. The SDK's request decoder throws while decoding initialize — before any server handler runs — and StatelessHTTPServerTransport returns the JSON-RPC error inside an HTTP 200 response, making the failed handshake indistinguishable from success at the HTTP layer.

Practical impact: every Swift-SDK server fails ChatGPT Developer-Mode connector setup. ChatGPT shows the connector as "Connected" (OAuth succeeds) but imports zero actions and displays a generic error banner. Because nothing 4xx/5xx appears anywhere, this took us a two-day investigation across OAuth, transports, and tool schemas before we inspected the JSON-RPC body of a "200 OK" initialize.

To Reproduce
Steps to reproduce the behavior:

  1. Run any MCP server built on swift-sdk 0.12.1 with StatelessHTTPServerTransport (a single tool is enough).
  2. POST the following initialize request (captured verbatim from ChatGPT Developer Mode, July 2026) to the server's MCP endpoint:
{
  "jsonrpc": "2.0",
  "method": "initialize",
  "id": 1,
  "params": {
    "protocolVersion": "2025-11-25",
    "clientInfo": { "name": "openai-mcp", "version": "1.0.0" },
    "capabilities": {
      "experimental": {
        "openai/visibility": { "enabled": true }
      },
      "extensions": {
        "io.modelcontextprotocol/ui": { "mimeTypes": ["text/html;profile=mcp-app"] }
      }
    }
  }
}
  1. Observe an HTTP 200 whose body is a JSON-RPC internal error; the server's initialize handler never runs.
  2. Real-world trigger: add the server as a ChatGPT Developer-Mode custom connector — OAuth completes, then setup fails with no actions imported.

Expected behavior
The initialize request decodes and succeeds. experimental["openai/visibility"] is a nested object, which is valid per the schema, and extensions is a spec-defined field. More defensively: unknown or unexpectedly-shaped entries inside capabilities should arguably never fail the entire initialize — capability objects evolve faster than typed models, and a server that ignores capabilities it does not consume is spec-safe.

Logs
Response to the request above (HTTP status 200):

{
  "jsonrpc": "2.0",
  "id": 1,
  "error": {
    "code": -32603,
    "message": "Internal error: The operation could not be completed. The data isn’t in the correct format."
  }
}

Server-side request logging shows only a successful-looking POST; no 4xx/5xx is emitted anywhere in the exchange.

Additional context

  • Suggested fix: type experimental as [String: Value]? (or another arbitrary-JSON container) to match the schema, and add extensions: [String: Value]? per the 2025-11-25 spec. Also worth considering: surfacing request-decode failures distinctly from handler errors, so servers can log them — the 200-wrapped -32603 actively hides this class of bug.
  • Workaround we run in production: strip params.capabilities.experimental and params.capabilities.extensions from initialize bodies before handing the request to the SDK transport (safe when the server doesn't consume them). This fully restores ChatGPT connector functionality.
  • Happy to open a PR for the capability typing if maintainers agree with the direction.
Lingua principale
Swift
Stelle
1.5k
Fork
246
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

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 modelcontextprotocol/swift-sdk

Tutte le issue di modelcontextprotocol/swift-sdk

Issue simili

Altre issue su Swift

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.