Type annotation gaps and unhandled FileNotFoundError in src/mcp/cli/cli.py
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 84/100
Línea de trabajo
Lee src/mcp/cli/cli.py, centrándote en _get_npx_command, _import_server y _check_server_object. Comprueba cómo gestiona la consulta de npx en Windows la ausencia del ejecutable y, después, ejecuta las pruebas pertinentes de CLI y las comprobaciones indicadas de Ruff y Pyright. El trabajo estará terminado cuando se gestione la excepción y las anotaciones solicitadas superen esas comprobaciones.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Environment / Context
While running static analysis (ruff check --select ANN and pyright) on src/mcp/cli/cli.py during local development, I noticed a few missing type annotations and an uncaught exception edge case on Windows.
Description
-
Unhandled
FileNotFoundErrorin_get_npx_command:
Insrc/mcp/cli/cli.py,_get_npx_command()attempts to probe fornpxexecutables on Windows inside atry...except subprocess.CalledProcessError:block. Ifnpx.cmdornpx.exeis missing from the system entirely,subprocess.runraisesFileNotFoundErrorbeforeCalledProcessErrorcan be raised, causing an unexpected crash instead of returningNone. -
Missing Return Type Annotations (
ANN202):_get_npx_command()lacks a return type annotation (returnsstr | None)._import_server()lacks a return type annotation._check_server_object()lacks a return type annotation (-> bool).
-
AnyType Usage (ANN401):_check_server_object()usesserver_object: Any, which can be tightened toobjectsince it performs runtimeisinstancechecks.
Proposed Fix
- Update
_get_npx_command()to catch(subprocess.CalledProcessError, FileNotFoundError)and returnstr | None. - Add explicit return type annotations to
_import_serverand_check_server_object. - Replace
server_object: Anywithserver_object: object.
I would be happy to submit a PR for this if a maintainer is willing to assign the issue to me!
I know that the contributing guidelines for this project forbid direct PRs about formatting and such without assigning, so just putting this out there.
(Note: Disclosing per guidelines that AI tools were used to assist in local testing and analysis; I am ready to own, test, and answer questions on the proposed changes).
- Lenguaje dominante
- Python
- Estrellas
- 24.5k
- Forks
- 4k
- Merge medio
- 15 h 19 min
- PR fusionados (30 d)
- 32
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de modelcontextprotocol/python-sdk
-
Streamable HTTP server rejects a mixed-case Content-Type with 415Posiblemente ocupada @CRYPTONIKAV la tomó hace 1 día. Abiertobug v1 v2
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
modelcontextprotocol/python-sdk#3670 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
-
Bug in the MCP Apps documentation.Posiblemente ocupada @Kludex la tomó hoy. Abiertodocumentation v2
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
modelcontextprotocol/python-sdk#3662 ·
Los mantenedores suelen responder en 1 día
-
Audio(data=b"") raises "Either path or data can be provided", while Image(data=b"") worksPosiblemente ocupada @KaiyiQuan la tomó hace 3 días. Abiertobug v1 v2
Dificultad 1/5 Menos de una hora Aptitud para principiantes 85/100
modelcontextprotocol/python-sdk#3656 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
enhancement
Dificultad 2/5 1-3 horas Aptitud para principiantes 66/100
modelcontextprotocol/python-sdk#3655 ·
Los mantenedores suelen responder en 1 día
-
Simple chatbot: unused Server.stdio_context attribute obscures transport ownershipPosiblemente ocupada @Kludex la tomó hoy. Abiertoenhancement
Dificultad 1/5 Menos de una hora Aptitud para principiantes 86/100
modelcontextprotocol/python-sdk#3654 ·
Los mantenedores suelen responder en 1 día
Todos los issues de modelcontextprotocol/python-sdk
Issues similares
-
Broken links found in docsAbiertodocs pydanty:is-working
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
pydantic/pydantic-ai#10113 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 77/100
GreedyBear-Project/GreedyBear#1727 ·
Los mantenedores suelen responder en 2 días
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
ARM-software/CMSIS-DSP#354 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
kiat/codeAssist#391 ·
-
needs triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 83/100
darnitdevorg/darnit#587 ·
Los mantenedores suelen responder en 1 día