User-Agent header in sHTTP transport is not forwarded to auth flow

Aperta
#1,664 5 commenti 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
68/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
python

Direzione di ricerca

Inizia dall'utilizzo di streamablehttp_client in examples/clients/simple-auth-client/mcp_simple_auth_client/main.py, in particolare dall'argomento headers intorno alle righe 214-220, e traccia il modo in cui il flusso di autenticazione costruisce le sue requests. Verifica che uno User-Agent personalizzato raggiunga tali requests, incluso il caso d'uso di AWS WAF; il lavoro è completato quando i chiamanti possono configurare l'header tramite l'SDK senza disabilitare tale regola.

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

Descrizione

auth bug P2 ready for work
Initial Checks
Description

Passing a custom User-Agent header to the sHTTP transport, e.g. here does not result in auth flow requests including that user agent. There also does not appear to be any way to customize this behavior externally to the SDK itself.

In particular, this becomes a problem when working with AWS WAF, as one of its baseline rules is to require all requests to include a User-Agent header, to filter out low-grade spam.

I am currently recommending to internal teams that they disable this rule for the time being, but this is not a great solution for them, as it means removing an application guardrail to work around an SDK limitation.

Example Code
print("📡 Opening StreamableHTTP transport connection with auth...")
async with streamablehttp_client(
    url=self.server_url,
    auth=oauth_auth,
    timeout=timedelta(seconds=60),
    headers={
        "User-Agent": "mcp-python-sdk/0.1.0",
    },
) as (read_stream, write_stream, get_session_id):
    await self._run_session(read_stream, write_stream, get_session_id)
Python & MCP Python SDK

Latest SDK commit: 27279bc (1.22.0)
Python 3.13.2

Lingua principale
Python
Stelle
24.3k
Fork
4k
Merge medio
1g 1h
PR unite (30g)
31

Guida per i contributori

Apri la guida per i contributori

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

Tutte le issue di modelcontextprotocol/python-sdk

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.