modelcontextprotocol / modelcontextprotocol/python-sdk
More control over stderr in stdio client
Nessuno ha ancora preso questa issue.
- Lingua principale
- Python
- Stelle
- 24.3k
- Fork
- 4k
- Merge medio
- 1g 1h
- PR unite (30g)
- 31
Descrizione
Description
Currently, a TextIO object (defaulting to sys.stderr) must be set for errlog when creating a new stdio client session.
https://github.com/modelcontextprotocol/python-sdk/blob/2aa1ad2a69b56bc6cef089c9b4c3ecccbbc8e84d/src/mcp/client/stdio/__init__.py#L106
However, the underlying calls to Python's native Popen and anyio.create_process both support subprocess.DEVNULL: int = -3 for stderr, which allows the stream to be ignored.
By updating the type hint, we can easily support int for errlog. This change would benefit downstream projects and resolve issues for CLI users. Furthermore, I believe ignoring errlog is a better default than piping them into stderr, as the current behaviour can create unexpected side-effects that are difficult to trace.
References
Related Issues:
https://github.com/modelcontextprotocol/python-sdk/issues/156
https://github.com/langchain-ai/langchain-mcp-adapters/issues/72
Documentation:
https://docs.python.org/3/library/subprocess.html#subprocess.Popen
https://anyio.readthedocs.io/en/stable/api.html#anyio.open_process
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia in src/mcp/client/stdio/init.py, alla definizione di errlog citata nell’issue, quindi confronta i valori di stderr accettati in Python subprocess.Popen e anyio.create_process. Conferma la gestione prevista di subprocess.DEVNULL e aggiorna di conseguenza l’API client; il lavoro è completato quando i chiamanti possono passare il valore intero senza problemi di tipo o di runtime e il comportamento esistente di stderr rimane coperto.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- python
- Ambito
- api
- Tipo di issue
- Funzionalità
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Stato di attività
- Tranquilla
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 68/100