Transport and AuthInfo are declared separately in server and client, so an AuthInfo augmentation breaks in-process connections

Aperta
#3,268 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@lipeh1 ci sta già lavorando.

Dal 4/12/2026.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
48/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
node.js, typescript

Direzione di ricerca

Start by reading the server and client package declarations for Transport, MessageExtraInfo, and AuthInfo, then trace how each package bundles the protocol engine and how both depend on @modelcontextprotocol/core. Reproduce the reported TypeScript error with the module augmentation under TypeScript 5.9.3 or 6.0.3. Done means the shared types remain assignable across the packages after augmentation, with the protocol engine shared at runtime as described.

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

Descrizione

v2

Packages: @modelcontextprotocol/server and @modelcontextprotocol/client 2.4.0
TypeScript: 5.9.3 and 6.0.3, strict, module/moduleResolution nodenext

Summary

Each package's declaration bundle carries its own copy of the shared types (Transport, MessageExtraInfo, AuthInfo, …). Without changes they are structurally identical, but a server that adds fields to AuthInfo by module augmentation (a common way to type the extra data its auth layer attaches) changes only the server package's copy. A server-side transport, such as InMemoryTransport from the server package, then no longer type-checks as the client package's Transport, which breaks in-process client/server setups used in tests and embedding.

The runtime is duplicated the same way: server and client each bundle the protocol engine, so a process that loads both (a server that also calls other servers, or a test that uses both) holds both copies (about 3 MB of live heap in our measurement).

Reproduction

import { Client } from '@modelcontextprotocol/client';
import { InMemoryTransport } from '@modelcontextprotocol/server';

declare module '@modelcontextprotocol/server' {
  interface AuthInfo {
    tenantId: string;
  }
}

export async function connectInProcess(): Promise<void> {
  const [clientTransport] = InMemoryTransport.createLinkedPair();
  await new Client({ name: 'c', version: '1' }).connect(clientTransport);
}

Expected

Compiles, as it does without the augmentation (and as with 1.32.1, where one declaration of AuthInfo existed).

Actual

error TS2345: Argument of type 'InMemoryTransport' is not assignable to parameter of type 'Transport'.
  Types of property 'onmessage' are incompatible. … Types of parameters 'extra' and 'extra' are incompatible.

Suggestion

Declare the shared types once (for example in @modelcontextprotocol/core, which both packages already depend on) and have server and client re-export them, so augmentations and assignability hold across packages. The same would let the protocol engine be shared at runtime.

Lingua principale
TypeScript
Stelle
13.8k
Fork
2.5k
Merge medio
6g 23h
PR unite (30g)
2

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/typescript-sdk

Tutte le issue di modelcontextprotocol/typescript-sdk

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.