Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

Type annotation gaps and unhandled FileNotFoundError in src/mcp/cli/cli.py

Abierto Apto para principiantes
#3,673 0 comentarios 0 reacciones 0 asignados Ver en GitHub

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
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
python
Área
cli

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

enhancement
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
  1. Unhandled FileNotFoundError in _get_npx_command:
    In src/mcp/cli/cli.py, _get_npx_command() attempts to probe for npx executables on Windows inside a try...except subprocess.CalledProcessError: block. If npx.cmd or npx.exe is missing from the system entirely, subprocess.run raises FileNotFoundError before CalledProcessError can be raised, causing an unexpected crash instead of returning None.

  2. Missing Return Type Annotations (ANN202):

    • _get_npx_command() lacks a return type annotation (returns str | None).
    • _import_server() lacks a return type annotation.
    • _check_server_object() lacks a return type annotation (-> bool).
  3. Any Type Usage (ANN401):

    • _check_server_object() uses server_object: Any, which can be tightened to object since it performs runtime isinstance checks.
Proposed Fix
  • Update _get_npx_command() to catch (subprocess.CalledProcessError, FileNotFoundError) and return str | None.
  • Add explicit return type annotations to _import_server and _check_server_object.
  • Replace server_object: Any with server_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

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de modelcontextprotocol/python-sdk

Todos los issues de modelcontextprotocol/python-sdk

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.